How to use the pynwb.form.spec.AttributeSpec 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 / 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_group_spec.py View on Github external
attributes=self.dset2_attributes,
                        linkable=True,
                        namespace='core',
                        data_type_def='VoltageArray')
        ]

        self.subgroups = [
            GroupSpec('A test subgroup',
                      name='subgroup1',
                      linkable=False),
            GroupSpec('A test subgroup',
                      name='subgroup2',
                      linkable=False)

        ]
        self.ndt_attr_spec = AttributeSpec('data_type', 'the data type of this object', 'text', value='EphysData')
        self.ns_attr_spec = AttributeSpec('namespace', 'the namespace for the data type of this object',
                                          'text', required=False)
github NeurodataWithoutBorders / pynwb / tests / unit / form_tests / spec_tests / test_group_spec.py View on Github external
def setUp(self):
        self.attributes = [
            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',
github NeurodataWithoutBorders / pynwb / tests / unit / form_tests / build_tests / test_io_map.py View on Github external
def test_dynamic_container_constructor(self):
        baz_spec = GroupSpec('A test extension with no Container class',
                             data_type_def='Baz', data_type_inc=self.bar_spec,
                             attributes=[AttributeSpec('attr3', 'an example float attribute', 'float'),
                                         AttributeSpec('attr4', 'another example float attribute', 'float')])
        self.spec_catalog.register_spec(baz_spec, 'extension.yaml')
        cls = self.type_map.get_container_cls(CORE_NAMESPACE, 'Baz')
        # TODO: test that constructor works!
        inst = cls('My Baz', [1, 2, 3, 4], 'string attribute', 1000, attr3=98.6, attr4=1.0)
        self.assertEqual(inst.name, 'My Baz')
        self.assertEqual(inst.data, [1, 2, 3, 4])
        self.assertEqual(inst.attr1, 'string attribute')
        self.assertEqual(inst.attr2, 1000)
        self.assertEqual(inst.attr3, 98.6)
        self.assertEqual(inst.attr4, 1.0)
github NeurodataWithoutBorders / pynwb / tests / unit / form_tests / spec_tests / test_dataset_spec.py View on Github external
def setUp(self):
        self.attributes = [
            AttributeSpec('attribute1', 'my first attribute', 'str'),
            AttributeSpec('attribute2', 'my second attribute', 'str')
        ]
github NeurodataWithoutBorders / pynwb / tests / unit / form_tests / spec_tests / test_group_spec.py View on Github external
def setUp(self):
        self.attributes = [
            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',
github NeurodataWithoutBorders / pynwb / tests / unit / form_tests / spec_tests / test_group_spec.py View on Github external
def setUp(self):
        self.attributes = [
            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',
github NeurodataWithoutBorders / pynwb / tests / unit / form_tests / build_tests / test_io_map.py View on Github external
def setUp(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')])
        self.spec_catalog = SpecCatalog()
        self.spec_catalog.register_spec(self.bar_spec, 'test.yaml')
        self.namespace = SpecNamespace('a test namespace', CORE_NAMESPACE,
                                       [{'source': 'test.yaml'}], catalog=self.spec_catalog)
        self.namespace_catalog = NamespaceCatalog()
        self.namespace_catalog.add_namespace(CORE_NAMESPACE, self.namespace)
        self.type_map = TypeMap(self.namespace_catalog)
        self.type_map.register_container_type(CORE_NAMESPACE, 'Bar', Bar)
        self.type_map.register_map(Bar, ObjectMapper)
        self.manager = BuildManager(self.type_map)
        self.mapper = ObjectMapper(self.bar_spec)
github NeurodataWithoutBorders / pynwb / tests / unit / form_tests / spec_tests / test_dataset_spec.py View on Github external
def setUp(self):
        self.attributes = [
            AttributeSpec('attribute1', 'my first attribute', 'str'),
            AttributeSpec('attribute2', 'my second attribute', 'str')
        ]
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')])