Skip to content

Commit

Permalink
tests with start values
Browse files Browse the repository at this point in the history
  • Loading branch information
papajohn committed Mar 8, 2016
1 parent a7ad94e commit 2658ada
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions datascience/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def minimize(f, start=None, **vargs):
arg_count = f.__code__.co_argcount
assert arg_count > 0, "Please pass starting values explicitly"
start = [0] * arg_count
if not hasattr(start, '__len__'):
start = [start]

@functools.wraps(f)
def wrapper(args):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ def test_table_apply():
def test_minimize():
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))
assert (2 == ds.minimize(lambda x: (x-2)**2, 1)) == True
assert [2, 1] == list(ds.minimize(lambda x, y: (x-2)**2 + (y-1)**2, [1, 1]))

0 comments on commit 2658ada

Please sign in to comment.