@@ -257,9 +257,10 @@ def test_prepare_emodel_dir():
257257
258258
259259@attr ('unit' )
260- def test_prepare_emodel_dirs ():
261- """prepare_combos.prepare_emodel_dirs: test prepare_emodel_dirs
262- based on test example 'simple1'.
260+ def test_prepare_emodel_dirs_single_process ():
261+ """prepare_combos.prepare_emodel_dirs_single_process:
262+ test prepare_emodel_dirs based on test example 'simple1
263+ using a single process'.
263264 """
264265 # create test directory, where output of this test will be created
265266 test_dir = os .path .join (TMP_DIR , 'test_prepare_emodel_dirs' )
@@ -308,3 +309,58 @@ def test_prepare_emodel_dirs():
308309 nt .assert_dict_equal (ret , expected_ret )
309310 nt .assert_true (os .path .isdir (emodels_dir ))
310311 nt .assert_true (os .path .isdir (emodels_hoc_dir ))
312+
313+
314+ @attr ('unit' )
315+ def test_prepare_emodel_dirs_multi_process ():
316+ """prepare_combos.prepare_emodel_dirs_multi_process:
317+ test prepare_emodel_dirs based on test example 'simple1'
318+ using multiprocessing.
319+ """
320+ # create test directory, where output of this test will be created
321+ test_dir = os .path .join (TMP_DIR , 'test_prepare_emodel_dirs' )
322+ tools .makedirs (test_dir )
323+
324+ # input parameters
325+ final_dict = {'emodel1' : {'main_path' : '.' ,
326+ 'seed' : 2 ,
327+ 'rank' : 0 ,
328+ 'notes' : '' ,
329+ 'branch' : 'emodel1' ,
330+ 'params' : {'cm' : 1.0 },
331+ 'fitness' : {'Step1.SpikeCount' : 20.0 },
332+ 'score' : 104.72906197480131 ,
333+ 'morph_path' : 'morphologies/morph1.asc' },
334+ 'emodel2' : {'main_path' : '.' ,
335+ 'seed' : 2 ,
336+ 'rank' : 0 ,
337+ 'notes' : '' ,
338+ 'branch' : 'emodel2' ,
339+ 'params' : {'cm' : 0.5 },
340+ 'fitness' : {'Step1.SpikeCount' : 20.0 },
341+ 'score' : 104.72906197480131 ,
342+ 'morph_path' : 'morphologies/morph2.asc' }}
343+ emodel_etype_map = {'emodel1' : {'mm_recipe' : 'emodel1' ,
344+ 'etype' : 'etype1' ,
345+ 'layer' : ['1' , 'str1' ]},
346+ 'emodel2' : {'mm_recipe' : 'emodel2' ,
347+ 'etype' : 'etype2' ,
348+ 'layer' : ['1' , '2' ]}}
349+ emodels_dir = os .path .join (test_dir , 'tmp/emodels/' )
350+ opt_dir = os .path .join (TEST_DATA_DIR , 'data/emodels_dir/subdir/' )
351+ emodels_hoc_dir = os .path .join (test_dir , './output/emodels_hoc/' )
352+ emodels_in_repo = False
353+ continu = False
354+
355+ # run function
356+ with tools .cd (TEST_DATA_DIR ):
357+ ret = prepare_emodel_dirs .prepare_emodel_dirs (
358+ final_dict , emodel_etype_map , emodels_dir , opt_dir ,
359+ emodels_hoc_dir , emodels_in_repo , continu , n_processes = None )
360+
361+ # verify output
362+ expected_ret = {emodel : os .path .join (
363+ emodels_dir , emodel ) for emodel in final_dict }
364+ nt .assert_dict_equal (ret , expected_ret )
365+ nt .assert_true (os .path .isdir (emodels_dir ))
366+ nt .assert_true (os .path .isdir (emodels_hoc_dir ))
0 commit comments