Skip to content

Commit 356bd9f

Browse files
committed
Merge branch 'master' into noinherit
Conflicts: larray/core.py
2 parents 17e500a + d502c65 commit 356bd9f

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

larray/core.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,10 @@ def __getitem__(self, key, collapse_slices=False):
977977

978978
if (isinstance(key, np.ndarray) or isinstance(key, LArray)) and \
979979
np.issubdtype(key.dtype, bool):
980+
#TODO: return an LArray with Axis labels = combined keys
981+
# these combined keys should be objects which display as:
982+
# (axis1_label, axis2_label, ...) but should also store the axis
983+
# (names). Should it be the same object as the NDValueGroup?/NDKey?
980984
return data[np.asarray(key)]
981985

982986
translated_key = self.translated_key(self.full_key(key))

larray/tests/test_la.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ def test_transpose(self):
12331233
self.assertEqual(la.transpose().axes_names,
12341234
['lipro', 'sex', 'geo', 'age'])
12351235

1236-
def test_arithmetics(self):
1236+
def test_binary_ops(self):
12371237
raw = self.small_data
12381238
la = self.small
12391239

@@ -1262,13 +1262,20 @@ def test_arithmetics(self):
12621262
# test adding two larrays with different axes order
12631263
self._assert_equal_raw(la + la.transpose(), raw * 2)
12641264

1265-
# def test_boolean_indexing(self):
1266-
# raw = self.small_data
1267-
# la = self.small
1268-
#
1269-
# self._assert_equal_raw(la > 2, raw > 2)
1270-
# FIXME this fails: it should return a 1d array with "combined ticks"
1271-
# self._assert_equal_raw(la[la > 2], raw[raw > 2])
1265+
def test_unary_ops(self):
1266+
raw = self.small_data
1267+
la = self.small
1268+
1269+
# using numpy functions
1270+
self._assert_equal_raw(np.abs(la - 10), np.abs(raw - 10))
1271+
self._assert_equal_raw(np.negative(la), np.negative(raw))
1272+
self._assert_equal_raw(np.invert(la), np.invert(raw))
1273+
1274+
# using python builtin ops
1275+
self._assert_equal_raw(abs(la - 10), abs(raw - 10))
1276+
self._assert_equal_raw(-la, -raw)
1277+
self._assert_equal_raw(+la, +raw)
1278+
self._assert_equal_raw(~la, ~raw)
12721279

12731280
def test_mean(self):
12741281
la = self.small

0 commit comments

Comments
 (0)