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

Error when saving spiketrain with left_sweep attribute #11

Open
JuliaSprenger opened this issue Jun 19, 2017 · 2 comments
Open

Error when saving spiketrain with left_sweep attribute #11

JuliaSprenger opened this issue Jun 19, 2017 · 2 comments
Assignees

Comments

@JuliaSprenger
Copy link

On the 'nixio-object-names' branch, when trying to save a spiketrain like this one

    st = neo.SpikeTrain([1, 2, 3]*pq.s, t_start=0*pq.s,
                        t_stop=10*pq.s, sampling_rate=1*pq.Hz,
                        left_sweep=-2.0*pq.s)
    waveforms = np.arange(3*16).reshape((3,-1))*pq.V
    st.waveforms = waveforms

this results in a TypeError

[...]
File "python-neo/neo/io/nixio.py", line 741, in write_spiketrain
self._write_object(sptr, loc)
File "python-neo/neo/io/nixio.py", line 555, in _write_object
self._write_data(nixobj, attr, objpath)
File "python-neo/neo/io/nixio.py", line 964, in _write_data
attr["left_sweep"])
File "python-neo/neo/io/nixio.py", line 1076, in _write_property
for item in v:
TypeError: iteration over a 0-d array

The underlying problem is that a scalar quantity object like -2.0*pq.s is evaluated as being an Iterable, but actually can not be iterated.
I think this case should needs to be explicitly checked somewhere within the nixio.

@JuliaSprenger
Copy link
Author

A simple workaround to avoid this problem would be to save only spiketrains, for which the left_sweep attributes contain data like [-2.0]*pq.s.

@achilleas-k
Copy link
Member

achilleas-k commented Jun 19, 2017

I should add a special case for 0d/scalar quantities. The _write_property() method needs to make some assumptions about the structure of properties based on their type and for now one of the assumptions is that Quantity types are iterable. Of course this isn't true when it's a 0d array, so we should check for that.

@achilleas-k achilleas-k self-assigned this Jun 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants