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

Document that Dataset.update defaults to being inplace. #2951

Closed
nebain opened this issue May 9, 2019 · 4 comments · Fixed by #4932
Closed

Document that Dataset.update defaults to being inplace. #2951

nebain opened this issue May 9, 2019 · 4 comments · Fixed by #4932

Comments

@nebain
Copy link

nebain commented May 9, 2019

It is not documented that the inplace argument to Dataset.update defaults to True, in a departure from every other place where the inplace argument exists (I see this was briefly mentioned in #1756).

Currently the documentation reads:

Dataset.update(other, inplace=None)
...
inplace:bool, optional
If True, merge the other dataset into this dataset in-place. Otherwise, return a new dataset object.

I had to dig into the source code to understand why new_ds = ds.update(changes) was causing changes to ds. It needs to be documented that update is one of the few mutable functions on a dataset.

@max-sixty
Copy link
Collaborator

Thanks for the issue @nebain .

.update does default to 'inplace' in python's standard library, I agree we could show that in the docs though.

Would you be interested in adding it in a PR?

@shoyer
Copy link
Member

shoyer commented May 11, 2019

Ideally, we would probably have update() return None (like dict.update) if it's acting in-place.

I'm not sure if there's an easy way to change this incrementally, though.

@max-sixty max-sixty mentioned this issue Aug 24, 2019
4 tasks
@shoyer
Copy link
Member

shoyer commented Aug 25, 2019

Maybe we could make update return a dummy object wrapping a Dataset that forwards all methods to the dataset but issues a warning on the first use? I think this could probably be cooked up with __getattr__.

@keewis
Copy link
Collaborator

keewis commented Nov 26, 2020

Adding a wrapper object would probably break isinstance checks (unless we inherit from Dataset), so we would break some code either way.

I would vote for listing this as a breaking change in the next major version and start returning None (and maybe point to assign in the docstring).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants