Skip to content
Browse files

BUG -la.larry([True, False]) returns wrong answer.

Closes #51.
  • Loading branch information...
1 parent 225e1db commit f3c012dcd1ced50df34515bd66b75492b4b21170 @kwgoodman committed Mar 8, 2012
Showing with 17 additions and 9 deletions.
  1. +2 −2 README.rst
  2. +1 −0 RELEASE.rst
  3. +5 −5 la/deflarry.py
  4. +9 −2 la/tests/deflarry_test.py
View
4 README.rst
@@ -122,9 +122,9 @@ After you have installed ``la``, run the suite of unit tests::
>>> import la
>>> la.test()
<snip>
- Ran 3062 tests in 1.408s
+ Ran 3063 tests in 1.408s
OK
- <nose.result.TextTestResult run=3062 errors=0 failures=0>
+ <nose.result.TextTestResult run=3063 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
@@ -44,6 +44,7 @@ la 0.6
- #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
+- #51 -la.larry([True, False]) returns wrong answer
Older versions
==============
View
10 la/deflarry.py
@@ -460,13 +460,13 @@ def clip(self, lo, hi):
return y
def __neg__(self):
- "Return a copy with each element multiplied by minus 1."
- y = self.copy()
- y.x *= -1
- return y
+ "Return a copy with each element switched with its negative."
+ label = self.copylabel()
+ x = self.x.__neg__()
+ return larry(x, label, validate=False)
def __pos__(self):
- "Return a copy with each element multiplied by 1."
+ "Return a copy."
return self.copy()
def abs(self):
View
11 la/tests/deflarry_test.py
@@ -432,8 +432,8 @@ def test_nan_replace_3(self):
self.assert_((abs(t - p) < self.tol).all(), msg)
self.assert_(noreference(p, t), 'Reference found')
- def test___neg__(self):
- "larry.__neg__"
+ def test___neg__1(self):
+ "larry.__neg__1"
t = np.array([[-1.0,-1.0],
[-1.0,-1.0],
[-1.0,-1.0]])
@@ -446,6 +446,13 @@ def test___neg__(self):
self.assert_(label == p.label, printfail(label, p.label, 'label'))
self.assert_(noreference(p, self.l), 'Reference found')
+ def test___neg__2(self):
+ "larry.__neg__2"
+ original = larry([True, False])
+ actual = -original
+ desired = larry([False, True])
+ ale(actual, desired, "__neg__ of bool", original=original)
+
def test___pos__(self):
"larry.__pos__"
t = np.array([[ 1.0, 1.0],

0 comments on commit f3c012d

Please sign in to comment.
Something went wrong with that request. Please try again.