-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Labels
category: bugerrors in the code or code behaviorerrors in the code or code behaviorpriority: 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
What happened?
Some optional fields in the schema have a default value specified in the PyNWB constructor. For example, TimeSeries.__init__
accepts the argument conversion
with a default value of 1. A a user should be able to reset the value to None if they want so that it is not written at all. This would be used to represent an unknown value for the field. I can't think of any other use cases.
However, you cannot initialize a TimeSeries
with its value set to None. As a result, all TimeSeries
will have conversion
set to either 1 or a user-set non-None value. A value is always written.
The core issue lies with docval in HDMF, but I want to track this issue in PyNWB as well.
Steps to Reproduce
from pynwb import TimeSeries
ts = TimeSeries(name='test', data=[1, 2], rate=1.0, unit='unit', conversion=None)
Traceback
Traceback (most recent call last):
File "<string>", line 1, in <module>
from pynwb import TimeSeries; ts = TimeSeries(name='test', data=[1, 2], rate=1.0, unit='unit', conversion=None); print(ts.conversion)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/rly/miniconda3/envs/test/lib/python3.13/site-packages/hdmf/utils.py", line 577, in func_call
pargs = _check_args(args, kwargs)
File "/Users/rly/miniconda3/envs/test/lib/python3.13/site-packages/hdmf/utils.py", line 570, in _check_args
raise ExceptionType(msg)
TypeError: TimeSeries.__init__: incorrect type for 'conversion' (got 'NoneType', expected 'float')
Operating System
macOS
Python Executable
Conda
Python Version
3.13
Package Versions
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
- Have you checked the Contributing document?
- Have you ensured this bug was not already reported?
Metadata
Metadata
Assignees
Labels
category: bugerrors in the code or code behaviorerrors in the code or code behaviorpriority: lowalternative solution already working and/or relevant to only specific user(s)alternative solution already working and/or relevant to only specific user(s)