Skip to content

Commit e6e16c6

Browse files
committed
added support for mixed operations (eg LArray + ndarray)
1 parent d502c65 commit e6e16c6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

larray/core.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,8 @@ def opmethod(self, other):
13521352
if isinstance(other, LArray):
13531353
#TODO: first test if it is not already broadcastable
13541354
other = other.broadcast_with(self)
1355+
elif isinstance(other, np.ndarray):
1356+
pass
13551357
elif not np.isscalar(other):
13561358
raise TypeError("unsupported operand type(s) for %s: '%s' "
13571359
"and '%s'" % (opname, type(self), type(other)))

larray/tests/test_la.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,14 @@ def test_binary_ops(self):
12621262
# test adding two larrays with different axes order
12631263
self._assert_equal_raw(la + la.transpose(), raw * 2)
12641264

1265+
# mixed operations
1266+
la_raw = la + raw
1267+
self.assertEqual(la_raw.axes, la.axes)
1268+
self._assert_equal_raw(la_raw, raw + raw)
1269+
raw_la = raw + la
1270+
self._assert_equal_raw(raw_la, raw + raw)
1271+
self.assertEqual(raw_la.axes, la.axes)
1272+
12651273
def test_unary_ops(self):
12661274
raw = self.small_data
12671275
la = self.small

0 commit comments

Comments
 (0)