Permalink
Browse files

BUG la.larry([], dtype=np.int).sum(0) chokes.

Closes #50.
  • Loading branch information...
1 parent 1e162da commit 225e1dbe6d62090f0b6360d9c198a08921502f08 @kwgoodman committed Mar 8, 2012
Showing with 13 additions and 9 deletions.
  1. +2 −2 README.rst
  2. +1 −0 RELEASE.rst
  3. +4 −4 la/deflarry.py
  4. +6 −3 la/tests/empty_larry_test.py
View
@@ -122,9 +122,9 @@ After you have installed ``la``, run the suite of unit tests::
>>> import la
>>> la.test()
<snip>
- Ran 3061 tests in 1.408s
+ Ran 3062 tests in 1.408s
OK
- <nose.result.TextTestResult run=3061 errors=0 failures=0>
+ <nose.result.TextTestResult run=3062 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
@@ -43,6 +43,7 @@ la 0.6
- #38 Indexing single element of larry with object dtype
- #39 move_func(myfunc) did not pass kwargs to myfunc when method='loop'
- #49 setup.py does not install module to load yahoo finance data
+- #50 la.larry([], dtype=np.int).sum(0), and similar reductions, choke
Older versions
==============
View
@@ -1356,12 +1356,12 @@ def __reduce(self, op, default=np.nan, **kwargs):
if axis == None:
return default
shape = list(self.shape)
- shape.pop(axis)
- x = np.ones(shape, dtype=self.dtype)
- x.fill(default)
- if (x.ndim == 0) and (x.size == 1):
+ shape.pop(axis)
+ if len(shape) == 0:
return default
else:
+ x = np.empty(shape, dtype=self.dtype)
+ x.fill(default)
label = self.copylabel()
label.pop(axis)
return larry(x, label, validate=False)
@@ -1,7 +1,7 @@
"Test larry methods for proper handling of empty larrys"
import numpy as np
-from numpy.testing import assert_, assert_equal
+from numpy.testing import assert_
from la import larry, nan
from la.util.testing import assert_larry_equal as ale
@@ -200,5 +200,8 @@ def test_reduce_shape():
ymethod = getattr(y, method['la'])
lar = ymethod(axis=axis, **method['kw'])
yield ale, lar, arr, msg % (method['la'], shape, axis)
-
-
+def test_50():
+ "Regression #50"
+ actual = larry([], dtype=np.int).sum(0)
+ desired = np.nan
+ ale(actual, desired, "Regression #50")

0 comments on commit 225e1db

Please sign in to comment.