You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pynwb: 1.4.0
hdfm: 2.1.0
python 3.7.4
h5py 2.10.0
Windows
Below is a MWE and the backtrace.
I'm a bit suprised I had to pass a list at
data = ["abcd"]
into UserCommentDevice.
I'd be glad to hear about workarounds.
MWE:
frompynwb.specimportNWBNamespaceBuilder, NWBGroupSpec, NWBAttributeSpec, NWBDatasetSpecfrompynwbimportload_namespaces, get_classname='test_multicontainerinterface'ns_path=name+".namespace.yaml"ext_source=name+".extensions.yaml"ns_builder=NWBNamespaceBuilder(name+' extensions', name, version='0.1.0')
ns_builder.include_type('NWBDataInterface', namespace='core')
ns_builder.include_type('NWBData', namespace='core')
user_comment_string=NWBDatasetSpec('device specific user text notes',
neurodata_type_def='UserCommentString',
neurodata_type_inc='NWBData',
dtype="text")
potato_sack=NWBGroupSpec(neurodata_type_def='PotatoSack',
neurodata_type_inc='NWBDataInterface',
name='potato_sack',
doc='A sack of potatoes', quantity='?',
datasets=[user_comment_string])
ns_builder.add_spec(ext_source, potato_sack)
ns_builder.export(ns_path)
frompynwbimportregister_class, load_namespacesfrompynwb.fileimportMultiContainerInterface, NWBContainerload_namespaces(ns_path)
UserCommentString=get_class("UserCommentString", name)
@register_class('PotatoSack', name)classPotatoSack(MultiContainerInterface):
__clsconf__= {
'attr': 'user_comment_string',
'type': UserCommentString,
'add': 'add_potato',
'get': 'get_potato',
'create': 'create_potato',
}
##################### Then use the objects (again, this would often be done in a different file).frompynwbimportNWBHDF5IO, NWBFilefromdatetimeimportdatetimefromdateutil.tzimporttzlocal# You can add potatoes to a potato sack in different wayspotato_sack=PotatoSack(user_comment_string=UserCommentString(name='potato1', data= ["abcd"]))
nwbfile=NWBFile("a file with metadata", "NB123A", datetime(2018, 6, 1, tzinfo=tzlocal()))
pmod=nwbfile.create_processing_module('module_name', 'desc')
pmod.add_container(potato_sack)
withNWBHDF5IO('test_multicontainerinterface.nwb', 'w') asio:
io.write(nwbfile)
##################### This is how you read the NWB file (again, this would often be done in a# different file).load_namespaces(ns_path)
io=NWBHDF5IO('test_multicontainerinterface.nwb', 'r')
nwb=io.read()
$ python extensions.py
Traceback (most recent call last):
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1137, in construct
obj.__init__(**kwargs)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\utils.py", line 560, in func_call
pargs = _check_args(args, kwargs)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\utils.py", line 553, in _check_args
raise ExceptionType(msg)
TypeError: TypeMap.__get_cls_dict.<locals>.__init__: incorrect type for 'data' (got 'str', expected 'ndarray, list, tuple, Dataset, HDMFDataset, AbstractDataChunkIterator, DataIO or Data')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "extensions.py", line 69, in <module>
nwb = io.read()
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\backends\hdf5\h5tools.py", line 414, in read
return call_docval_func(super().read, kwargs)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\utils.py", line 405, in call_docval_func
return func(*fargs, **fkwargs)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\utils.py", line 561, in func_call
return func(args[0], **pargs)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\backends\io.py", line 36, in read
container = self.__manager.construct(f_builder)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\utils.py", line 561, in func_call
return func(args[0], **pargs)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\manager.py", line 238, in construct
result = self.__type_map.construct(builder, self, None)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\utils.py", line 561, in func_call
return func(args[0], **pargs)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\manager.py", line 857, in construct
return obj_mapper.construct(builder, build_manager, parent)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\utils.py", line 561, in func_call
return func(args[0], **pargs)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1105, in construct
subspecs = self.__get_subspec_values(builder, self.spec, manager)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1035, in __get_subspec_values
self.__get_sub_builders(groups, spec.groups, manager, ret)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1085, in __get_sub_builders
ret.update(self.__get_subspec_values(sub_builder, subspec, manager))
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1035, in __get_subspec_values
self.__get_sub_builders(groups, spec.groups, manager, ret)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1077, in __get_sub_builders
sub_builder = self.__flatten(sub_builder, subspec, manager)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1090, in __flatten
tmp = [manager.construct(b) for b in sub_builder]
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1090, in <listcomp>
tmp = [manager.construct(b) for b in sub_builder]
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\utils.py", line 561, in func_call
return func(args[0], **pargs)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\manager.py", line 234, in construct
result = self.__type_map.construct(builder, self, parent)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\utils.py", line 561, in func_call
return func(args[0], **pargs)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\manager.py", line 857, in construct
return obj_mapper.construct(builder, build_manager, parent)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\utils.py", line 561, in func_call
return func(args[0], **pargs)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1105, in construct
subspecs = self.__get_subspec_values(builder, self.spec, manager)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1035, in __get_subspec_values
self.__get_sub_builders(groups, spec.groups, manager, ret)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1077, in __get_sub_builders
sub_builder = self.__flatten(sub_builder, subspec, manager)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1090, in __flatten
tmp = [manager.construct(b) for b in sub_builder]
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1090, in <listcomp>
tmp = [manager.construct(b) for b in sub_builder]
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\utils.py", line 561, in func_call
return func(args[0], **pargs)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\manager.py", line 234, in construct
result = self.__type_map.construct(builder, self, parent)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\utils.py", line 561, in func_call
return func(args[0], **pargs)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\manager.py", line 857, in construct
return obj_mapper.construct(builder, build_manager, parent)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\utils.py", line 561, in func_call
return func(args[0], **pargs)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1105, in construct
subspecs = self.__get_subspec_values(builder, self.spec, manager)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1036, in __get_subspec_values
self.__get_sub_builders(datasets, spec.datasets, manager, ret)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1077, in __get_sub_builders
sub_builder = self.__flatten(sub_builder, subspec, manager)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1090, in __flatten
tmp = [manager.construct(b) for b in sub_builder]
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1090, in <listcomp>
tmp = [manager.construct(b) for b in sub_builder]
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\utils.py", line 561, in func_call
return func(args[0], **pargs)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\manager.py", line 234, in construct
result = self.__type_map.construct(builder, self, parent)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\utils.py", line 561, in func_call
return func(args[0], **pargs)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\manager.py", line 857, in construct
return obj_mapper.construct(builder, build_manager, parent)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\utils.py", line 561, in func_call
return func(args[0], **pargs)
File "C:\users\thomas\Anaconda3\envs\pynwb\lib\site-packages\hdmf\build\objectmapper.py", line 1140, in construct
raise Exception(msg) from ex
Exception: Could not construct UserCommentString object due to: TypeMap.__get_cls_dict.<locals>.__init__: incorrect type for 'data' (got 'str', expected 'ndarray, list, tuple, Dataset, HDMFDataset, AbstractDataChunkIterator, DataIO or Data')
The text was updated successfully, but these errors were encountered:
Thanks for pinging. Indeed this is fixed with pynwb 5fcd364 (Add environment-ros3.yml to MANIFEST.in (#1398), 2021-08-13), hdmf b3437314 (Remove regex test for setting an unsettable property (#664), 2021-08-16) and h5py 3.3.
pynwb: 1.4.0
hdfm: 2.1.0
python 3.7.4
h5py 2.10.0
Windows
Below is a MWE and the backtrace.
I'm a bit suprised I had to pass a list at
into UserCommentDevice.
I'd be glad to hear about workarounds.
MWE:
The text was updated successfully, but these errors were encountered: