Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docval shape cannot be checked on types without len #103

Closed
rly opened this issue Jul 16, 2019 · 0 comments · Fixed by #104
Closed

Docval shape cannot be checked on types without len #103

rly opened this issue Jul 16, 2019 · 0 comments · Fixed by #104
Labels
category: bug errors in the code or code behavior

Comments

@rly
Copy link
Contributor

rly commented Jul 16, 2019

When shape is defined for a docval argument and type can be an object that does not have a __len__, e.g. ElectricalSeries.data

class ElectricalSeries(TimeSeries):
    @docval(...
            {'name': 'data', 'type': ('array_data', 'data', TimeSeries),
             'shape': ((None, ), (None, None), (None, None, None)),
             'doc': 'The data this TimeSeries dataset stores. Can also store binary data e.g. image frames'},
             ...)

then doing a direct link between data of one ElectricalSeries and another:

ts1 = ElectricalSeries('test_ts1', [0, 1, 2, 3, 4, 5], region, timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])
ts2 = ElectricalSeries('test_ts2', ts1, region, timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])

results in the error:

Traceback (most recent call last):
  File "C:\Users\Ryan\Documents\NWB\temp\pynwb\tests\unit\test_ecephys.py", line 42, in test_timestamps_link
    ts2 = ElectricalSeries('test_ts2', ts1, region, timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])
  File "c:\users\ryan\documents\nwb\hdmf\src\hdmf\utils.py", line 379, in func_call
    allow_extra=allow_extra)
  File "c:\users\ryan\documents\nwb\hdmf\src\hdmf\utils.py", line 176, in __parse_args
    if not __shape_okay_multi(argval, arg['shape']):
  File "c:\users\ryan\documents\nwb\hdmf\src\hdmf\utils.py", line 71, in __shape_okay_multi
    return any(__shape_okay(value, a) for a in argshape)
  File "c:\users\ryan\documents\nwb\hdmf\src\hdmf\utils.py", line 71, in <genexpr>
    return any(__shape_okay(value, a) for a in argshape)
  File "c:\users\ryan\documents\nwb\hdmf\src\hdmf\utils.py", line 78, in __shape_okay
    if not len(valshape) == len(argshape):
TypeError: object of type 'NoneType' has no len()
@rly rly added the category: bug errors in the code or code behavior label Jul 16, 2019
@rly rly closed this as completed in #104 Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: bug errors in the code or code behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant