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

[NixIO] Support "empty" annotations #500

Open
achilleas-k opened this issue Mar 21, 2018 · 4 comments
Open

[NixIO] Support "empty" annotations #500

achilleas-k opened this issue Mar 21, 2018 · 4 comments
Assignees
Labels
Milestone

Comments

@achilleas-k
Copy link
Contributor

achilleas-k commented Mar 21, 2018

Support empty lists in annotations (for NixIO).
See #476

@JuliaSprenger
Copy link
Member

For there is a quick fix for this (#476) but I think we should keep this open to find a more general solution.

@JuliaSprenger JuliaSprenger reopened this Mar 21, 2018
@JuliaSprenger JuliaSprenger added this to the 0.7.0 milestone Mar 21, 2018
@apdavison apdavison modified the milestones: 0.7.0, 0.8.0 Nov 15, 2018
@apdavison apdavison modified the milestones: 0.8.0, 0.9.0 Jul 23, 2019
@JuliaSprenger
Copy link
Member

Hi @achilleas-k
Any news on the support of empty annotations from the nix side?

@achilleas-k
Copy link
Contributor Author

Took me a while to remember what the situation was here. As a reminder for myself and anyone else that might need this:

Currently the Neo NIXIO writes empty annotations with a string dtype because properties must always have a dtype:

python-neo/neo/io/nixio.py

Lines 1326 to 1331 in 4e90312

if len(v) == 0:
# NIX supports empty properties but dtype must be specified
# Defaulting to String and using definition to signify empty
# iterable as opposed to empty string
values = nix.DataType.String
definition = EMPTYANNOTATION

It uses the definition field of the property to mark it as an empty annotation and return an empty list as its value on read, because otherwise it would return an empty string:

python-neo/neo/io/nixio.py

Lines 1381 to 1383 in 4e90312

if not len(values):
if prop.definition == EMPTYANNOTATION:
values = list()

Since (I think) v1.5.0b3, property values are always tuples, even when a single value is stored. It still requires the dtype to be specified, but when storing an empty value, the on disk representation is essentially an empty array. On read, this returns as an empty tuple.

So now we can indeed get rid of the workaround with the definition attribute. Storing an empty value, regardless of dtype, will be read back as an empty tuple, which we can then present to the Neo user as an empty list if necessary.

@JuliaSprenger
Copy link
Member

Since there is a quick fix for this already existing, I am postponing the clean solution to the next release

@JuliaSprenger JuliaSprenger modified the milestones: 0.9.0, 0.10.0 Nov 6, 2020
@samuelgarcia samuelgarcia modified the milestones: 0.10.0, 0.11.0 Jul 26, 2021
@apdavison apdavison modified the milestones: 0.10.3, 0.11.0 Aug 30, 2022
@apdavison apdavison modified the milestones: 0.11.0, 0.12.0 Sep 29, 2022
@JuliaSprenger JuliaSprenger modified the milestones: 0.12.0, 0.12.1 Apr 2, 2023
@JuliaSprenger JuliaSprenger modified the milestones: 0.12.1, 0.13.0 Jul 19, 2023
@apdavison apdavison modified the milestones: 0.13.0, 0.14.0 Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants