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 update as inplace #4932

Merged
merged 9 commits into from
Feb 24, 2021
Merged

document update as inplace #4932

merged 9 commits into from
Feb 24, 2021

Conversation

keewis
Copy link
Collaborator

@keewis keewis commented Feb 19, 2021

As pointed out in #2951 I don't think we are able to deprecate the return value. If we are fine with introducing the breaking change in 0.17, I can also remove the return value here.

@dcherian
Copy link
Contributor

I think we should warn for a while before removing the return value.

@keewis
Copy link
Collaborator Author

keewis commented Feb 20, 2021

how would we do that? As far as I can tell the only options are: always warn (but that would also warn if the return value is not used) or wrap in a custom object and warn in __getattr__ (but that would break isinstance checks).

@dcherian
Copy link
Contributor

dcherian commented Feb 20, 2021

:embarassed: I didn't think of that. Maybe we make the breaking change in v1.0? could add a "pending deprecation" message in the docstring?

@keewis
Copy link
Collaborator Author

keewis commented Feb 21, 2021

could add a "pending deprecation" message in the docstring?

I added the deprecation to both the docstring and whats-new.rst. This won't reach as many people as warning would, but I guess this is as much as we are able to do. Should we add a estimated release for the removal (0.19)?

@max-sixty
Copy link
Collaborator

LGTM!

Your call on ETA — 0.19 sounds very reasonable. Also OK to see how we go.

@max-sixty
Copy link
Collaborator

I was on the fence about doing the release this evening anyway — I may as well wait until we're decided and this is merged — I'll complete in the next couple of days.

@mathause
Copy link
Collaborator

mathause commented Feb 22, 2021

Could we modify the original Dataset class with a special attribute? (Not sure if that'd actually work.)

class Dataset(...)

    _from_update = False

    def update(self, other: "CoercibleMapping") -> "Dataset":

        merge_result = dataset_update_method(self, other)
        self._replace(inplace=True, **merge_result._asdict())
        out = self.copy()
        out._from_update = True
        return out

    def __getattr__(self, name: str) -> Any:
        if self._from_update:
            warnings.warn("")
            self._from_update = False
        return super().__getattr__(name)

@keewis
Copy link
Collaborator Author

keewis commented Feb 22, 2021

that could work, but we would need to use __getattribute__ instead (__getattr__ is only called if AttributeError would be raised otherwise). Not sure if the increased visibility is worth the additional complexity, though.

@keewis
Copy link
Collaborator Author

keewis commented Feb 22, 2021

if we decide the overhead introduced by @mathause's suggestion is worth it, I can try adding that. Does not have to be in this PR (or included in the release), though.

@keewis
Copy link
Collaborator Author

keewis commented Feb 24, 2021

let's include this in the release, even though we still have to decide if we should use the __getattributes__ method

@keewis keewis merged commit 351b0aa into pydata:master Feb 24, 2021
@keewis keewis deleted the update branch February 24, 2021 21:17
dcherian added a commit to dcherian/xarray that referenced this pull request Mar 8, 2021
* upstream/master: (46 commits)
  pin netCDF4=1.5.3 in min-all-deps (pydata#4982)
  fix matplotlib errors for single level discrete colormaps (pydata#4256)
  Adapt exception handling in CFTimeIndex.__sub__ and __rsub__ (pydata#5006)
  Update options.py (pydata#5000)
  Adjust tests to use updated pandas syntax for offsets (pydata#4537)
  add a combine_attrs parameter to Dataset.merge (pydata#4895)
  Support for dask.graph_manipulation (pydata#4965)
  raise on passing axis to Dataset.reduce methods (pydata#4940)
  Whatsnew for 0.17.1 (pydata#4963)
  Refinements to how-to-release (pydata#4964)
  DOC: add example for reindex (pydata#4956)
  DOC: rm np import (pydata#4949)
  Add 0.17.0 release notes (pydata#4953)
  document update as inplace (pydata#4932)
  bump the dependencies (pydata#4942)
  Upstream CI: limit runtime (pydata#4946)
  typing for numpy 1.20 (pydata#4878)
  Use definition of DTypeLike from Numpy if found (pydata#4941)
  autoupdate mypy (pydata#4943)
  Add DataArrayCoarsen.reduce and DatasetCoarsen.reduce methods (pydata#4939)
  ...
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 this pull request may close these issues.

Document that Dataset.update defaults to being inplace.
4 participants