Commit 9888c32f authored by Martin Bauer's avatar Martin Bauer
Browse files

Merge branch 'Field.__repr__' into 'master'

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

See merge request pycodegen/pystencils!90
parents 11d9663e 8140cfbf
......@@ -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
Supports Markdown
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