本文整理汇总了Python中neo.test.generate_datasets.get_fake_value函数的典型用法代码示例。如果您正苦于以下问题:Python get_fake_value函数的具体用法?Python get_fake_value怎么用?Python get_fake_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_fake_value函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test__get_fake_values
def test__get_fake_values(self):
self.annotations['seed'] = 0
channel_indexes = get_fake_value('channel_indexes', np.ndarray, seed=0,
dim=1, dtype='i')
name = get_fake_value('name', str, seed=1, obj=Unit)
description = get_fake_value('description', str, seed=2, obj='Unit')
file_origin = get_fake_value('file_origin', str)
attrs1 = {'name': name,
'description': description,
'file_origin': file_origin}
attrs2 = attrs1.copy()
attrs2.update(self.annotations)
res11 = get_fake_values(Unit, annotate=False, seed=0)
res12 = get_fake_values('Unit', annotate=False, seed=0)
res21 = get_fake_values(Unit, annotate=True, seed=0)
res22 = get_fake_values('Unit', annotate=True, seed=0)
assert_arrays_equal(res11.pop('channel_indexes'), channel_indexes)
assert_arrays_equal(res12.pop('channel_indexes'), channel_indexes)
assert_arrays_equal(res21.pop('channel_indexes'), channel_indexes)
assert_arrays_equal(res22.pop('channel_indexes'), channel_indexes)
self.assertEqual(res11, attrs1)
self.assertEqual(res12, attrs1)
self.assertEqual(res21, attrs2)
self.assertEqual(res22, attrs2)
示例2: check_creation
def check_creation(self, rcg):
assert_neo_object_is_compliant(rcg)
seed = rcg.annotations['seed']
for i, rchan in enumerate(rcg.recordingchannels):
self.assertEqual(rchan.name, rcg.channel_names[i].astype(str))
self.assertEqual(rchan.index, rcg.channel_indexes[i])
for i, unit in enumerate(rcg.units):
for sigarr in rcg.analogsignalarrays:
self.assertEqual(unit.channel_indexes[0],
sigarr.channel_index[i])
targ2 = get_fake_value('name', str, seed=seed+2,
obj=RecordingChannelGroup)
self.assertEqual(rcg.name, targ2)
targ3 = get_fake_value('description', str,
seed=seed+3, obj=RecordingChannelGroup)
self.assertEqual(rcg.description, targ3)
targ4 = get_fake_value('file_origin', str)
self.assertEqual(rcg.file_origin, targ4)
targ5 = get_annotations()
targ5['seed'] = seed
self.assertEqual(rcg.annotations, targ5)
self.assertTrue(hasattr(rcg, 'recordingchannels'))
self.assertTrue(hasattr(rcg, 'units'))
self.assertTrue(hasattr(rcg, 'analogsignalarrays'))
self.assertEqual(len(rcg.recordingchannels), self.nchildren)
self.assertEqual(len(rcg.units), self.nchildren)
self.assertEqual(len(rcg.analogsignalarrays), self.nchildren)
示例3: check_creation
def check_creation(self, chx):
assert_neo_object_is_compliant(chx)
seed = chx.annotations['seed']
# for i, unit in enumerate(chx.units):
# for sigarr in chx.analogsignals:
# self.assertEqual(unit.channel_indexes[0],
# sigarr.channel_index[i])
targ2 = get_fake_value('name', str, seed=seed+4,
obj=ChannelIndex)
self.assertEqual(chx.name, targ2)
targ3 = get_fake_value('description', str,
seed=seed+5, obj=ChannelIndex)
self.assertEqual(chx.description, targ3)
targ4 = get_fake_value('file_origin', str)
self.assertEqual(chx.file_origin, targ4)
targ5 = get_annotations()
targ5['seed'] = seed
self.assertEqual(chx.annotations, targ5)
self.assertTrue(hasattr(chx, 'units'))
self.assertTrue(hasattr(chx, 'analogsignals'))
self.assertEqual(len(chx.units), self.nchildren)
self.assertEqual(len(chx.analogsignals), self.nchildren)
示例4: test__get_fake_values
def test__get_fake_values(self):
self.annotations['seed'] = 0
times = get_fake_value('times', pq.Quantity, seed=0, dim=1)
labels = get_fake_value('labels', np.ndarray, seed=1, dim=1, dtype='S')
name = get_fake_value('name', str, seed=2, obj=Event)
description = get_fake_value('description', str,
seed=3, obj='Event')
file_origin = get_fake_value('file_origin', str)
attrs1 = {'name': name,
'description': description,
'file_origin': file_origin}
attrs2 = attrs1.copy()
attrs2.update(self.annotations)
res11 = get_fake_values(Event, annotate=False, seed=0)
res12 = get_fake_values('Event', annotate=False, seed=0)
res21 = get_fake_values(Event, annotate=True, seed=0)
res22 = get_fake_values('Event', annotate=True, seed=0)
assert_arrays_equal(res11.pop('times'), times)
assert_arrays_equal(res12.pop('times'), times)
assert_arrays_equal(res21.pop('times'), times)
assert_arrays_equal(res22.pop('times'), times)
assert_arrays_equal(res11.pop('labels'), labels)
assert_arrays_equal(res12.pop('labels'), labels)
assert_arrays_equal(res21.pop('labels'), labels)
assert_arrays_equal(res22.pop('labels'), labels)
self.assertEqual(res11, attrs1)
self.assertEqual(res12, attrs1)
self.assertEqual(res21, attrs2)
self.assertEqual(res22, attrs2)
示例5: test__get_fake_values
def test__get_fake_values(self):
self.annotations["seed"] = 0
time = get_fake_value("time", pq.Quantity, seed=0, dim=0)
label = get_fake_value("label", str, seed=1)
name = get_fake_value("name", str, seed=2, obj=Event)
description = get_fake_value("description", str, seed=3, obj="Event")
file_origin = get_fake_value("file_origin", str)
attrs1 = {"label": label, "name": name, "description": description, "file_origin": file_origin}
attrs2 = attrs1.copy()
attrs2.update(self.annotations)
res11 = get_fake_values(Event, annotate=False, seed=0)
res12 = get_fake_values("Event", annotate=False, seed=0)
res21 = get_fake_values(Event, annotate=True, seed=0)
res22 = get_fake_values("Event", annotate=True, seed=0)
assert_arrays_equal(res11.pop("time"), time)
assert_arrays_equal(res12.pop("time"), time)
assert_arrays_equal(res21.pop("time"), time)
assert_arrays_equal(res22.pop("time"), time)
self.assertEqual(res11, attrs1)
self.assertEqual(res12, attrs1)
self.assertEqual(res21, attrs2)
self.assertEqual(res22, attrs2)
示例6: test__get_fake_values
def test__get_fake_values(self):
self.annotations['seed'] = 0
index = get_fake_value('index', int, seed=0)
coordinate = get_fake_value('coordinate', pq.Quantity, seed=1, dim=1)
name = get_fake_value('name', str, seed=2, obj=RecordingChannel)
description = get_fake_value('description', str, seed=3,
obj='RecordingChannel')
file_origin = get_fake_value('file_origin', str)
attrs1 = {'index': index,
'name': name,
'description': description,
'file_origin': file_origin}
attrs2 = attrs1.copy()
attrs2.update(self.annotations)
res11 = get_fake_values(RecordingChannel, annotate=False, seed=0)
res12 = get_fake_values('RecordingChannel', annotate=False, seed=0)
res21 = get_fake_values(RecordingChannel, annotate=True, seed=0)
res22 = get_fake_values('RecordingChannel', annotate=True, seed=0)
assert_arrays_equal(res11.pop('coordinate'), coordinate)
assert_arrays_equal(res12.pop('coordinate'), coordinate)
assert_arrays_equal(res21.pop('coordinate'), coordinate)
assert_arrays_equal(res22.pop('coordinate'), coordinate)
self.assertEqual(res11, attrs1)
self.assertEqual(res12, attrs1)
self.assertEqual(res21, attrs2)
self.assertEqual(res22, attrs2)
示例7: 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)
示例8: check_creation
def check_creation(self, unit):
assert_neo_object_is_compliant(unit)
seed = unit.annotations['seed']
targ0 = get_fake_value('channel_indexes', np.ndarray, dim=1, dtype='i',
seed=seed+0)
assert_arrays_equal(unit.channel_indexes, targ0)
targ1 = get_fake_value('name', str, seed=seed+1, obj=Unit)
self.assertEqual(unit.name, targ1)
targ2 = get_fake_value('description', str,
seed=seed+2, obj=Unit)
self.assertEqual(unit.description, targ2)
targ3 = get_fake_value('file_origin', str)
self.assertEqual(unit.file_origin, targ3)
targ4 = get_annotations()
targ4['seed'] = seed
self.assertEqual(unit.annotations, targ4)
self.assertTrue(hasattr(unit, 'spikes'))
self.assertTrue(hasattr(unit, 'spiketrains'))
self.assertEqual(len(unit.spikes), self.nchildren)
self.assertEqual(len(unit.spiketrains), self.nchildren)
示例9: test__str
def test__str(self):
name = 'test__str'
datatype = str
targ = str(np.random.randint(100000))
res = get_fake_value(name, datatype, seed=0)
self.assertTrue(isinstance(res, str))
self.assertEqual(targ, res)
示例10: test__int
def test__int(self):
name = 'test__int'
datatype = int
targ = np.random.randint(100)
res = get_fake_value(name, datatype, seed=0)
self.assertTrue(isinstance(res, int))
self.assertEqual(targ, res)
示例11: test__float
def test__float(self):
name = 'test__float'
datatype = float
targ = 1000. * np.random.random()
res = get_fake_value(name, datatype, seed=0)
self.assertTrue(isinstance(res, float))
self.assertEqual(targ, res)
示例12: test__datetime
def test__datetime(self):
name = 'test__datetime'
datatype = datetime
targ = datetime.fromtimestamp(1000000000 * np.random.random())
res = get_fake_value(name, datatype, seed=0)
self.assertTrue(isinstance(res, datetime))
self.assertEqual(res, targ)
示例13: test__file_origin
def test__file_origin(self):
name = 'file_origin'
datatype = str
targ = 'test_file.txt'
res = get_fake_value(name, datatype, seed=0)
self.assertTrue(isinstance(res, str))
self.assertEqual(targ, res)
self.assertRaises(ValueError, get_fake_value, name, datatype, dim=1)
self.assertRaises(ValueError, get_fake_value, name, np.ndarray)
示例14: test__t_stop
def test__t_stop(self):
name = 't_stop'
datatype = pq.Quantity
targ = 1.0 * pq.millisecond
res = get_fake_value(name, datatype)
self.assertTrue(isinstance(res, pq.Quantity))
self.assertEqual(res.units, pq.millisecond)
assert_arrays_equal(targ, res)
self.assertRaises(ValueError, get_fake_value, name, datatype, dim=1)
self.assertRaises(ValueError, get_fake_value, name, np.ndarray)
示例15: test__sampling_rate
def test__sampling_rate(self):
name = 'sampling_rate'
datatype = pq.Quantity
targ = 10000.0 * pq.Hz
res = get_fake_value(name, datatype)
self.assertTrue(isinstance(res, pq.Quantity))
self.assertEqual(res.units, pq.Hz)
assert_arrays_equal(targ, res)
self.assertRaises(ValueError, get_fake_value, name, datatype, dim=1)
self.assertRaises(ValueError, get_fake_value, name, np.ndarray)