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

[Feature]: Add function to reset a field to None #1029

Open
rly opened this issue Jan 16, 2024 · 0 comments
Open

[Feature]: Add function to reset a field to None #1029

rly opened this issue Jan 16, 2024 · 0 comments
Assignees
Labels
category: enhancement improvements of code or code behavior priority: low alternative solution already working and/or relevant to only specific user(s)

Comments

@rly
Copy link
Contributor

rly commented Jan 16, 2024

What would you like to see added to HDMF?

AbstractContainer.reset_parent and LabelledDict.pop allow users to remove objects from a MultiContainerInterface, which is useful during modification and export of an NWB file. However, child objects that are not in a LabelledDict, e.g., NWBFile.units cannot be removed this way. The workaround is to do:

nwbfile.units.reset_parent()
nwbfile.fields["units"] = None

This is not ideal, because we normally discourage users from tampering with the fields attribute.

What solution would you like?

Perhaps reset_parent should look into the parent object and if it is in the parent object in the fields dictionary, then reset the value in fields.

Or perhaps even more intuitively, simply allow nwbfile.units = None which would handle resetting the value in fields (if it is allowed to be None) and call nwbfile.units.reset_parent(). This is related to #868

Do you have any interest in helping implement the feature?

Yes.

@rly rly added category: enhancement improvements of code or code behavior priority: low alternative solution already working and/or relevant to only specific user(s) labels Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: enhancement improvements of code or code behavior priority: low alternative solution already working and/or relevant to only specific user(s)
Projects
None yet
Development

No branches or pull requests

2 participants