本文整理汇总了Python中neo.test.tools.assert_neo_object_is_compliant函数的典型用法代码示例。如果您正苦于以下问题:Python assert_neo_object_is_compliant函数的具体用法?Python assert_neo_object_is_compliant怎么用?Python assert_neo_object_is_compliant使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_neo_object_is_compliant函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_time_slice_differnt_units
def test_time_slice_differnt_units(self):
params = {'test2': 'y1', 'test3': True}
arr_ann = {'index': np.arange(9), 'test': np.arange(100, 109)}
evt = Event([0.1, 0.5, 1.1, 1.5, 1.7, 2.2, 2.9, 3.1, 3.3] * pq.ms, name='test',
description='tester', file_origin='test.file', test1=1,
array_annotations=arr_ann, **params)
assert_neo_object_is_compliant(evt)
evt.annotate(test1=1.1, test0=[1, 2])
targ = Event([2.2, 2.9] * pq.ms, name='test', description='tester',
file_origin='test.file', test1=1, **params)
assert_neo_object_is_compliant(targ)
targ.annotate(test1=1.1, test0=[1, 2])
t_start = 0.002 * pq.s
t_stop = 0.003 * pq.s
result = evt.time_slice(t_start, t_stop)
assert_arrays_equal(targ, result)
self.assertEqual(targ.name, result.name)
self.assertEqual(targ.description, result.description)
self.assertEqual(targ.file_origin, result.file_origin)
self.assertEqual(targ.annotations['test0'], result.annotations['test0'])
self.assertEqual(targ.annotations['test1'], result.annotations['test1'])
self.assertEqual(targ.annotations['test2'], result.annotations['test2'])
assert_arrays_equal(result.array_annotations['index'], np.arange(5, 7))
assert_arrays_equal(result.array_annotations['test'], np.arange(105, 107))
self.assertIsInstance(result.array_annotations, ArrayDict)
示例2: test__slice_should_return_AnalogSignalArray
def test__slice_should_return_AnalogSignalArray(self):
# slice
for index in (0, np.int64(0)):
result = self.signal1[3:8, index]
self.assertIsInstance(result, AnalogSignal)
assert_neo_object_is_compliant(result)
self.assertEqual(result.name, 'spam') # should slicing really preserve name and description?
self.assertEqual(result.description, 'eggs') # perhaps these should be modified to indicate the slice?
self.assertEqual(result.file_origin, 'testfile.txt')
self.assertEqual(result.annotations, {'arg1': 'test'})
self.assertEqual(result.size, 5)
self.assertEqual(result.sampling_period, self.signal1.sampling_period)
self.assertEqual(result.sampling_rate, self.signal1.sampling_rate)
self.assertEqual(result.t_start,
self.signal1.t_start+3*result.sampling_period)
self.assertEqual(result.t_stop,
result.t_start + 5*result.sampling_period)
assert_array_equal(result.magnitude, self.data1[3:8].reshape(-1, 1))
# Test other attributes were copied over (in this case, defaults)
self.assertEqual(result.file_origin, self.signal1.file_origin)
self.assertEqual(result.name, self.signal1.name)
self.assertEqual(result.description, self.signal1.description)
self.assertEqual(result.annotations, self.signal1.annotations)
示例3: test__children
def test__children(self):
params = {'test2': 'y1', 'test3': True}
epc = Epoch([1.1, 1.5, 1.7]*pq.ms, durations=[20, 40, 60]*pq.ns,
labels=np.array(['test epoch 1',
'test epoch 2',
'test epoch 3'], dtype='S'),
name='test', description='tester',
file_origin='test.file',
test1=1, **params)
epc.annotate(test1=1.1, test0=[1, 2])
assert_neo_object_is_compliant(epc)
segment = Segment(name='seg1')
segment.epochs = [epc]
segment.create_many_to_one_relationship()
self.assertEqual(epc._single_parent_objects, ('Segment',))
self.assertEqual(epc._multi_parent_objects, ())
self.assertEqual(epc._single_parent_containers, ('segment',))
self.assertEqual(epc._multi_parent_containers, ())
self.assertEqual(epc._parent_objects, ('Segment',))
self.assertEqual(epc._parent_containers, ('segment',))
self.assertEqual(len(epc.parents), 1)
self.assertEqual(epc.parents[0].name, 'seg1')
assert_neo_object_is_compliant(epc)
示例4: test_time_slice_none_both
def test_time_slice_none_both(self):
targdataquant = [[0.0], [1.0], [2.0], [3.0], [4.0], [5.0], [6.0], [7.0], [8.0],
[9.0]] * pq.mV
targtime = np.logspace(1, 5, 10)
targtimequant = targtime[0:10] * pq.ms
targ_signal = IrregularlySampledSignal(targtimequant, signal=targdataquant, name='spam',
description='eggs', file_origin='testfile.txt',
arg1='test')
t_start = None
t_stop = None
result = self.signal1.time_slice(t_start, t_stop)
assert_array_equal(result, targ_signal)
assert_array_equal(result.times, targtimequant)
self.assertEqual(result.units, 1 * pq.mV)
self.assertIsInstance(result, IrregularlySampledSignal)
assert_neo_object_is_compliant(result)
self.assertEqual(result.name, 'spam')
self.assertEqual(result.description, 'eggs')
self.assertEqual(result.file_origin, 'testfile.txt')
self.assertEqual(result.annotations, {'arg1': 'test'})
assert_arrays_equal(result.array_annotations['anno1'], np.array([23]))
assert_arrays_equal(result.array_annotations['anno2'], np.array(['A']))
self.assertIsInstance(result.array_annotations, ArrayDict)
示例5: test__sampling_period
def test__sampling_period(self):
result1 = self.spike1.sampling_period
self.spike1.sampling_rate = None
assert_neo_object_is_compliant(self.spike1)
result2 = self.spike1.sampling_period
self.spike1.sampling_rate = self.sampling_rate1
self.spike1.sampling_period = 10.0 * pq.ms
assert_neo_object_is_compliant(self.spike1)
result3a = self.spike1.sampling_period
result3b = self.spike1.sampling_rate
self.spike1.sampling_period = None
result4a = self.spike1.sampling_period
result4b = self.spike1.sampling_rate
self.assertEqual(result1, 10.0 / pq.Hz)
self.assertEqual(result1.units, 1.0 / pq.Hz)
self.assertEqual(result2, None)
self.assertEqual(result3a, 10.0 * pq.ms)
self.assertEqual(result3a.units, 1.0 * pq.ms)
self.assertEqual(result3b, 0.1 / pq.ms)
self.assertEqual(result3b.units, 1.0 / pq.ms)
self.assertEqual(result4a, None)
self.assertEqual(result4b, None)
示例6: test_defaults
def test_defaults(self):
res = generate_one_simple_block()
self.assertTrue(isinstance(res, Block))
assert_neo_object_is_compliant(res)
self.assertEqual(len(res.segments), 0)
示例7: test_time_slice_empty
def test_time_slice_empty(self):
params = {'test2': 'y1', 'test3': True}
epc = Epoch([]*pq.ms, durations=[]*pq.ns,
labels=np.array([], dtype='S'),
name='test', description='tester',
file_origin='test.file',
test1=1, **params)
epc.annotate(test1=1.1, test0=[1, 2])
assert_neo_object_is_compliant(epc)
targ = Epoch([]*pq.ms, durations=[]*pq.ns,
labels=np.array([], dtype='S'),
name='test', description='tester',
file_origin='test.file',
test1=1, **params)
targ.annotate(test1=1.1, test0=[1, 2])
assert_neo_object_is_compliant(targ)
t_start = 1.2
t_stop = 1.6
result = epc.time_slice(t_start, t_stop)
assert_arrays_equal(result.times, targ.times)
assert_arrays_equal(result.durations, targ.durations)
assert_arrays_equal(result.labels, targ.labels)
self.assertEqual(result.name, targ.name)
self.assertEqual(result.description, targ.description)
self.assertEqual(result.file_origin, targ.file_origin)
self.assertEqual(result.annotations['test0'], targ.annotations['test0'])
self.assertEqual(result.annotations['test1'], targ.annotations['test1'])
self.assertEqual(result.annotations['test2'], targ.annotations['test2'])
示例8: test__children
def test__children(self):
params = {"test2": "y1", "test3": True}
evt = Event(
1.5 * pq.ms,
label="test epoch",
name="test",
description="tester",
file_origin="test.file",
test1=1,
**params
)
evt.annotate(test1=1.1, test0=[1, 2])
assert_neo_object_is_compliant(evt)
segment = Segment(name="seg1")
segment.events = [evt]
segment.create_many_to_one_relationship()
self.assertEqual(evt._single_parent_objects, ("Segment",))
self.assertEqual(evt._multi_parent_objects, ())
self.assertEqual(evt._single_parent_containers, ("segment",))
self.assertEqual(evt._multi_parent_containers, ())
self.assertEqual(evt._parent_objects, ("Segment",))
self.assertEqual(evt._parent_containers, ("segment",))
self.assertEqual(len(evt.parents), 1)
self.assertEqual(evt.parents[0].name, "seg1")
assert_neo_object_is_compliant(evt)
示例9: test__children
def test__children(self):
segment = Segment(name='seg1')
segment.spikes = [self.spike1]
segment.create_many_to_one_relationship()
unit = Unit(name='unit1')
unit.spikes = [self.spike1]
unit.create_many_to_one_relationship()
self.assertEqual(self.spike1._single_parent_objects,
('Segment', 'Unit'))
self.assertEqual(self.spike1._multi_parent_objects, ())
self.assertEqual(self.spike1._single_parent_containers,
('segment', 'unit'))
self.assertEqual(self.spike1._multi_parent_containers, ())
self.assertEqual(self.spike1._parent_objects,
('Segment', 'Unit'))
self.assertEqual(self.spike1._parent_containers,
('segment', 'unit'))
self.assertEqual(len(self.spike1.parents), 2)
self.assertEqual(self.spike1.parents[0].name, 'seg1')
self.assertEqual(self.spike1.parents[1].name, 'unit1')
assert_neo_object_is_compliant(self.spike1)
示例10: test__create_with_copy_true_should_return_copy
def test__create_with_copy_true_should_return_copy(self):
data = np.arange(20.0).reshape((10, 2)) * pq.mV
rate = 5000 * pq.Hz
signal = AnalogSignal(data, copy=True, sampling_rate=rate)
assert_neo_object_is_compliant(signal)
data[3, 0] = 0.099 * pq.V
self.assertNotEqual(signal[3, 0], 99 * pq.mV)
示例11: test__children
def test__children(self):
signal = self.signals[0]
segment = Segment(name='seg1')
segment.analogsignals = [signal]
segment.create_many_to_one_relationship()
chx = ChannelIndex(name='chx1', index=np.arange(signal.shape[1]))
chx.analogsignals = [signal]
chx.create_many_to_one_relationship()
self.assertEqual(signal._single_parent_objects, ('Segment', 'ChannelIndex'))
self.assertEqual(signal._multi_parent_objects, ())
self.assertEqual(signal._single_parent_containers, ('segment', 'channel_index'))
self.assertEqual(signal._multi_parent_containers, ())
self.assertEqual(signal._parent_objects, ('Segment', 'ChannelIndex'))
self.assertEqual(signal._parent_containers, ('segment', 'channel_index'))
self.assertEqual(len(signal.parents), 2)
self.assertEqual(signal.parents[0].name, 'seg1')
self.assertEqual(signal.parents[1].name, 'chx1')
assert_neo_object_is_compliant(signal)
示例12: check_creation
def check_creation(self, rchan):
assert_neo_object_is_compliant(rchan)
seed = rchan.annotations['seed']
targ0 = get_fake_value('index', int, seed=seed+0, obj=RecordingChannel)
self.assertEqual(rchan.index, targ0)
targ1 = get_fake_value('coordinate', pq.Quantity, dim=1, seed=seed+1)
assert_arrays_equal(rchan.coordinate, targ1)
targ2 = get_fake_value('name', str, seed=seed+2, obj=RecordingChannel)
self.assertEqual(rchan.name, targ2)
targ3 = get_fake_value('description', str,
seed=seed+3, obj=RecordingChannel)
self.assertEqual(rchan.description, targ3)
targ4 = get_fake_value('file_origin', str)
self.assertEqual(rchan.file_origin, targ4)
targ5 = get_annotations()
targ5['seed'] = seed
self.assertEqual(rchan.annotations, targ5)
self.assertTrue(hasattr(rchan, 'analogsignals'))
self.assertTrue(hasattr(rchan, 'irregularlysampledsignals'))
self.assertEqual(len(rchan.analogsignals), self.nchildren)
self.assertEqual(len(rchan.irregularlysampledsignals), self.nchildren)
示例13: test__fake_neo__cascade
def test__fake_neo__cascade(self):
self.annotations['seed'] = None
obj_type = Segment
cascade = True
res = fake_neo(obj_type=obj_type, cascade=cascade)
self.assertTrue(isinstance(res, Segment))
assert_neo_object_is_compliant(res)
self.assertEqual(res.annotations, self.annotations)
self.assertEqual(len(res.analogsignals), 1)
self.assertEqual(len(res.irregularlysampledsignals), 1)
self.assertEqual(len(res.spiketrains), 1)
self.assertEqual(len(res.events), 1)
self.assertEqual(len(res.epochs), 1)
for child in res.children:
del child.annotations['i']
del child.annotations['j']
self.assertEqual(res.analogsignals[0].annotations,
self.annotations)
self.assertEqual(res.irregularlysampledsignals[0].annotations,
self.annotations)
self.assertEqual(res.spiketrains[0].annotations,
self.annotations)
self.assertEqual(res.events[0].annotations,
self.annotations)
self.assertEqual(res.epochs[0].annotations,
self.annotations)
示例14: test_recordingchannelgroup__compliance
def test_recordingchannelgroup__compliance(self):
assert_neo_object_is_compliant(self.rcg1)
assert_neo_object_is_compliant(self.rcg2)
self.assertEqual(self.rcg1.name, 'test')
self.assertEqual(self.rcg2.name, 'test')
self.assertEqual(self.rcg1.description, 'tester 1')
self.assertEqual(self.rcg2.description, 'tester 2')
self.assertEqual(self.rcg1.file_origin, 'test.file')
self.assertEqual(self.rcg2.file_origin, 'test.file')
self.assertEqual(self.rcg1.annotations['testarg0'], [1, 2, 3])
self.assertEqual(self.rcg2.annotations['testarg10'], [1, 2, 3])
self.assertEqual(self.rcg1.annotations['testarg1'], 1.1)
self.assertEqual(self.rcg2.annotations['testarg1'], 1)
self.assertEqual(self.rcg2.annotations['testarg11'], 1.1)
self.assertEqual(self.rcg1.annotations['testarg2'], 'yes')
self.assertEqual(self.rcg2.annotations['testarg2'], 'yes')
self.assertTrue(self.rcg1.annotations['testarg3'])
self.assertTrue(self.rcg2.annotations['testarg3'])
self.assertTrue(hasattr(self.rcg1, 'units'))
self.assertTrue(hasattr(self.rcg2, 'units'))
self.assertEqual(len(self.rcg1.units), 2)
self.assertEqual(len(self.rcg2.units), 3)
self.assertEqual(self.rcg1.units, self.units1)
self.assertEqual(self.rcg2.units, self.units2)
self.assertTrue(hasattr(self.rcg1, 'recordingchannels'))
self.assertTrue(hasattr(self.rcg2, 'recordingchannels'))
self.assertEqual(len(self.rcg1.recordingchannels), 2)
self.assertEqual(len(self.rcg2.recordingchannels), 3)
for res, targ in zip(self.rcg1.recordingchannels, self.rchan1):
self.assertEqual(res.name, targ.name)
for res, targ in zip(self.rcg2.recordingchannels, self.rchan2):
self.assertEqual(res.name, targ.name)
self.assertTrue(hasattr(self.rcg1, 'analogsignalarrays'))
self.assertTrue(hasattr(self.rcg2, 'analogsignalarrays'))
self.assertEqual(len(self.rcg1.analogsignalarrays), 2)
self.assertEqual(len(self.rcg2.analogsignalarrays), 3)
for res, targ in zip(self.rcg1.analogsignalarrays, self.sigarr1):
assert_arrays_equal(res, targ)
self.assertEqual(res.name, targ.name)
for res, targ in zip(self.rcg2.analogsignalarrays, self.sigarr2):
assert_arrays_equal(res, targ)
self.assertEqual(res.name, targ.name)
示例15: test__fake_neo__cascade
def test__fake_neo__cascade(self):
self.annotations['seed'] = None
obj_type = 'ChannelIndex'
cascade = True
res = fake_neo(obj_type=obj_type, cascade=cascade)
self.assertTrue(isinstance(res, ChannelIndex))
assert_neo_object_is_compliant(res)
self.assertEqual(res.annotations, self.annotations)
for child in res.children_recur:
del child.annotations['i']
del child.annotations['j']
self.assertEqual(len(res.units), 1)
unit = res.units[0]
self.assertEqual(unit.annotations, self.annotations)
self.assertEqual(len(res.analogsignals), 1)
self.assertEqual(res.analogsignals[0].annotations,
self.annotations)
self.assertEqual(len(unit.spiketrains), 1)
self.assertEqual(unit.spiketrains[0].annotations,
self.annotations)