Skip to content

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

@rly

Description

@rly

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.

Metadata

Metadata

Assignees

Labels

category: enhancementimprovements of code or code behaviorpriority: lowalternative solution already working and/or relevant to only specific user(s)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions