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

FIX: bypass inverse in collection#17206

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

Conversation

jklymak
Copy link
Member

PR Summary

I think thisfixes#17203. If anyone has a dev environment where#17203 is triggered can you test this? It bypasses transforming the offsets if the offset transform and the data transform are the same.

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@jklymakjklymakforce-pushed thefix-bypass-inverse-collection branch from5f878c1 to20ab0faCompareApril 22, 2020 00:43
@jklymakjklymakforce-pushed thefix-bypass-inverse-collection branch from20ab0fa to229b49eCompareApril 22, 2020 01:10
@jklymakjklymakforce-pushed thefix-bypass-inverse-collection branch from229b49e toa53833eCompareApril 22, 2020 01:13
@QuLogic
Copy link
Member

QuLogic commentedApr 22, 2020
edited
Loading

This works for me,though it appears tests are not happy about it. Never mind, seems you've pushed a fix.

jklymak reacted with thumbs up emoji

Copy link
Member

@dstansbydstansby left a comment

Choose a reason for hiding this comment

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

👍 works for me, thanks for the quick investigation and fix!

jklymak reacted with thumbs up emoji
@jklymakjklymak added this to thev3.2.2 milestoneApr 22, 2020
@anntzer
Copy link
Contributor

anntzer commentedApr 22, 2020
edited
Loading

Untested, but I think something along the lines of the following may work too, be simpler, and cover more cases?

diff --git i/lib/matplotlib/collections.py w/lib/matplotlib/collections.pyindex 181e46b45..55a681000 100644--- i/lib/matplotlib/collections.py+++ w/lib/matplotlib/collections.py@@ -211,8 +211,6 @@ class Collection(artist.Artist, cm.ScalarMappable):             # we may have transform.contains_branch(transData) but not             # transforms.get_affine().contains_branch(transData).  But later,             # be careful to only apply the affine part that remains.-        if not transOffset.is_affine:-            offsets = transOffset.transform_non_affine(offsets)          if isinstance(offsets, np.ma.MaskedArray):             offsets = offsets.filled(np.nan)@@ -226,7 +224,8 @@ class Collection(artist.Artist, cm.ScalarMappable):                 # also use this algorithm (like streamplot).                 result = mpath.get_path_collection_extents(                     transform.get_affine(), paths, self.get_transforms(),-                    offsets, transOffset.get_affine().frozen())+                    transOffset.transform_non_affine(offsets),+                    transOffset.get_affine().frozen())                 return result.transformed(transData.inverted())             if not self._offsetsNone:                 # this is for collections that have their paths (shapes)@@ -234,14 +233,13 @@ class Collection(artist.Artist, cm.ScalarMappable):                 # (i.e. like scatter). We can't uniquely set limits based on                 # those shapes, so we just set the limits based on their                 # location.-                # Finish the transform:-                offsets = (transOffset.get_affine() +-                           transData.inverted()).transform(offsets)+                offsets = (transOffset - transData).transform(offsets)                 offsets = np.ma.masked_invalid(offsets)                 if not offsets.mask.all():                     points = np.row_stack((offsets.min(axis=0),                                            offsets.max(axis=0)))                     return transforms.Bbox(points)+         return transforms.Bbox.null()      def get_window_extent(self, renderer):

The point is thattransOffset - transData will check whether transOffset and transData contain the same subtransform and if so will cancel them out exactly (that's howTransform.__sub__ is implemented). So this would work even if e.g.transOffset = someothertransform + transData or whatnot.

@jklymak
Copy link
MemberAuthor

Ireally don't understand why transforms were implemented withadd andminus to really mean multiplication and multiplication by the inverse. Worse, these operators are, as far as I can tell,completely undocumented. So I'm not in favour of adding them to the code until this situation improves.

@dstansby
Copy link
Member

Ireally don't understand why transforms were implemented withadd andminus to really mean multiplication and multiplication by the inverse. Worse, these operators are, as far as I can tell,completely undocumented. So I'm not in favour of adding them to the code until this situation improves.

Woah, that is confusing! I was looking at your changelog and got really confused with what was happening because it never crossed my mind that + could ever mean multiplying two transformations together.

@jklymak
Copy link
MemberAuthor

I should stipulate that__sub__ and__add__ are documented, but as far as I can tell they don't come up in the webpage docs.

@anntzer
Copy link
Contributor

There was one transform operator in the code before (an addition:transOffset.get_affine() + transData.inverted()); there's still one in my proposed patch (transOffset - transData), so in that sense it doesn't make things worse. And my proposed patch avoids splitting the affine and non-affine parts of transOffset unless we really need to do it.

As to why multiplication and division are implemented as addition and subtraction: I didn't make that choice so I can't tell, but it's not a completely silly choice either. In particular, if you follow the matrix multiplication semantics, you'd haveA + B [current] === B * A [matrix], i.e. apply B then A. But then you simply don't have a good way to writeA - B (apply A then the inverse of B) because there's no leftdivide in python. Sure you could write(1/B) * A but then it becomes much more awkward to get the "enforced cancelling" whenA = B (unless1/B returns a special object which knows its inverse), and even then(1/B) * A (orB**-1 * A) doesn't read that nicely either.

@jklymak
Copy link
MemberAuthor

There was one transform operator in the code before

Ha ha, guess why?

I've implement it with the minus sign and put a comment. The extra code intransform to handle the inverse properly does seem quite helpful.

@jklymak
Copy link
MemberAuthor

... added a simple test as well..

@jklymakjklymak added the Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labelApr 27, 2020
@anntzeranntzer merged commitf091a4d intomatplotlib:masterApr 27, 2020
@lumberbot-app
Copy link

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout v3.2.x$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 f091a4d92e0a73e702e15c172c884d35c9a478a2
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #17206: FIX: bypass inverse in collection'
  1. Push to a named branch :
git push YOURFORK v3.2.x:auto-backport-of-pr-17206-on-v3.2.x
  1. Create a PR against branch v3.2.x, I would have named this PR:

"Backport PR#17206 on branch v3.2.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free tosuggest an improvement.

@jklymak
Copy link
MemberAuthor

OK, I have real troubles manually backporting:

$ git checkout v3.2.xerror: pathspec 'v3.2.x' did not match any file(s) known to git

Like maybe this PR isn't worth back porting, but the instructionsused to work

@kannes
Copy link

OK, I have real troubles manually backporting:

$ git checkout v3.2.xerror: pathspec 'v3.2.x' did not match any file(s) known to git

Like maybe this PR isn't worth back porting, but the instructionsused to work

Works fine for me on a fresh git clone, maybe you need tofetch the remote branch to your repo?

QuLogic added a commit that referenced this pull requestApr 27, 2020
…3.2.xMerge pull request#17206 from jklymak/fix-bypass-inverse-collection
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@anntzeranntzeranntzer approved these changes

@dstansbydstansbydstansby approved these changes

@ImportanceOfBeingErnestImportanceOfBeingErnestAwaiting requested review from ImportanceOfBeingErnest

Assignees
No one assigned
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Milestone
v3.2.2
Development

Successfully merging this pull request may close these issues.

Subplots using bad axis limits in 3.2
5 participants
@jklymak@QuLogic@anntzer@dstansby@kannes

[8]ページ先頭

©2009-2025 Movatter.jp