本文整理汇总了Python中pypet.utils.comparisons.nested_equal函数的典型用法代码示例。如果您正苦于以下问题:Python nested_equal函数的具体用法?Python nested_equal怎么用?Python nested_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了nested_equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: check_spike_monitor
def check_spike_monitor(self, res, monitor):
self.assertTrue(comp.nested_equal(monitor.num_spikes, res.num_spikes))
self.assertTrue(comp.nested_equal(str(monitor.source), res.source))
self.assertEqual(monitor.name,res.name)
self.assertTrue(comp.nested_equal(monitor.t[:], res.t))
self.assertTrue(comp.nested_equal(monitor.i[:], res.i))
for idx, varname in enumerate(monitor.record_variables):
self.assertTrue(comp.nested_equal(getattr(monitor, varname)[:], res.f_get(varname)))
开发者ID:femtotrader,项目名称:pypet,代码行数:8,代码来源:brian2_monitor_test.py
示例2: test_get_annotations
def test_get_annotations(self):
key_list = sorted(self.annotations.keys())
for node in self.traj.f_iter_nodes(recursive=True):
for name in self.annotations:
self.assertTrue(comp.nested_equal(self.annotations[name],
node.f_get_annotations(name)))
val_list = node.f_get_annotations(*key_list)
for idx, val in enumerate(val_list):
self.assertTrue(comp.nested_equal(self.annotations[key_list[idx]], val))
开发者ID:ilonajulczuk,项目名称:pypet,代码行数:11,代码来源:annotations_test.py
示例3: check_multi_state_monitor
def check_multi_state_monitor(self, res, monitor):
self.assertEqual(monitor.vars, res.vars)
if len(monitor.times)>0:
self.assertEqual('second', res.times_unit)
self.assertTrue(comp.nested_equal(monitor.times, res.times))
for idx, varname in enumerate(monitor.vars):
mon = monitor.monitors[varname]
self.assertTrue(comp.nested_equal(mon.record, res.record))
self.assertTrue(comp.nested_equal(mon.when, res.when))
self.assertEqual(mon.timestep, res.timestep)
self.assertTrue(comp.nested_equal(str(mon.P), res.source))
if hasattr(res, varname+'_mean'):
self.assertTrue(comp.nested_equal(mon.mean, res.f_get(varname+'_mean')))
self.assertTrue(comp.nested_equal(mon.var, res.f_get(varname+'_var')))
if len(monitor.times)>0:
self.assertTrue(comp.nested_equal(mon.values, res.f_get(varname+'_values')))
self.assertTrue(comp.nested_equal(repr(mon.unit), res.f_get(varname+'_unit')))
开发者ID:lsolanka,项目名称:pypet,代码行数:26,代码来源:brian_monitor_test.py
示例4: test_get_data
def test_get_data(self):
for res in self.results.values():
if len(res._data)==1:
val1=res.data
val2=res.f_get()
self.assertTrue(comp.nested_equal(val1,val2), '%s != %s' % (str(val1),str(val2)))
val3=res['data']
self.assertTrue(comp.nested_equal(val3,val2), '%s != %s' % (str(val3),str(val2)))
else:
with self.assertRaises(AttributeError):
res.data
with self.assertRaises(AttributeError):
res['data']
with self.assertRaises(ValueError):
res.f_get()
开发者ID:SmokinCaterpillar,项目名称:pypet,代码行数:15,代码来源:parameter_test.py
示例5: check_state_monitor
def check_state_monitor(self, res, monitor):
self.assertEqual(monitor.record_variables, res.record_variables)
self.assertEqual(monitor.name,res.name)
times=np.array(monitor.t)
if len(times)>0:
self.assertTrue(comp.nested_equal(times, res.t))
for idx, varname in enumerate(monitor.record_variables):
self.assertTrue(comp.nested_equal(monitor.record, res.record))
self.assertTrue(comp.nested_equal(monitor.when, res.when))
self.assertTrue(comp.nested_equal(str(monitor.source), res.source))
self.assertTrue(comp.nested_equal(getattr(monitor, varname), res.f_get(varname)))
开发者ID:femtotrader,项目名称:pypet,代码行数:15,代码来源:brian2_monitor_test.py
示例6: 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)))
开发者ID:ilonajulczuk,项目名称:pypet,代码行数:8,代码来源:utilstest.py
示例7: test_annotations_insert
def test_annotations_insert(self):
for node in self.traj.f_iter_nodes(recursive=True):
for name in self.annotations:
anno = self.annotations[name]
node_anno = node.v_annotations[name]
self.assertTrue(comp.nested_equal(anno, node_anno),
'%s != %s' % (str(anno), str(node_anno)))
开发者ID:ilonajulczuk,项目名称:pypet,代码行数:8,代码来源:annotations_test.py
示例8: 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)))
开发者ID:ilonajulczuk,项目名称:pypet,代码行数:9,代码来源:utilstest.py
示例9: compare_trajectories
def compare_trajectories(self,traj1,traj2):
trajlength = len(traj1)
if 'results.runs' in traj1:
rungroups = traj1.results.runs.f_children()
else:
rungroups = 1
self.assertEqual(trajlength, rungroups, 'len of traj1 is %d, rungroups %d' % (trajlength, rungroups))
old_items = to_dict_wo_config(traj1)
new_items = to_dict_wo_config(traj2)
self.assertEqual(len(traj1),len(traj2), 'Length unequal %d != %d.' % (len(traj1), len(traj2)))
self.assertEqual(len(old_items),len(new_items))
for key,item in new_items.items():
old_item = old_items[key]
if isinstance(item, BaseParameter):
self.assertTrue(parameters_equal(item,old_item),
'For key %s: %s not equal to %s' %(key,str(old_item),str(item)))
elif isinstance(item,BaseResult):
self.assertTrue(results_equal(item, old_item),
'For key %s: %s not equal to %s' %(key,str(old_item),str(item)))
else:
raise RuntimeError('You shall not pass')
self.assertTrue(nested_equal(item.v_annotations,old_item.v_annotations),'%s != %s' %
(item.v_annotations.f_ann_to_str(),old_item.v_annotations.f_ann_to_str()))
# Check the annotations
for node in traj1.f_iter_nodes(recursive=True):
if (not 'run' in node.v_full_name) or 'run_00000000' in node.v_full_name:
if node.v_comment != '' and node.v_full_name in traj2:
second_comment = traj2.f_get(node.v_full_name).v_comment
self.assertEqual(node.v_comment, second_comment, '%s != %s, for %s' %
(node.v_comment, second_comment, node.v_full_name))
if not node.v_annotations.f_is_empty():
second_anns = traj2.f_get(node.v_full_name).v_annotations
self.assertTrue(nested_equal(node.v_annotations, second_anns))
开发者ID:ilonajulczuk,项目名称:pypet,代码行数:44,代码来源:test_helpers.py
示例10: check_state_spike_monitor
def check_state_spike_monitor(self, res, monitor):
self.assertTrue(comp.nested_equal(monitor.delay, res.delay))
self.assertTrue(comp.nested_equal(monitor.nspikes, res.nspikes))
self.assertTrue(comp.nested_equal(str(monitor.source), res.source))
self.assertTrue(comp.nested_equal(monitor._varnames, res.varnames))
self.assertEqual('second', res.spiketimes_unit)
if res.v_storage_mode == BrianMonitorResult.TABLE_MODE:
spike_frame = res.spikes
spiked_list=sorted(list(set(spike_frame['neuron'].to_dict().values())))
self.assertEqual(spiked_list, res.neurons_with_spikes)
for idx,val_tuple in enumerate(monitor.spikes):
neuron = val_tuple[0]
time = val_tuple[1]
vals = val_tuple[2:]
self.assertEqual(neuron, spike_frame['neuron'][idx])
self.assertEqual(float(time), spike_frame['spiketimes'][idx])
for idx_var, varname in enumerate(res.varnames):
val = vals[idx_var]
self.assertEqual(float(val),spike_frame[varname][idx])
elif res.v_storage_mode == BrianMonitorResult.ARRAY_MODE:
self.assertTrue('%0' in res.format_string and 'd' in res.format_string)
spiked_set=set()
for item_name in res:
if item_name.startswith('spiketimes') and not item_name.endswith('unit'):
neuron_id = int(item_name.split('_')[-1])
spiked_set.add(neuron_id)
times = monitor.times(neuron_id)
self.assertTrue(comp.nested_equal(times,res[item_name]))
for varname in res.varnames:
if item_name.startswith(varname) and not item_name.endswith('unit'):
neuron_id =int(item_name.split('_')[-1])
values = monitor.values(varname,neuron_id)
# Remove units:
self.assertTrue(comp.nested_equal(values,res[item_name]))
spiked_list = sorted(list(spiked_set))
self.assertEqual(spiked_list, res.neurons_with_spikes)
else:
raise RuntimeError('You shall not pass!')
# Check Units
for idx,varname in enumerate(monitor._varnames):
unit = repr(get_unit_fast(monitor.spikes[0][idx+2]))
self.assertTrue(unit,res[varname+'_unit'])
开发者ID:lsolanka,项目名称:pypet,代码行数:60,代码来源:brian_monitor_test.py
示例11: check_population_rate_monitor
def check_population_rate_monitor(self, res, monitor):
self.assertEqual(str(monitor.source),res.source)
self.assertTrue(comp.nested_equal(monitor._bin,res.bin))
self.assertTrue(comp.nested_equal('second',res.times_unit))
self.assertTrue(comp.nested_equal('Hz',res.rate_unit))
self.assertTrue(comp.nested_equal(monitor.rate,res.rate))
self.assertTrue(comp.nested_equal(monitor.times,res.times))
self.assertTrue(comp.nested_equal(monitor.delay,res.delay))
开发者ID:lsolanka,项目名称:pypet,代码行数:8,代码来源:brian_monitor_test.py
示例12: check_state_monitor
def check_state_monitor(self, res, monitor):
self.assertEqual('second', res.times_unit)
self.assertEqual(monitor.varname, res.varname)
self.assertEqual(repr(monitor.unit), res.unit)
self.assertTrue(comp.nested_equal(monitor.record, res.record))
self.assertTrue(comp.nested_equal(monitor.when, res.when))
self.assertEqual(monitor.timestep, res.timestep)
self.assertTrue(comp.nested_equal(str(monitor.P), res.source))
if hasattr(res, 'mean'):
self.assertTrue(comp.nested_equal(monitor.mean, res.mean))
self.assertTrue(comp.nested_equal(monitor.var, res.var))
if len(monitor.times) > 0:
self.assertTrue(comp.nested_equal(monitor.times, res.times))
self.assertTrue(comp.nested_equal(monitor.values, res.values))
开发者ID:lsolanka,项目名称:pypet,代码行数:19,代码来源:brian_monitor_test.py
示例13: test_natural_naming
def test_natural_naming(self):
for res_name,res in self.results.items():
for key, val1 in res.f_to_dict().items():
val2 = getattr(res, key)
self.assertTrue(comp.nested_equal(val1,val2))
开发者ID:SmokinCaterpillar,项目名称:pypet,代码行数:5,代码来源:parameter_test.py
示例14: check_population_rate_monitor
def check_population_rate_monitor(self, res, monitor):
self.assertEqual(str(monitor.source),res.source)
self.assertEqual(monitor.name,res.name)
#self.assertTrue(comp.nested_equal(monitor._bin,res.bin))
self.assertTrue(comp.nested_equal(monitor.rate[:],res.rate))
self.assertTrue(comp.nested_equal(monitor.t[:],res.t))
开发者ID:femtotrader,项目名称:pypet,代码行数:6,代码来源:brian2_monitor_test.py
示例15: test_get_item
def test_get_item(self):
for paramname in self.explore_dict:
param = self.param[paramname]
val1=param.f_get_range()[1]
val2=param[1]
self.assertTrue(comp.nested_equal(val1,val2), '%s != %s' % (str(val1),str(val2)))
开发者ID:SmokinCaterpillar,项目名称:pypet,代码行数:6,代码来源:parameter_test.py
示例16: test_get_data_dictionaries_directly
def test_get_data_dictionaries_directly(self):
############## Cofig ###################
config_dict_from_subtree = self.traj.config.f_to_dict()
self.assertTrue(len(config_dict_from_subtree)>0)
config_dict_directly = self.traj.f_get_config(copy=True)
self.assertTrue(comp.nested_equal(config_dict_directly,config_dict_from_subtree),
'%s!=%s' % (str(config_dict_directly),str(config_dict_directly)))
config_dict_directly = self.traj.f_get_config(copy=False)
self.assertTrue(comp.nested_equal(config_dict_directly,config_dict_from_subtree),
'%s!=%s' % (str(config_dict_directly),str(config_dict_directly)))
config_dict_from_subtree = self.traj.config.f_to_dict(fast_access=True)
with self.assertRaises(ValueError):
config_dict_directly = self.traj.f_get_config(copy=False, fast_access=True)
config_dict_directly = self.traj.f_get_config(copy=True, fast_access=True)
self.assertTrue(comp.nested_equal(config_dict_directly,config_dict_from_subtree),
'%s!=%s' % (str(config_dict_directly),str(config_dict_directly)))
############## Parameters #############################
parameters_dict_from_subtree = self.traj.parameters.f_to_dict()
self.assertTrue(len(parameters_dict_from_subtree)>0)
parameters_dict_directly = self.traj.f_get_parameters(copy=True)
self.assertTrue(comp.nested_equal(parameters_dict_directly,parameters_dict_from_subtree),
'%s!=%s' % (str(parameters_dict_directly),str(parameters_dict_directly)))
parameters_dict_directly = self.traj.f_get_parameters(copy=False)
self.assertTrue(comp.nested_equal(parameters_dict_directly,parameters_dict_from_subtree),
'%s!=%s' % (str(parameters_dict_directly),str(parameters_dict_directly)))
### Empty Parameters won't support fast access so we need to set
self.traj.paul.peter.f_set(42)
parameters_dict_from_subtree = self.traj.parameters.f_to_dict(fast_access=True)
with self.assertRaises(ValueError):
parameters_dict_directly = self.traj.f_get_parameters(copy=False, fast_access=True)
parameters_dict_directly = self.traj.f_get_parameters(copy=True, fast_access=True)
self.assertTrue(comp.nested_equal(parameters_dict_directly,parameters_dict_from_subtree),
'%s!=%s' % (str(parameters_dict_directly),str(parameters_dict_directly)))
################# Derived Parameters ############################
derived_parameters_dict_from_subtree = self.traj.derived_parameters.f_to_dict()
self.assertTrue(len(derived_parameters_dict_from_subtree)>0)
derived_parameters_dict_directly = self.traj.f_get_derived_parameters(copy=True)
self.assertTrue(comp.nested_equal(derived_parameters_dict_directly,derived_parameters_dict_from_subtree),
'%s!=%s' % (str(derived_parameters_dict_directly),str(derived_parameters_dict_directly)))
derived_parameters_dict_directly = self.traj.f_get_derived_parameters(copy=False)
self.assertTrue(comp.nested_equal(derived_parameters_dict_directly,derived_parameters_dict_from_subtree),
'%s!=%s' % (str(derived_parameters_dict_directly),str(derived_parameters_dict_directly)))
derived_parameters_dict_from_subtree = self.traj.derived_parameters.f_to_dict(fast_access=True)
with self.assertRaises(ValueError):
derived_parameters_dict_directly = self.traj.f_get_derived_parameters(copy=False, fast_access=True)
derived_parameters_dict_directly = self.traj.f_get_derived_parameters(copy=True, fast_access=True)
self.assertTrue(comp.nested_equal(derived_parameters_dict_directly,derived_parameters_dict_from_subtree),
'%s!=%s' % (str(derived_parameters_dict_directly),str(derived_parameters_dict_directly)))
############## Results #################################
results_dict_from_subtree = self.traj.results.f_to_dict()
self.assertTrue(len(results_dict_from_subtree)>0)
results_dict_directly = self.traj.f_get_results(copy=True)
self.assertTrue(comp.nested_equal(results_dict_directly,results_dict_from_subtree),
'%s!=%s' % (str(results_dict_directly),str(results_dict_directly)))
results_dict_directly = self.traj.f_get_results(copy=False)
self.assertTrue(comp.nested_equal(results_dict_directly,results_dict_from_subtree),
'%s!=%s' % (str(results_dict_directly),str(results_dict_directly)))
#.........这里部分代码省略.........
开发者ID:lsolanka,项目名称:pypet,代码行数:101,代码来源:trajectory_test.py
示例17: test_get_item_no_copy
def test_get_item_no_copy(self):
for node in self.traj.f_iter_nodes(recursive=True):
for key, val1 in node.v_annotations.f_to_dict(copy=False).items():
val2 = node.v_annotations[key]
self.assertTrue(comp.nested_equal(val1,val2))
开发者ID:ilonajulczuk,项目名称:pypet,代码行数:5,代码来源:annotations_test.py
示例18: check_isi_hist_monitor
def check_isi_hist_monitor(self, res, monitor):
self.assertEqual(str(monitor.source),res.source)
self.assertTrue(comp.nested_equal(monitor.count,res.count))
self.assertTrue(comp.nested_equal(monitor.bins,res.bins))
self.assertTrue(comp.nested_equal(monitor.delay,res.delay))
self.assertEqual(monitor.nspikes, res.nspikes)
开发者ID:lsolanka,项目名称:pypet,代码行数:6,代码来源:brian_monitor_test.py
示例19: check_population_spike_counter
def check_population_spike_counter(self, res, monitor):
self.assertTrue(comp.nested_equal(monitor.delay, res.delay))
self.assertTrue(comp.nested_equal(monitor.nspikes, res.nspikes))
self.assertTrue(comp.nested_equal(str(monitor.source), res.source))
开发者ID:lsolanka,项目名称:pypet,代码行数:4,代码来源:brian_monitor_test.py
示例20: check_van_rossum_metric
def check_van_rossum_metric(self,res, monitor):
self.assertTrue(comp.nested_equal(float(monitor.tau), res.tau))
self.assertTrue(comp.nested_equal('second', res.tau_unit))
self.assertTrue(comp.nested_equal(monitor.distance, res.distance))
self.assertTrue(comp.nested_equal(monitor.N, res.N))
self.assertTrue(comp.nested_equal(str(monitor.source), res.source))
开发者ID:lsolanka,项目名称:pypet,代码行数:6,代码来源:brian_monitor_test.py
注:本文中的pypet.utils.comparisons.nested_equal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论