Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ceyzeriat committed May 8, 2018
1 parent d990ff4 commit 3208ee5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
19 changes: 16 additions & 3 deletions binge/binge.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def __call__(self, *args, **kwargs):
if self._n is None:
self.n = 1
# check all input arguments
for p, param in [(0, enumerate(params[0])),\
for p, param in [(0, enumerate(params[0])),
(1, params[1].items())]:
for idx, item in param:
if self._inspect_it(item):
Expand All @@ -216,22 +216,35 @@ def __call__(self, *args, **kwargs):
.format(self.n, self.cores))
# go through args and kwargs input arguments and make lists of it if
# need be
for p, param in enumerate(params):
for idx, item in enumerate(param):
#dochanges = []
for p, param in [(0, enumerate(params[0])),
(1, params[1].items())]:
for idx, item in param:
if self._inspect_it(item):
# this input is inspect-compatible
if len(item) != self.n:
# but its length is not the one we want to iterate on
# wrap it into a fake 1-item list
#dochanges.append((p, idx))
params[p][idx] = [item]
else:
# item not inspect-compatible
# wrap it into a fake 1-item list
if isinstance(item, types.GeneratorType):
# can't pickle generators, so gotta force it into
# tuple
#dochanges.append((p, idx, None))
item = tuple(item)
#else:
# dochanges.append((p, idx))
params[p][idx] = [item]
#for changes in dochanges:
# dotuple = False
# if len(changes) == 3:
# dotuple = True
# p, idx = changes[:2]
# params[p][idx] = [tuple(params[p][idx])] if dotuple\
# else [params[p][idx]]
# make the single parameter list for the pool
allparams = []
for j in range(self.n):
Expand Down
6 changes: 3 additions & 3 deletions binge/test/test_binge.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import numpy as np
import time
import pandas
import pandas as pd


from ..binge import B
Expand Down Expand Up @@ -72,14 +72,14 @@ def test_dum_create4():
l = [1,2,3]
b = 2
res = B(_dummy2)(l, b=b)
assert l == [i+b for i in res]
assert [i+b for i in l] == res


def test_dum_create5():
l = [1,2,3]
b = 2
res = B(_dummy2)(a=l, b=b)
assert l == [i+b for i in res]
assert [i+b for i in l] == res


def test_cores():
Expand Down

0 comments on commit 3208ee5

Please sign in to comment.