本文整理汇总了Python中pypet.utils.explore.cartesian_product函数的典型用法代码示例。如果您正苦于以下问题:Python cartesian_product函数的具体用法?Python cartesian_product怎么用?Python cartesian_product使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cartesian_product函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
env = Environment(trajectory='Test_'+repr(time.time()).replace('.','_'),
filename=make_temp_dir(os.path.join(
'experiments',
'tests',
'briantests',
'HDF5',
'briantest.hdf5')),
file_title='test',
log_config=get_log_config(),
dynamic_imports=['pypet.brian.parameter.BrianParameter',
BrianMonitorResult],
multiproc=False)
traj = env.v_trajectory
#env._set_standard_storage()
#env._hdf5_queue_writer._hdf5storageservice = LazyStorageService()
traj = env.v_trajectory
#traj.set_storage_service(LazyStorageService())
add_params(traj)
#traj.mode='Parallel'
traj.f_explore(cartesian_product({traj.f_get('N').v_full_name:[50,60],
traj.f_get('tauw').v_full_name:[30*ms,40*ms]}))
self.traj = traj
self.env = env
self.traj = traj
示例2: main
def main():
# Let's be very verbose!
logging.basicConfig(level = logging.INFO)
# Let's do multiprocessing this time with a lock (which is default)
filename = os.path.join('hdf5', 'example_07.hdf5')
env = Environment(trajectory='Example_07_BRIAN',
filename=filename,
file_title='Example_07_Brian',
comment = 'Go Brian!',
dynamically_imported_classes=[BrianMonitorResult, BrianParameter],
multiproc=True,
wrap_mode='QUEUE',
ncores=2)
traj = env.trajectory
# 1st a) add the parameters
add_params(traj)
# 1st b) prepare, we want to explore the different network sizes and different tauw time scales
traj.f_explore(cartesian_product({traj.f_get('N').v_full_name:[50,60],
traj.f_get('tauw').v_full_name:[30*ms,40*ms]}))
# 2nd let's run our experiment
env.run(run_net)
# You can take a look at the results in the hdf5 file if you want!
# Finally disable logging and close all log-files
env.disable_logging()
示例3: explore
def explore(self):
matrices = []
for irun in range(3):
spsparse_lil = spsp.lil_matrix((111,111))
spsparse_lil[3,2] = 44.5*irun
matrices.append(spsparse_lil)
self.explore_dict=cartesian_product({'npstr':[np.array(['Uno', 'Dos', 'Tres']),
np.array(['Cinco', 'Seis', 'Siette']),
np.array(['Ocho', 'Nueve', 'Diez'])],
'val0':[1,2,3],
'spsparse_lil' : matrices}, (('npstr','val0'),'spsparse_lil'))
## Explore the parameter:
for key, vallist in self.explore_dict.items():
self.param[key]._explore(vallist)
示例4: setUp
def setUp(self):
logging.basicConfig(level = logging.DEBUG)
env = Environment(trajectory='Test_'+repr(time.time()).replace('.','_'),
filename=make_temp_file('experiments/tests/briantests/HDF5/briantest.hdf5'),
file_title='test',
log_folder=make_temp_file('experiments/tests/briantests/log'),
dynamically_imported_classes=['pypet.brian.parameter.BrianParameter',
BrianMonitorResult],
multiproc=True,
use_pool=True,
complib='blosc',
wrap_mode='QUEUE',
ncores=2)
traj = env.v_trajectory
#env._set_standard_storage()
#env._hdf5_queue_writer._hdf5storageservice = LazyStorageService()
traj = env.v_trajectory
#traj.set_storage_service(LazyStorageService())
add_params(traj)
#traj.mode='Parallel'
traj.f_explore(cartesian_product({traj.f_get('N').v_full_name:[50,60],
traj.f_get('tauw').v_full_name:[30*ms,40*ms]}))
self.traj = traj
self.env = env
self.traj = traj
示例5: main
def main():
# Let's be very verbose!
logging.basicConfig(level = logging.INFO)
# Let's do multiprocessing this time with a lock (which is default)
env = Environment(trajectory='Example_07_BRIAN',
filename='experiments/example_07/HDF5/example_07.hdf5',
file_title='Example_07_Euler_Integration',
log_folder='experiments/example_07/LOGS/',
comment = 'Go Brian!',
dynamically_imported_classes=[BrianMonitorResult, BrianParameter],
multiproc=True,
wrap_mode='QUEUE',
ncores=2)
traj = env.v_trajectory
# 1st a) add the parameters
add_params(traj)
# 1st b) prepare, we want to explore the different network sizes and different tauw time scales
traj.f_explore(cartesian_product({traj.f_get('N').v_full_name:[50,60],
traj.f_get('tauw').v_full_name:[30*ms,40*ms]}))
# 2nd let's run our experiment
env.f_run(run_net)
示例6: main
def main():
try:
# Create an environment that handles running
env = Environment(trajectory='Example1_Quick_And_Not_So_Dirty',filename='experiments/example_01/HDF5/',
file_title='Example1_Quick_And_Not_So_Dirty', log_folder='experiments/example_01/LOGS/',
comment='The first example!',
complib='blosc',
small_overview_tables=False,
git_repository='./', git_message='Im a message!',
sumatra_project='./', sumatra_reason='Testing!')
# Get the trajectory from the environment
traj = env.v_trajectory
# Add both parameters
traj.f_add_parameter('x', 1, comment='Im the first dimension!')
traj.f_add_parameter('y', 1, comment='Im the second dimension!')
# Explore the parameters with a cartesian product:
traj.f_explore(cartesian_product({'x':[1,2,3], 'y':[6,7,8]}))
# Run the simulation
env.f_run(multiply)
print("Python git test successful")
# traj.f_expand({'x':[3,3],'y':[42,43]})
#
# env.f_run(multiply)
except Exception as e:
print(repr(e))
sys.exit(1)
示例7: test_cartesian_product
def test_cartesian_product(self):
cartesian_dict=cartesian_product({'param1':[1,2,3], 'param2':[42.0, 52.5]},
('param1','param2'))
result_dict = {'param1':[1,1,2,2,3,3],'param2': [42.0,52.5,42.0,52.5,42.0,52.5]}
self.assertTrue(nested_equal(cartesian_dict,result_dict), '%s != %s' %
(str(cartesian_dict),str(result_dict)))
示例8: expand
def expand(self):
self.expanded ={'Normal.trial': [1],
'Numpy.double': [np.array([1.0,2.0,3.0,4.0]), np.array([-1.0,3.0,5.0,7.0])],
'csr_mat' :[spsp.csr_matrix((2222,22)), spsp.csr_matrix((2222,22))]}
self.expanded['csr_mat'][0][1,2]=44.0
self.expanded['csr_mat'][1][2,2]=33
self.traj.f_expand(cartesian_product(self.expanded))
示例9: test_cartesian_product_combined_params
def test_cartesian_product_combined_params(self):
cartesian_dict=cartesian_product( {'param1': [42.0, 52.5], 'param2':['a', 'b'],\
'param3' : [1,2,3]}, (('param3',),('param1', 'param2')))
result_dict={'param3':[1,1,2,2,3,3],'param1' : [42.0,52.5,42.0,52.5,42.0,52.5],
'param2':['a','b','a','b','a','b']}
self.assertTrue(nested_equal(cartesian_dict,result_dict), '%s != %s' %
(str(cartesian_dict),str(result_dict)))
示例10: explore
def explore(self):
self.explore_dict=cartesian_product({'npstr':[np.array(['Uno', 'Dos', 'Tres']),
np.array(['Cinco', 'Seis', 'Siette']),
np.array(['Ocho', 'Nueve', 'Diez'])],
'val0':[1,2,3]})
## Explore the parameter:
for key, vallist in self.explore_dict.items():
self.param[key]._explore(vallist)
示例11: explore
def explore(self, traj):
self.explored ={'Normal.trial': [0],
'Numpy.double': [np.array([1.0,2.0,3.0,4.0]), np.array([-1.0,3.0,5.0,7.0])],
'csr_mat' :[spsp.lil_matrix((2222,22)), spsp.lil_matrix((2222,22))]}
self.explored['csr_mat'][0][1,2]=44.0
self.explored['csr_mat'][1][2,2]=33
self.explored['csr_mat'][0] = self.explored['csr_mat'][0].tocsr()
self.explored['csr_mat'][1] = self.explored['csr_mat'][0].tocsr()
traj.f_explore(cartesian_product(self.explored))
示例12: explore
def explore(self):
self.explore_dict = cartesian_product({#'brian2_array_a': [np.array([1., 2.]) * mV],
# 'brian2_array_b': [2 * mV],
# Arrays need to be of the same size!
'brian2_array_c': [np.array([5., 8.]) * mV, np.array([7., 8.]) * mV],
})
## Explore the parameter:
for key, vallist in self.explore_dict.items():
self.param[key]._explore(vallist)
self.assertTrue(self.param[key].v_explored and self.param[key].f_has_range())
示例13: main
def main():
# Create an environment that handles running
filename = os.path.join('hdf5','example_18.hdf5')
env = Environment(trajectory='Multiplication',
filename=filename,
file_title='Example_18_Many_Runs',
overwrite_file=True,
comment='Contains many runs',
multiproc=True,
use_pool=True,
freeze_input=True,
ncores=2,
wrap_mode='QUEUE')
# The environment has created a trajectory container for us
traj = env.trajectory
# Add both parameters
traj.f_add_parameter('x', 1, comment='I am the first dimension!')
traj.f_add_parameter('y', 1, comment='I am the second dimension!')
# Explore the parameters with a cartesian product, yielding 2500 runs
traj.f_explore(cartesian_product({'x': range(50), 'y': range(50)}))
# Run the simulation
env.run(multiply)
# Disable logging
env.disable_logging()
# turn auto loading on, since results have not been loaded, yet
traj.v_auto_load = True
# Use the `v_idx` functionality
traj.v_idx = 2042
print('The result of run %d is: ' % traj.v_idx)
# Now we can rely on the wildcards
print(traj.res.crunset.crun.z)
traj.v_idx = -1
# Or we can use the shortcuts `rts_X` (run to set) and `r_X` to get particular results
print('The result of run %d is: ' % 2044)
print(traj.res.rts_2044.r_2044.z)
示例14: main
def main(inputargs):
args = docopt(__doc__, argv=inputargs)
wavpath = path.join(modulePath, "resources", "tone_in_noise")
stimuli = [path.join(wavpath, i) for i in glob.glob(path.join(wavpath, "*.wav"))]
outfile = path.realpath(path.expanduser(args["--out"]))
env = Environment(trajectory='tone-in-noise',
filename=outfile,
overwrite_file=True,
file_title="Tone in noise at different SNR",
comment="some comment",
large_overview_tables="False",
# freeze_input=True,
# use_pool=True,
multiproc=True,
ncores=3,
graceful_exit=True,
#wrap_mode=pypetconstants.WRAP_MODE_QUEUE,
)
traj = env.trajectory
traj.f_add_parameter('periphery', 'verhulst', comment="which periphery was used")
traj.f_add_parameter('brainstem', 'nelsoncarney04', comment="which brainstem model was used")
traj.f_add_parameter('weighting', "--no-cf-weighting ", comment="weighted CFs")
traj.f_add_parameter('wavfile', '', comment="Which wav file to run")
traj.f_add_parameter('level', 80, comment="stimulus level, spl")
traj.f_add_parameter('neuropathy', "none", comment="")
parameter_dict = {
"periphery" : ['verhulst', 'zilany'],
"brainstem" : ['nelsoncarney04', 'carney2015'],
"weighting" : [cf_weighting, ""],
"wavfile" : stimuli,
"level" : [80],
"neuropathy": ["none", "moderate", "severe", "ls-moderate", "ls-severe"]
}
traj.f_explore(cartesian_product(parameter_dict))
env.run(tone_in_noise)
return 0
示例15: explore
def explore(self, traj):
self.explored =cartesian_product({'Normal.trial': [0,1],
'Numpy.double': [np.array([1.0,2.0,3.0,4.0]), np.array([-1.0,3.0,5.0,7.0])]})
traj.f_explore(self.explored)