Browse files

BUG lara index bug; closes #40

  • Loading branch information...
1 parent 789d46f commit 5775a4043d6c988cd75f277810724c75d81ccd72 @kwgoodman committed Feb 11, 2014
Showing with 24 additions and 3 deletions.
  1. +2 −2 README.rst
  2. +1 −0 RELEASE.rst
  3. +12 −1 la/io.py
  4. +9 −0 la/tests/io_test.py
View
4 README.rst
@@ -120,9 +120,9 @@ After you have installed ``la``, run the suite of unit tests::
>>> import la
>>> la.test()
<snip>
- Ran 3005 tests in 12.225s
+ Ran 3006 tests in 12.225s
OK
- <nose.result.TextTestResult run=3005 errors=0 failures=0>
+ <nose.result.TextTestResult run=3006 errors=0 failures=0>
The ``la`` package contains C extensions that speed up common alignment
operations such as adding two unaligned larrys. If the C extensions don't
View
1 RELEASE.rst
@@ -41,6 +41,7 @@ la 0.7
**Bug fixes**
+- #40 lara indexing bug when index is a list
- #59 Proper int promotion in larry.cumsum() and larry.cumprod()
- #62 la.cov() overwrites NaNs in input array
- #65 lar.any() and lar.all() return wrong dtype with size=0 input
View
13 la/io.py
@@ -331,7 +331,18 @@ def __init__(self, filename, key):
def __getitem__(self, index):
f = h5py.File(self.filename, 'r')
self.x = f[self.key]['x']
- lar = self._larry_getitem(index)
+ if isinstance(index, list):
+ # at this point self.x is a h5py Dataset object, which doesn't
+ # have a take method, so do the indexing here instead of asking
+ # larry to do it.
+ label = list(self.label)
+ lab = [label[0][int(i)] for i in index]
+ if len(set(lab)) != len(lab):
+ raise IndexError("Duplicate labels along axis 0.")
+ label[0] = lab
+ lar = larry(self.x[index], label, validate=False)
+ else:
+ lar = self._larry_getitem(index)
f.close()
self.x = None
return lar
View
9 la/tests/io_test.py
@@ -210,6 +210,15 @@ def test_io_load_2(self):
la.io.delete(f, 'd')
f.close()
+ def test_io_lara_1(self):
+ "lara indexing bug #40"
+ io = IO(self.filename)
+ io['a'] = la.lrange(3)
+ b = io['a']
+ # b[[0, 2]] raised:
+ # AttributeError: 'Dataset' object has no attribute 'take'
+ b[[0,2]]
+
# nose tests ----------------------------------------------------------------
def datetime_test():

0 comments on commit 5775a40

Please sign in to comment.