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

Fix pickle/deepcopy for non-default argument CRSs #1491

Merged
merged 2 commits into from
Mar 26, 2020

Conversation

pelson
Copy link
Member

@pelson pelson commented Mar 22, 2020

Rationale

Currently the CRS __reduce__ implementation ignores the state entirely (i.e. __getstate__ is never called), and you end up with deepcopy / pickle returned instances which have default values, not the values that the original instance had.

Implications

  • Fixes the incorrect copy/pickling behaviour
  • Preserves arbitrary state created by subclass constructors (e.g. threshold, x_limits)
  • Continues to allow subclasses to override if they have special behaviour
  • Increases pickle coverage, and adds deepcopy coverage
  • Closes deepcopy does not work for Projections #1336

@@ -328,7 +328,7 @@ def get_proj_libraries():
else:
extras_require[section].append(line.strip())
install_requires = extras_require.pop('default')
tests_require = extras_require.pop('tests', [])
tests_require = extras_require.get('tests', [])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to pip install the test dependencies with pip install -e .[tests] rather than having to do something like python setup.py test (which I'm not 100% confident actually works).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a deprecated entry point now, so we shouldn't really rely on it, too.

@QuLogic
Copy link
Member

QuLogic commented Mar 22, 2020

Looks like you missed the license headers.

@dopplershift
Copy link
Contributor

Implementation seems reasonable enough. Not sure if we're expecting CI to fail right now.

@QuLogic QuLogic closed this Mar 26, 2020
@QuLogic QuLogic reopened this Mar 26, 2020
@QuLogic
Copy link
Member

QuLogic commented Mar 26, 2020

Going to ignore Python3 docs since that's fixed on master.

@QuLogic QuLogic merged commit 136a047 into SciTools:master Mar 26, 2020
@QuLogic QuLogic added this to the 0.18 milestone Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

deepcopy does not work for Projections
3 participants