Skip to content

Commit

Permalink
fix test and output
Browse files Browse the repository at this point in the history
  • Loading branch information
papajohn committed Mar 8, 2016
1 parent b143a40 commit a7ad94e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion datascience/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,9 @@ def wrapper(args):
return f(*args)

result = optimize.minimize(wrapper, start, **vargs)
return np.round(result.x, 7)
rounded = np.round(result.x, 7)
if len(start) == 1:
return rounded.item(0)
else:
return rounded

2 changes: 1 addition & 1 deletion tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ def test_table_apply():
assert all(newtab['b'] == tab['b'] + 1)

def test_minimize():
assert 2 == ds.minimize(lambda x: (x-2)**2)
assert (2 == ds.minimize(lambda x: (x-2)**2)) == True
assert [2, 1] == list(ds.minimize(lambda x, y: (x-2)**2 + (y-1)**2))

0 comments on commit a7ad94e

Please sign in to comment.