Skip to content

Commit

Permalink
Fixed Bug that Brian2 Parameters cannot be merged;
Browse files Browse the repository at this point in the history
Added new regression test for the bug;
  • Loading branch information
Robert Meyer committed Nov 28, 2017
1 parent 8eff0fc commit dee912c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
pypet 0.4.2

* BUG FIX: Brian2Parameters can now be merged [Issue #50]

pypet 0.4.1

* BUG FIX: Fixed slow `f_get_from_all_runs` with run groups
Expand Down
2 changes: 1 addition & 1 deletion pypet/brian2/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def _load(self, load_dict):
value_col = explore_table['value']
explore_list = [value * unit for value in value_col]

self._explored_range = tuple(explore_list)
self._explored_range = explore_list
self._explored = True

except KeyError:
Expand Down
35 changes: 35 additions & 0 deletions pypet/tests/unittests/brian2tests/brian2_parameter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,41 @@ def test_exploration(self):
val = self.data[key]
self.assertTrue(np.all(repr(param.f_get())==repr(val))),'%s != %s'%( str(param.f_get()),str(val))

def test_expanding(self):
for key, vallist in self.explore_dict.items():
param = self.param[key]

copy_list = vallist.copy()
old_len = len(vallist)

param.f_unlock()
param._expand(copy_list)

new_len = len(param.f_get_range())

self.assertEqual(new_len, 2 * old_len)

def test_loading_and_expanding(self):
# Regression test for issue #50
# https://github.com/SmokinCaterpillar/pypet/issues/50
for key, vallist in self.explore_dict.items():
param = self.param[key]

copy_list = vallist.copy()
old_len = len(vallist)


store_dict = param._store()
param.f_unlock()
param._load(store_dict)

param.f_unlock()
param._expand(copy_list)

new_len = len(param.f_get_range())

self.assertEqual(new_len, 2 * old_len)

def test_meta_settings(self):
for key, param in self.param.items():
self.assertEqual(param.v_full_name, self.location+'.'+key)
Expand Down

0 comments on commit dee912c

Please sign in to comment.