Commit 76145cba authored by Martin Reinecke's avatar Martin Reinecke
Browse files

tweaks suggested by Theo

parent 3781a34e
Pipeline #18331 passed with stage
in 5 minutes and 57 seconds
......@@ -71,6 +71,8 @@ class DomainObject(with_metaclass(
True if `self` and x describe the same manifold.
"""
if self is x: # shortcut for simple case
return True
if isinstance(x, type(self)):
for key in list(vars(self).keys()):
......
......@@ -106,16 +106,15 @@ class Field(object):
if np.isscalar(val):
return () # empty domain tuple
raise TypeError("could not infer domain from value")
return utilities.parse_domain(domain)
@staticmethod
def _get_axes_tuple(things_with_shape):
i = 0
axes_list = []
for thing in things_with_shape:
axes_list = [None]*len(things_with_shape)
for idx, thing in enumerate(things_with_shape):
nax = len(thing.shape)
axes_list += [tuple(range(i, i+nax))]
axes_list[idx] = tuple(range(i, i+nax))
i += nax
return tuple(axes_list)
......@@ -627,9 +626,11 @@ class Field(object):
if isinstance(other, Field):
if other.domain != self.domain:
raise ValueError("domains are incompatible.")
return Field(self.domain, getattr(self.val, op)(other.val))
tval = getattr(self.val, op)(other.val)
return self if tval is self.val else Field(self.domain, tval)
return Field(self.domain, getattr(self.val, op)(other))
tval = getattr(self.val, op)(other)
return self if tval is self.val else Field(self.domain, tval)
def __add__(self, other):
return self._binary_helper(other, op='__add__')
......
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