Beispiel #1
0
 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)
Beispiel #2
0
 def setUp(self):
     spec_catalog = SpecCatalog()
     for spec in self.getSpecs():
         spec_catalog.register_spec(spec, 'test.yaml')
     self.namespace = SpecNamespace(
         'a test namespace', CORE_NAMESPACE, [{'source': 'test.yaml'}], catalog=spec_catalog)
     self.vmap = ValidatorMap(self.namespace)
Beispiel #3
0
 def setUp(self):
     self.setUpBazSpec()
     self.spec_catalog = SpecCatalog()
     self.spec_catalog.register_spec(self.baz_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, 'Baz', Baz)
     self.type_map.register_map(Baz, ObjectMapper)
     self.manager = BuildManager(self.type_map)
     self.mapper = ObjectMapper(self.baz_spec)
Beispiel #4
0
 def setUp(self):
     self.bar_spec = GroupSpec(
         'A test group specification with a data type', data_type_def='Bar')
     spec_catalog = SpecCatalog()
     spec_catalog.register_spec(self.bar_spec, 'test.yaml')
     namespace = SpecNamespace('a test namespace',
                               CORE_NAMESPACE, [{
                                   'source': 'test.yaml'
                               }],
                               catalog=spec_catalog)
     namespace_catalog = NamespaceCatalog()
     namespace_catalog.add_namespace(CORE_NAMESPACE, namespace)
     self.type_map = TypeMap(namespace_catalog)
     self.type_map.register_container_type(CORE_NAMESPACE, 'Bar', Bar)
Beispiel #5
0
 def setUp(self):
     self.attributes = [
         AttributeSpec('attribute1', 'my first attribute', 'text'),
         AttributeSpec('attribute2', 'my second attribute', 'text')
     ]
     self.dset1_attributes = [
         AttributeSpec('attribute3', 'my third attribute', 'text'),
         AttributeSpec('attribute4', 'my fourth attribute', 'text')
     ]
     self.dset2_attributes = [
         AttributeSpec('attribute5', 'my fifth attribute', 'text'),
         AttributeSpec('attribute6', 'my sixth attribute', 'text')
     ]
     self.datasets = [
         DatasetSpec(
             'my first dataset',  # noqa: F405
             'int',
             name='dataset1',
             attributes=self.dset1_attributes,
             linkable=True),
         DatasetSpec(
             'my second dataset',  # noqa: F405
             'int',
             name='dataset2',
             dimension=(None, None),
             attributes=self.dset2_attributes,
             linkable=True,
             data_type_def='VoltageArray')
     ]
     self.spec = GroupSpec(
         'A test group',  # noqa: F405
         name='root_constructor_nwbtype',
         datasets=self.datasets,
         attributes=self.attributes,
         linkable=False,
         data_type_def='EphysData')
     dset1_attributes_ext = [
         AttributeSpec('dset1_extra_attribute',
                       'an extra attribute for the first dataset', 'text')
     ]
     self.ext_datasets = [
         DatasetSpec(
             'my first dataset extension',  # noqa: F405
             'int',
             name='dataset1',
             attributes=dset1_attributes_ext,
             linkable=True),
     ]
     self.ext_attributes = [
         AttributeSpec('ext_extra_attribute',
                       'an extra attribute for the group', 'text'),
     ]
     self.ext_spec = GroupSpec(
         'A test group extension',  # noqa: F405
         name='root_constructor_nwbtype',
         datasets=self.ext_datasets,
         attributes=self.ext_attributes,
         linkable=False,
         data_type_inc='EphysData',
         data_type_def='SpikeData')
     to_dump = {'groups': [self.spec, self.ext_spec]}
     self.specs_path = 'test_load_namespace.specs.yaml'
     self.namespace_path = 'test_load_namespace.namespace.yaml'
     with open(self.specs_path, 'w') as tmp:
         yaml.safe_dump(json.loads(json.dumps(to_dump)),
                        tmp,
                        default_flow_style=False)
     ns_dict = {
         'doc': 'a test namespace',
         'name': self.NS_NAME,
         'schema': [{
             'source': self.specs_path
         }]
     }
     self.namespace = SpecNamespace.build_namespace(**ns_dict)  # noqa: F405
     to_dump = {'namespaces': [self.namespace]}
     with open(self.namespace_path, 'w') as tmp:
         yaml.safe_dump(json.loads(json.dumps(to_dump)),
                        tmp,
                        default_flow_style=False)
     self.ns_catalog = NamespaceCatalog()  # noqa: F405