Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BUG Indexing single element with dtype object.

Closes #38.
  • Loading branch information...
commit fce96d51dafed38cfc91fb67ba26f78a11494191 1 parent 8de67d5
@kwgoodman authored
View
4 README.rst
@@ -118,9 +118,9 @@ After you have installed ``la``, run the suite of unit tests::
>>> import la
>>> la.test()
<snip>
- Ran 3019 tests in 1.175s
+ Ran 3020 tests in 1.175s
OK
- <nose.result.TextTestResult run=3019 errors=0 failures=0>
+ <nose.result.TextTestResult run=3020 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
@@ -29,6 +29,7 @@ la 0.6
- #22 Morphing an empty larry chokes lar.morph()
- #31 la.panel() gives wrong output
- #35 larry([1, 2]) == 'a' did not return a bool like numpy does
+- #38 Indexing single element of larry with object dtype
- #39 move_func(myfunc) did not pass kwargs to myfunc when method='loop'
Older versions
View
2  la/deflarry.py
@@ -1717,7 +1717,7 @@ def __getitem__(self, index):
msg = 'Only slice, integer, and seq (list, tuple, 1d array)'
msg = msg + ' indexing supported'
raise IndexError, msg
- if np.isscalar(x):
+ if not isinstance(x, np.ndarray):
return x
return larry(x, label)
View
13 la/tests/deflarry_test.py
@@ -24,8 +24,8 @@ def setUp(self):
self.list = [[1,2],[3,4]]
self.tuple = ((1,2),(3,4))
self.matrix = np.matrix([[1,2],[3,4]])
- self.array = np.array([[1,2],[3,4]])
- self.label = [[0,1],[0,1]]
+ self.array = np.array([[1,2],[3,4]])
+ self.label = [[0,1],[0,1]]
def test_init_list(self):
"larry.__init__list"
@@ -2275,6 +2275,13 @@ def test_getitem_21(self):
desired = larry([ 3.0, 5.0], [[1, 2]])
actual = self.l[np.array([1, 2]), 0]
ale(actual, desired, original=self.l)
+
+ def test_getitem_22(self):
+ "larry.__getitem___22"
+ lar = larry([None, None])
+ desired = None
+ actual = lar[0]
+ self.assert_(actual==desired, "Indexing object dtype failed.")
def test_setitem_1(self):
"larry.__setitem___1"
@@ -2288,7 +2295,7 @@ def test_setitem_1(self):
p[np.isnan(p.x)] = self.nancode
self.assert_((abs(t - p.x) < self.tol).all(), msg)
label = [[0, 1, 2], [0, 1]]
- self.assert_(label == p.label, printfail(label, p.label, 'label'))
+ self.assert_(label == p.label, printfail(label, p.label, 'label'))
def test_setitem_2(self):
"larry.__setitem___2"
Please sign in to comment.
Something went wrong with that request. Please try again.