| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
Sorry, something went wrong.
| self._functions = functions | ||
| elif isinstance(functions, Transform): | ||
| self._functions = ( | ||
| functions.transform, functions.inverted().transform) |
There was a problem hiding this comment.
This is dangerous, as Transform.inverted returns a copy with a snapshot of the transform, and thus won't be in sync if the input transform changes. Instead, you'd probably want (identity - input).
Sorry, something went wrong.
There was a problem hiding this comment.
I agree, but is it preferable to implicitly allow arguments to be mutated after the fact as a side effect at all? I.e., would a better way to ensure consistency be to simply copy the passed transform to begin with? Let me know which way to go (not sure if there's precedent here)
Sorry, something went wrong.
There was a problem hiding this comment.
Yes, we tend to be lazily evaluated, e.g., if we had Axes.transData here, it might change depending on limits (though of course that specific transform won't work here, being 2D, and as you've noted above this argument is 1D.)
Sorry, something went wrong.
There was a problem hiding this comment.
Actually, I'm not finding that to be the case (that subtraction avoids inconsistency upon mutation), at least with the Translation class I defined:
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
class Translation(mtransforms.Transform):
input_dims = 1
output_dims = 1
def __init__(self, dx):
self.dx = dx
def transform(self, values):
return values + self.dx
def inverted(self):
return Translation(-self.dx)
forward = Translation(1)
backward = mtransforms.IdentityTransform() - forward
print(forward.transform(1), backward.transform(1))
forward.dx = 2
print(forward.transform(1), backward.transform(1))prints
2 0 3 0
Reviewing Transform.__sub__, I can't actually say I understand how lazy inversion ever occurs... let me know what you think.
Sorry, something went wrong.
There was a problem hiding this comment.
But your test is wrong? The second printout should be 3 -1, if backward and forward are linked (which is what we want here, since the user only supplied the forward transform.)
Sorry, something went wrong.
There was a problem hiding this comment.
That's my point - forward and IdentityTransform() - forward are not linked, and I don't see any mechanism for that operation being lazy in Transform.__sub__.
Sorry, something went wrong.
There was a problem hiding this comment.
Oh, I see what you're saying now. Yes, I misremembered what happened there. What you will have to do is put a lambda in that calculates the inverse when it's called.
Sorry, something went wrong.
There was a problem hiding this comment.
Clever - 2803407
Sorry, something went wrong.
|
The coverage drop is because it is missing some of the uploads (it is only seeing 5, should be atlesat 9). |
Sorry, something went wrong.
|
Thank you for you work @zachjweiner and congratulations on your first merged PR to Matplotlib 🎉 We hope to hear from you again. |
Sorry, something went wrong.
|
Cheers, thanks! (and thanks @QuLogic for iterating on this!) |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR summary
Closes #25691 and adds a test.
First contribution to matplotlib, so please let me know if I've missed anything.
PR checklist