Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_mutually_exclusive_attributes(self):
gb1 = GroupBuilder('gb1', attributes={'attr1': 'my_attribute1'})
gb2 = GroupBuilder('gb2', attributes={'attr2': 'my_attribute2'})
gb1.deep_update(gb2)
self.assertIn('attr2', gb2)
self.assertEqual(gb2['attr2'], 'my_attribute2')
def test_mutually_exclusive_datasets(self):
gb1 = GroupBuilder('gb1', datasets={'dataset1': DatasetBuilder('dataset1', [1, 2, 3])})
gb2 = GroupBuilder('gb2', datasets={'dataset2': DatasetBuilder('dataset2', [4, 5, 6])})
gb1.deep_update(gb2)
self.assertIn('dataset2', gb1)
# self.assertIs(gb1['dataset2'], gb2['dataset2'])
self.assertListEqual(gb1['dataset2'].data, gb2['dataset2'].data)
def test_mutually_exclusive_subgroups(self):
gb1 = GroupBuilder('gb1', {'subgroup1': GroupBuilder('subgroup1')})
gb2 = GroupBuilder('gb2', {'subgroup2': GroupBuilder('subgroup2')})
gb1.deep_update(gb2)
self.assertIn('subgroup2', gb1)
gb1sg = gb1['subgroup2']
gb2sg = gb2['subgroup2']
self.assertIs(gb1sg, gb2sg)
def test_invalid_incorrect_type_validate(self):
builder = GroupBuilder('my_bar', attributes={'data_type': 'Bar', 'attr1': 10})
result = self.vmap.validate(builder)
self.assertEqual(len(result), 2)
self.assertIsInstance(result[0], DtypeError) # noqa: F405
self.assertEqual(result[0].name, 'Bar/attr1')
self.assertIsInstance(result[1], MissingError) # noqa: F405
self.assertEqual(result[1].name, 'Bar/data')
def setUp(self):
self.gb = GroupBuilder('gb')
self.gb2 = GroupBuilder('gb2', source='file1')
def test_mutually_exclusive_attributes(self):
gb1 = GroupBuilder('gb1', attributes={'attr1': 'my_attribute1'})
gb2 = GroupBuilder('gb2', attributes={'attr2': 'my_attribute2'})
gb1.deep_update(gb2)
self.assertIn('attr2', gb2)
self.assertEqual(gb2['attr2'], 'my_attribute2')
ts = TimeSeries('test_timeseries', 'example_source',
list(range(100, 200, 10)), 'SIunit', timestamps=list(range(10)), resolution=0.1)
self.container.add_acquisition(ts)
ts_builder = GroupBuilder('test_timeseries',
attributes={'source': 'example_source',
'neurodata_type': 'TimeSeries',
'help': 'General purpose TimeSeries'},
datasets={'data': DatasetBuilder('data', list(range(100, 200, 10)),
attributes={'unit': 'SIunit',
'conversion': 1.0,
'resolution': 0.1}),
'timestamps': DatasetBuilder('timestamps', list(range(10)),
attributes={'unit': 'Seconds',
'interval': 1})})
self.builder = GroupBuilder(
'root', groups={'acquisition': GroupBuilder('acquisition', groups={'test_timeseries': ts_builder}),
'analysis': GroupBuilder('analysis'),
'general': GroupBuilder('general'),
'processing': GroupBuilder('processing'),
'stimulus': GroupBuilder(
'stimulus',
groups={'presentation': GroupBuilder('presentation'),
'templates': GroupBuilder('templates')})},
datasets={'file_create_date': DatasetBuilder('file_create_date', [str(self.create_date)]),
'identifier': DatasetBuilder('identifier', 'TEST123'),
'session_description': DatasetBuilder('session_description', 'a test NWB File'),
'nwb_version': DatasetBuilder('nwb_version', '1.0.6'),
'session_start_time': DatasetBuilder('session_start_time', str(self.start_time))},
attributes={'neurodata_type': 'NWBFile'})
def test_intersecting_subgroups(self):
subgroup2 = GroupBuilder('subgroup2')
gb1 = GroupBuilder('gb1', {'subgroup1': GroupBuilder('subgroup1'), 'subgroup2': subgroup2})
gb2 = GroupBuilder('gb2', {'subgroup2': GroupBuilder('subgroup2'), 'subgroup3': GroupBuilder('subgroup3')})
gb1.deep_update(gb2)
self.assertIn('subgroup3', gb1)
self.assertIs(gb1['subgroup3'], gb2['subgroup3'])
self.assertIs(gb1['subgroup2'], subgroup2)
attributes={'ancestry': 'TimeSeries',
'neurodata_type': 'TimeSeries',
'int_array_attribute': [0, 1, 2, 3],
'str_array_attribute': ['a', 'b', 'c', 'd'],
'help': 'General purpose TimeSeries'},
datasets={'data': DatasetBuilder('data', list(range(100, 200, 10)),
attributes={'unit': 'SIunit',
'conversion': 1.0,
'resolution': 0.1}),
'timestamps': DatasetBuilder(
'timestamps', list(range(10)),
attributes={'unit': 'Seconds', 'interval': 1})})
self.ts = TimeSeries('test_timeseries', list(range(100, 200, 10)),
unit='SIunit', resolution=0.1, timestamps=list(range(10)))
self.manager.prebuilt(self.ts, self.ts_builder)
self.builder = GroupBuilder(
'root',
source=self.path,
groups={'acquisition':
GroupBuilder('acquisition',
groups={'timeseries':
GroupBuilder('timeseries',
groups={'test_timeseries': self.ts_builder}),
'images': GroupBuilder('images')}),
'analysis': GroupBuilder('analysis'),
'epochs': GroupBuilder('epochs'),
'general': GroupBuilder('general'),
'processing': GroupBuilder('processing',
groups={'test_module':
GroupBuilder('test_module',
links={'test_timeseries_link':
LinkBuilder(self.ts_builder,