Skip to content
Snippets Groups Projects
Commit de9255a7 authored by Sander Snoo's avatar Sander Snoo
Browse files

Added __rtruediv__

parent d8c82433
No related branches found
No related tags found
No related merge requests found
...@@ -181,6 +181,11 @@ class loop_obj(): ...@@ -181,6 +181,11 @@ class loop_obj():
cpy.data /= other cpy.data /= other
return cpy return cpy
def __rtruediv__(self, lhs):
cpy = copy.copy(self)
cpy.data = lhs / cpy.data
return cpy
def __round__(self, ndigits=None): def __round__(self, ndigits=None):
cpy = copy.copy(self) cpy = copy.copy(self)
cpy.data = np.round(self.data, ndigits) cpy.data = np.round(self.data, ndigits)
...@@ -242,13 +247,15 @@ class loop_obj(): ...@@ -242,13 +247,15 @@ class loop_obj():
def __combine_axis(this, other): def __combine_axis(this, other):
if isinstance(other, loop_obj): if isinstance(other, loop_obj):
if this.ndim != 1 and other.ndim != 1: if this.ndim != 1 and other.ndim != 1:
raise Exception(f'Cannot combine loops with shapes {this.shape} and {other.shape}') raise Exception(f'Cannot combine loops {this.names} and {other.names}'
f' with shapes {this.shape} and {other.shape}')
this_data = this.data this_data = this.data
other_data = other.data other_data = other.data
if this.axis[0] == other.axis[0]: if this.axis[0] == other.axis[0]:
if this.shape != other.shape: if this.shape != other.shape:
raise Exception(f'Cannot combine loops with shapes {this.shape} and {other.shape}') raise Exception(f'Cannot combine loops {this.names} and {other.names}'
f' with shapes {this.shape} and {other.shape}')
# assume axis are the same # assume axis are the same
# TODO check equality of units, setpoins, ... # TODO check equality of units, setpoins, ...
else: else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment