Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Make all transforms copiable (and thus scales, too).#19281

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
timhoffm merged 1 commit intomatplotlib:masterfromanntzer:copiable-transforms
Jan 17, 2021

Conversation

anntzer
Copy link
Contributor

PR Summary

Closes#18119; more general than#18126?

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings and runflake8 --docstring-convention=all).
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

Copy link
Member

@timhoffmtimhoffm left a comment
edited
Loading

Choose a reason for hiding this comment

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

AFAICS the tests do not test the behavioral difference between copy and deepcopy. The specific behavior of both should be exercised in the tests.

Copy link
Member

@jklymakjklymak left a comment

Choose a reason for hiding this comment

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

This looks like it would be good if it is robust. I'm still not clear what is going on well enough to review it though - what happens when people start using these copies in the wild? Also, what is the difference withtransform.frozen()?

# propagate back to `c`, i.e. we need to clear the parents of `a1`.
other._parents = {}
# If `c = a + b; c1 = deepcopy(c)`, this creates a separate tree
# (`c1 = a1 + b1`) so nothing needs to be done.
Copy link
Member

Choose a reason for hiding this comment

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

OK, so with a deepcopy the tranform is frozen, or at least to the point where someone would need to dig out the children? Does thecopy.deepcopy above really copy the children over?

@anntzer
Copy link
ContributorAuthor

I agree tests are needed. I'll work on these in the coming days...

timhoffm and jklymak reacted with thumbs up emoji

@jklymakjklymak marked this pull request as draftJanuary 12, 2021 20:40
@anntzeranntzerforce-pushed thecopiable-transforms branch 2 times, most recently fromf9f8d41 to3a63e5eCompareJanuary 15, 2021 10:35
@anntzer
Copy link
ContributorAuthor

Now with tests...

@anntzeranntzer marked this pull request as ready for reviewJanuary 15, 2021 10:35
Copy link
Member

@jklymakjklymak left a comment

Choose a reason for hiding this comment

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

Thisseems fine to me. Has the desired effect of making norms copy-able. I don't think it will have any negative consequences for end-users, though I don't now all the ways our users might use transforms....

def test_scale_deepcopy():
sc = mscale.LogScale(axis='x', base=10)
sc2 = copy.deepcopy(sc)
assert str(sc.get_transform()) == str(sc2.get_transform())
Copy link
Member

Choose a reason for hiding this comment

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

As a rough check that there is no shared state, I'd add

assert sc._transform is not sc2._transform

or, if you're uncomfortable with testing private attributes:

assert sc.get_transform() is not sc2.get_transform()

But personally, I'd test the internal state here, becauseget_transform()could be written to return copies, so that testingget_transform() include an additional assumption.

Copy link
ContributorAuthor

@anntzeranntzerJan 17, 2021
edited
Loading

Choose a reason for hiding this comment

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

yes (although this revealed the need to separately implementdeepcopy for transforms that just return self in frozen()).

Copy link
Member

Choose a reason for hiding this comment

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

👍 The test found an implementation flaw. It's working 😄

@timhoffmtimhoffm added this to thev3.4.0 milestoneJan 17, 2021
@timhoffmtimhoffm merged commitf72adc4 intomatplotlib:masterJan 17, 2021
@anntzeranntzer deleted the copiable-transforms branchJanuary 17, 2021 22:11
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jklymakjklymakjklymak approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.4.0
Development

Successfully merging this pull request may close these issues.

Can no longer deepcopy LogNorm objects on master
3 participants
@anntzer@jklymak@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp