How to use the pynwb.form.spec.DatasetSpec function in pynwb

To help you get started, we’ve selected a few pynwb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NeurodataWithoutBorders / pynwb / tests / unit / form_tests / spec_tests / test_group_spec.py View on Github external
def test_type_extension(self):
        spec = GroupSpec('A test group',
                         name='parent_type',
                         datasets=self.datasets,
                         attributes=self.attributes,
                         linkable=False,
                         namespace='core',
                         data_type_def='EphysData')
        dset1_attributes_ext = [
            AttributeSpec('dset1_extra_attribute', 'an extra attribute for the first dataset', 'str')
        ]
        ext_datasets = [
            DatasetSpec('my first dataset extension',
                        'int',
                        name='dataset1',
                        attributes=dset1_attributes_ext,
                        linkable=True),
        ]
        ext_attributes = [
            AttributeSpec('ext_extra_attribute', 'an extra attribute for the group', 'str'),
        ]
        ext = GroupSpec('A test group extension',
                        name='child_type',
                        datasets=ext_datasets,
                        attributes=ext_attributes,
                        linkable=False,
                        namespace='core',
                        data_type_inc=spec,
                        data_type_def='SpikeData')
github NeurodataWithoutBorders / pynwb / tests / unit / form_tests / build_tests / test_io_map.py View on Github external
def setUpBarSpec(self):
        self.bar_spec = GroupSpec('A test group specification with a data type',
                                  data_type_def='Bar',
                                  datasets=[DatasetSpec('an example dataset', 'int', name='data')],
                                  attributes=[AttributeSpec('attr1', 'an example string attribute', 'str'),
                                              AttributeSpec('attr2', 'an example integer attribute', 'int')])
github NeurodataWithoutBorders / pynwb / tests / unit / form_tests / spec_tests / test_dataset_spec.py View on Github external
def test_datatype_extension_groupspec(self):
        '''Test to make sure DatasetSpec catches when a GroupSpec used as data_type_inc'''
        base = GroupSpec('a fake grop',
                         namespace='core',
                         data_type_def='EphysData')
        with self.assertRaises(TypeError):
            ext = DatasetSpec('my first dataset extension',  # noqa: F841
                              'int',
                              name='dataset1',
                              namespace='core',
                              data_type_inc=base,
                              data_type_def='SpikeData')
github NeurodataWithoutBorders / pynwb / tests / unit / form_tests / build_tests / test_io_map.py View on Github external
def setUpBarSpec(self):
        self.bar_spec = GroupSpec('A test group specification with a data type',
                                  data_type_def='Bar',
                                  datasets=[DatasetSpec('an example dataset', 'int', name='data',
                                                        attributes=[AttributeSpec(
                                                            'attr2', 'an example integer attribute', 'int')])],
                                  attributes=[AttributeSpec('attr1', 'an example string attribute', 'str')])
github NeurodataWithoutBorders / pynwb / tests / unit / form_tests / spec_tests / test_dataset_spec.py View on Github external
def test_datatype_table_extension_higher_precision(self):
        dtype1 = DtypeSpec('column1', 'the first column', 'int')
        dtype2 = DtypeSpec('column2', 'the second column', 'float32')
        base = DatasetSpec('my first table',
                           [dtype1, dtype2],
                           attributes=self.attributes,
                           namespace='core',
                           data_type_def='SimpleTable')
        self.assertEqual(base['dtype'], [dtype1, dtype2])
        self.assertEqual(base['doc'], 'my first table')
        dtype3 = DtypeSpec('column2', 'the second column, with greater precision', 'float64')
        ext = DatasetSpec('my first table extension',
                          [dtype3],
                          namespace='core',
                          data_type_inc=base,
                          data_type_def='ExtendedTable')
        self.assertEqual(ext['dtype'], [dtype1, dtype3])
        self.assertEqual(ext['doc'], 'my first table extension')
github NeurodataWithoutBorders / pynwb / tests / unit / form_tests / validator_tests / test_validate.py View on Github external
def getSpecs(self):
        bar = GroupSpec('A test group specification with a data type',
                        data_type_def='Bar',
                        datasets=[DatasetSpec('an example dataset', 'int', name='data',
                                              attributes=[AttributeSpec('attr2', 'an example integer attribute',
                                                                        'int')])],
                        attributes=[AttributeSpec('attr1', text('an example string attribute'), 'text')])
        foo = GroupSpec('A test group that contains a data type',
                        data_type_def='Foo',
                        groups=[GroupSpec('A Bar group for Foos', name='my_bar', data_type_inc='Bar')],
                        attributes=[AttributeSpec('foo_attr', 'a string attribute specified as text', 'text',
                                                  required=False)])

        return (bar, foo)
github NeurodataWithoutBorders / pynwb / tests / unit / form_tests / spec_tests / test_dataset_spec.py View on Github external
def test_datatype_table_extension_lower_precision(self):
        dtype1 = DtypeSpec('column1', 'the first column', 'int')
        dtype2 = DtypeSpec('column2', 'the second column', 'float64')
        base = DatasetSpec('my first table',
                           [dtype1, dtype2],
                           attributes=self.attributes,
                           namespace='core',
                           data_type_def='SimpleTable')
        self.assertEqual(base['dtype'], [dtype1, dtype2])
        self.assertEqual(base['doc'], 'my first table')
        dtype3 = DtypeSpec('column2', 'the second column, with greater precision', 'float32')
        with self.assertRaisesRegex(ValueError, 'Cannot extend float64 to float32'):
            ext = DatasetSpec('my first table extension',  # noqa: F841
                              [dtype3],
                              namespace='core',
                              data_type_inc=base,
                              data_type_def='ExtendedTable')
github NeurodataWithoutBorders / pynwb / tests / unit / form_tests / spec_tests / test_dataset_spec.py View on Github external
def test_datatype_extension(self):
        base = DatasetSpec('my first dataset',
                           'int',
                           name='dataset1',
                           dimension=(None, None),
                           attributes=self.attributes,
                           linkable=False,
                           namespace='core',
                           data_type_def='EphysData')

        attributes = [AttributeSpec('attribute3', 'my first extending attribute', 'float')]
        ext = DatasetSpec('my first dataset extension',
                          'int',
                          name='dataset1',
                          dimension=(None, None),
                          attributes=attributes,
                          linkable=False,
                          namespace='core',
                          data_type_inc=base,
                          data_type_def='SpikeData')
        self.assertDictEqual(ext['attributes'][0], attributes[0])
        self.assertDictEqual(ext['attributes'][1], self.attributes[0])
        self.assertDictEqual(ext['attributes'][2], self.attributes[1])
        ext_attrs = ext.attributes
        self.assertIs(ext, ext_attrs[0].parent)
        self.assertIs(ext, ext_attrs[1].parent)
        self.assertIs(ext, ext_attrs[2].parent)
github NeurodataWithoutBorders / pynwb / tests / unit / form_tests / build_tests / test_io_map_data.py View on Github external
def setUpBazSpec(self):
        self.baz_spec = DatasetSpec('an Baz type', 'int', name='MyBaz', data_type_def='Baz',
                                    attributes=[AttributeSpec('baz_attr', 'an example string attribute', 'str')])
github NeurodataWithoutBorders / pynwb / tests / unit / form_tests / spec_tests / test_group_spec.py View on Github external
AttributeSpec('attribute1', 'my first attribute', 'str'),
            AttributeSpec('attribute2', 'my second attribute', 'str')
        ]

        self.dset1_attributes = [
            AttributeSpec('attribute3', 'my third attribute', 'str'),
            AttributeSpec('attribute4', 'my fourth attribute', 'str')
        ]

        self.dset2_attributes = [
            AttributeSpec('attribute5', 'my fifth attribute', 'str'),
            AttributeSpec('attribute6', 'my sixth attribute', 'str')
        ]

        self.datasets = [
            DatasetSpec('my first dataset',
                        'int',
                        name='dataset1',
                        attributes=self.dset1_attributes,
                        linkable=True),
            DatasetSpec('my second dataset',
                        'int',
                        name='dataset2',
                        dimension=(None, None),
                        attributes=self.dset2_attributes,
                        linkable=True,
                        namespace='core',
                        data_type_def='VoltageArray')
        ]

        self.subgroups = [
            GroupSpec('A test subgroup',