Commit ed864c0e authored by Martin Bauer's avatar Martin Bauer
Browse files

Field.Access consistently store offsets in sympyfied form

Field.Access compare fails when one field access returns the offsets as ints in its hashable contents
and another one as sp.Integers.
parent 0684cfe3
......@@ -701,7 +701,7 @@ class Field(AbstractField):
obj._offsets.append(o)
else:
obj._offsets.append(int(o))
obj._offsets = tuple(obj._offsets)
obj._offsets = tuple(sp.sympify(obj._offsets))
obj._offsetName = offset_name
obj._superscript = superscript
obj._index = idx
......
......@@ -327,14 +327,14 @@ def plot_2d(stencil, axes=None, figure=None, data=None, textsize='12', **kwargs)
text_box_style = BoxStyle("Round", pad=0.3)
head_length = 0.1
max_offsets = [max(abs(d[c]) for d in stencil) for c in (0, 1)]
max_offsets = [max(abs(int(d[c])) for d in stencil) for c in (0, 1)]
if data is None:
data = list(range(len(stencil)))
for direction, annotation in zip(stencil, data):
assert len(direction) == 2, "Works only for 2D stencils"
direction = tuple(int(i) for i in direction)
if not(direction[0] == 0 and direction[1] == 0):
axes.arrow(0, 0, direction[0], direction[1], head_width=0.08, head_length=head_length, color='k')
......@@ -443,6 +443,7 @@ def plot_3d(stencil, figure=None, axes=None, data=None, textsize='8'):
for d, annotation in zip(stencil, data):
assert len(d) == 3, "Works only for 3D stencils"
d = tuple(int(i) for i in d)
if not (d[0] == 0 and d[1] == 0 and d[2] == 0):
if d[0] == 0:
color = '#348abd'
......
......@@ -241,7 +241,7 @@ def create_intermediate_base_pointer(field_access, coordinates, previous_ptr):
if coordinate_id < field.spatial_dimensions:
offset += field.strides[coordinate_id] * field_access.offsets[coordinate_id]
if type(field_access.offsets[coordinate_id]) is int:
if field_access.offsets[coordinate_id].is_Integer:
name += "_%d%d" % (coordinate_id, field_access.offsets[coordinate_id])
else:
list_to_hash.append(field_access.offsets[coordinate_id])
......
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