Skip to content

Commit 2658ada

Browse files
committed
tests with start values
1 parent a7ad94e commit 2658ada

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

datascience/util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ def minimize(f, start=None, **vargs):
130130
arg_count = f.__code__.co_argcount
131131
assert arg_count > 0, "Please pass starting values explicitly"
132132
start = [0] * arg_count
133+
if not hasattr(start, '__len__'):
134+
start = [start]
133135

134136
@functools.wraps(f)
135137
def wrapper(args):

tests/test_util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,5 @@ def test_table_apply():
4444
def test_minimize():
4545
assert (2 == ds.minimize(lambda x: (x-2)**2)) == True
4646
assert [2, 1] == list(ds.minimize(lambda x, y: (x-2)**2 + (y-1)**2))
47+
assert (2 == ds.minimize(lambda x: (x-2)**2, 1)) == True
48+
assert [2, 1] == list(ds.minimize(lambda x, y: (x-2)**2 + (y-1)**2, [1, 1]))

0 commit comments

Comments
 (0)