Skip to content

Commit

Permalink
fix value error and add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernaldis committed May 19, 2022
1 parent 91c8db4 commit cd46161
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 1 addition & 2 deletions datajoint/autopopulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ def handler(signum, frame):
if not nkeys:
return

if processes > 1:
processes = min(*(_ for _ in (processes, nkeys, mp.cpu_count()) if _))
processes = min(*(_ for _ in (processes, nkeys, mp.cpu_count()) if _))

error_list = []
populate_kwargs = dict(
Expand Down
9 changes: 9 additions & 0 deletions tests/test_autopopulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ def test_multi_processing(self):
== len(self.subject) * self.experiment.fake_experiments_per_subject
)

def test_max_multi_processing(self):
assert self.subject, "root tables are empty"
assert not self.experiment, "table already filled?"
self.experiment.populate(processes=None)
assert (
len(self.experiment)
== len(self.subject) * self.experiment.fake_experiments_per_subject
)

@raises(DataJointError)
def test_allow_insert(self):
assert_true(self.subject, "root tables are empty")
Expand Down

0 comments on commit cd46161

Please sign in to comment.