-
Notifications
You must be signed in to change notification settings - Fork 90
Open
Labels
category: enhancementimprovements of code or code behaviorimprovements of code or code behaviorcategory: proposalproposed enhancements or new featuresproposed enhancements or new featurespriority: lowalternative solution already working and/or relevant to only specific user(s)alternative solution already working and/or relevant to only specific user(s)
Milestone
Description
I would like classes that are auto-generated by extensions to automatically check that dimensions with the same label across datasets have the same length. If they do not, either throw an error or a warning. For example, in the code below, dset1 and dset2 are in DimsTest and both have a dimension named 'cells'. I would like it to be enforced that the lengths of these datasets must be equal. The code demonstrates that this is not currently the case, since there is no warning or error when I set dset1=[0, 1, 2, 3], dset2=[0, 1, 2]. I would prefer if this check occurred in the __init__ of NWBDataInterface, as opposed to on write or in a separate validator.
from datetime import datetime
from pynwb.spec import (NWBGroupSpec, NWBDatasetSpec, NWBNamespaceBuilder)
from pynwb import get_class, load_namespaces, NWBHDF5IO, NWBFile
project_name = 'dims_test'
ns_path = project_name + '.namespace.yaml'
ext_source = project_name + '.extensions.yaml'
ns_builder = NWBNamespaceBuilder(project_name, project_name)
datasets = [
NWBDatasetSpec(doc='dset1', dtype='uint32',shape=(None,),
name='dset1', dims=('cells',)),
NWBDatasetSpec(doc='dset2', dtype='uint64', shape=(None,),
name='dset2', dims=('cells',))
]
cont_data = NWBGroupSpec(doc='data',
datasets=datasets,
neurodata_type_inc='NWBDataInterface',
neurodata_type_def='DimsTest')
ns_builder.add_spec(ext_source, cont_data)
ns_builder.export(ns_path)
##
load_namespaces(ns_path)
DimsTest = get_class('DimsTest', project_name)
dims_test = DimsTest(name='name', source='source', dset1=[0, 1, 2, 3], dset2=[0, 1, 2])
nwbfile = NWBFile(source='source', session_description='session_description',
identifier='identifier', session_start_time=datetime.now(),
file_create_date=datetime.now())
module = nwbfile.create_processing_module(name='name',
source='source',
description='description')
module.add_container(dims_test)
with NWBHDF5IO('dims_test.nwb', mode='w') as io:
io.write(nwbfile)Checklist
- Have you ensured the feature or change was not already reported ?
- Have you included a brief and descriptive title?
- Have you included a clear description of the problem you are trying to solve?
- Have you included a minimal code snippet that reproduces the issue you are encountering?
Metadata
Metadata
Assignees
Labels
category: enhancementimprovements of code or code behaviorimprovements of code or code behaviorcategory: proposalproposed enhancements or new featuresproposed enhancements or new featurespriority: lowalternative solution already working and/or relevant to only specific user(s)alternative solution already working and/or relevant to only specific user(s)