Skip to content

Commit 342eef2

Browse files
skhrgmhasself
authored andcommitted
feat: skip shape check for RangesMatrix math operations
1 parent 1a4a824 commit 342eef2

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

python/proj/ranges.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def __getitem__(self, index):
109109

110110
def __add__(self, x):
111111
if isinstance(x, Ranges):
112-
return self.__class__([d + x for d in self.ranges])
112+
return self.__class__([d + x for d in self.ranges], skip_shape_check=True)
113113
elif isinstance(x, RangesMatrix):
114114
# Check for shape compatibility.
115115
nd_a = len(self.shape)
@@ -122,16 +122,16 @@ def __add__(self, x):
122122
if nd_a == nd_b:
123123
# Broadcast if either has shape 1...
124124
if x.shape[0] == 1:
125-
return self.__class__([r + x[0] for r in self.ranges])
125+
return self.__class__([r + x[0] for r in self.ranges], skip_shape_check=True)
126126
elif self.shape[0] == 1:
127-
return self.__class__([self.ranges[0] + _x for _x in x])
127+
return self.__class__([self.ranges[0] + _x for _x in x], skip_shape_check=True)
128128
elif self.shape[0] == x.shape[0]:
129-
return self.__class__([r + d for r, d in zip(self.ranges, x)])
130-
return self.__class__([r + x for r in self.ranges])
129+
return self.__class__([r + d for r, d in zip(self.ranges, x)], skip_shape_check=True)
130+
return self.__class__([r + x for r in self.ranges], skip_shape_check=True)
131131

132132
def __mul__(self, x):
133133
if isinstance(x, Ranges):
134-
return self.__class__([d * x for d in self.ranges])
134+
return self.__class__([d * x for d in self.ranges], skip_shape_check=True)
135135
elif isinstance(x, RangesMatrix):
136136
# Check for shape compatibility.
137137
nd_a = len(self.shape)
@@ -144,15 +144,15 @@ def __mul__(self, x):
144144
if nd_a == nd_b:
145145
# Broadcast if either has shape 1...
146146
if x.shape[0] == 1:
147-
return self.__class__([r * x[0] for r in self.ranges])
147+
return self.__class__([r * x[0] for r in self.ranges], skip_shape_check=True)
148148
elif self.shape[0] == 1:
149-
return self.__class__([self.ranges[0] * _x for _x in x])
149+
return self.__class__([self.ranges[0] * _x for _x in x], skip_shape_check=True)
150150
elif self.shape[0] == x.shape[0]:
151-
return self.__class__([r * d for r, d in zip(self.ranges, x)])
152-
return self.__class__([r * x for r in self.ranges])
151+
return self.__class__([r * d for r, d in zip(self.ranges, x)], skip_shape_check=True)
152+
return self.__class__([r * x for r in self.ranges], skip_shape_check=True)
153153

154154
def __invert__(self):
155-
return self.__class__([~x for x in self.ranges])
155+
return self.__class__([~x for x in self.ranges], skip_shape_check=True)
156156

157157
@staticmethod
158158
def concatenate(items, axis=0):

0 commit comments

Comments
 (0)