Skip to content

Commit

Permalink
BUG -la.larry([True, False]) returns wrong answer.
Browse files Browse the repository at this point in the history
Closes #51.
  • Loading branch information
kwgoodman committed Mar 8, 2012
1 parent 225e1db commit f3c012d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -122,9 +122,9 @@ After you have installed ``la``, run the suite of unit tests::
>>> import la >>> import la
>>> la.test() >>> la.test()
<snip> <snip>
Ran 3062 tests in 1.408s Ran 3063 tests in 1.408s
OK 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 The ``la`` package contains C extensions that speed up common alignment
operations such as adding two unaligned larrys. If the C extensions don't operations such as adding two unaligned larrys. If the C extensions don't
Expand Down
1 change: 1 addition & 0 deletions RELEASE.rst
Expand Up @@ -44,6 +44,7 @@ la 0.6
- #39 move_func(myfunc) did not pass kwargs to myfunc when method='loop' - #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 - #49 setup.py does not install module to load yahoo finance data
- #50 la.larry([], dtype=np.int).sum(0), and similar reductions, choke - #50 la.larry([], dtype=np.int).sum(0), and similar reductions, choke
- #51 -la.larry([True, False]) returns wrong answer


Older versions Older versions
============== ==============
Expand Down
10 changes: 5 additions & 5 deletions la/deflarry.py
Expand Up @@ -460,13 +460,13 @@ def clip(self, lo, hi):
return y return y


def __neg__(self): def __neg__(self):
"Return a copy with each element multiplied by minus 1." "Return a copy with each element switched with its negative."
y = self.copy() label = self.copylabel()
y.x *= -1 x = self.x.__neg__()
return y return larry(x, label, validate=False)


def __pos__(self): def __pos__(self):
"Return a copy with each element multiplied by 1." "Return a copy."
return self.copy() return self.copy()


def abs(self): def abs(self):
Expand Down
11 changes: 9 additions & 2 deletions la/tests/deflarry_test.py
Expand Up @@ -432,8 +432,8 @@ def test_nan_replace_3(self):
self.assert_((abs(t - p) < self.tol).all(), msg) self.assert_((abs(t - p) < self.tol).all(), msg)
self.assert_(noreference(p, t), 'Reference found') self.assert_(noreference(p, t), 'Reference found')


def test___neg__(self): def test___neg__1(self):
"larry.__neg__" "larry.__neg__1"
t = np.array([[-1.0,-1.0], t = np.array([[-1.0,-1.0],
[-1.0,-1.0], [-1.0,-1.0],
[-1.0,-1.0]]) [-1.0,-1.0]])
Expand All @@ -446,6 +446,13 @@ def test___neg__(self):
self.assert_(label == p.label, printfail(label, p.label, 'label')) self.assert_(label == p.label, printfail(label, p.label, 'label'))
self.assert_(noreference(p, self.l), 'Reference found') 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): def test___pos__(self):
"larry.__pos__" "larry.__pos__"
t = np.array([[ 1.0, 1.0], t = np.array([[ 1.0, 1.0],
Expand Down

0 comments on commit f3c012d

Please sign in to comment.