Commit 8140cfbf authored by Stephan Seitz's avatar Stephan Seitz
Browse files

Change `Field.__repr__` to match representation in `pystencils.fields`

__repr__ of Field should look like

y: uint16_t[246,704,558]
x(3): float[20,40]

to match representation when using `pystencils.fields`
parent 974febd7
......@@ -83,7 +83,7 @@ def fields(description=None, index_dimensions=0, layout=None, field_type=FieldTy
Format string can be left out, field names are taken from keyword arguments.
>>> fields(f1=arr_s, f2=arr_s)
[f1, f2]
[f1: double[20,20], f2: double[20,20]]
The keyword names ``index_dimension`` and ``layout`` have special meaning, don't use them for field names
>>> f = fields(f=arr_v, index_dimensions=1)
......@@ -392,7 +392,19 @@ class Field(AbstractField):
return self.dtype.numpy_dtype.itemsize
def __repr__(self):
return self._field_name
if any(isinstance(s, sp.Symbol) for s in self.spatial_shape):
spatial_shape_str = f'{self.spatial_dimensions}d'
spatial_shape_str = ','.join(str(i) for i in self.spatial_shape)
index_shape_str = ','.join(str(i) for i in self.index_shape)
if self.index_shape:
return f'{self._field_name}({index_shape_str}): {self.dtype}[{spatial_shape_str}]'
return f'{self._field_name}: {self.dtype}[{spatial_shape_str}]'
def __str__(self):
def neighbor(self, coord_id, offset):
offset_list = [0] * self.spatial_dimensions
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment