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

Add a __delitem__ method to InferenceData #2293

Closed
Dekermanjian opened this issue Nov 29, 2023 · 3 comments · Fixed by #2295
Closed

Add a __delitem__ method to InferenceData #2293

Dekermanjian opened this issue Nov 29, 2023 · 3 comments · Fixed by #2295

Comments

@Dekermanjian
Copy link

I would like to be able to do something like this:

del idata["prior"]

At the moment I get the error:

TypeError: 'InferenceData' object does not support item deletion
@Dekermanjian
Copy link
Author

Never mind, I found the way to do it. Just for anyone searching how to do this.

idata.__delattr__(group = <group name>)

@OriolAbril
Copy link
Member

it looks like we have a __delattr__ method but not a __delitem__ one. You shouldn't call either directly though. To delete a group you should do:

del idata.prior

which will call __delattr__ under the hood. We need to add a __delitem__ method that calls the __delattr__ one. Do you want to send a PR for this?

@OriolAbril OriolAbril reopened this Nov 30, 2023
@OriolAbril OriolAbril changed the title Add a method to delete a group from an InferenceData Add a __delitem__ method to InferenceData Nov 30, 2023
@OriolAbril OriolAbril linked a pull request Dec 14, 2023 that will close this issue
@Dekermanjian
Copy link
Author

@OriolAbril Hey, I am sorry for some reason I did not get alerted to your message until just now. Thank you for taking care of adding that in.

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

Successfully merging a pull request may close this issue.

2 participants