-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Deprecate offset_position="data". #13696
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
Conversation
In general, this makes sense to me. Is there anything that would speak against making |
I would strongly doubt that there are many users of offset_position="data". But if you're worried about this we can replace the Deprecation by a PendingDeprecation, as usual. (On the other hand, seeing whether we get complaints or not is also one of the points of the deprecation period.) |
Even if the amount of users hit by this isn't massive, it's still not the right policy to first break something and then wait if someone complains. Often enough, people might just be frustrated without opening an issue about it. In this case I think that the functionality of an offset transform in data coordinates is in general useful. I would agree that this does not require an additional argument, but should be incorporated into the transform itself. So removing |
The changelog entry can mention e.g. "if you need this functionality, you can vendor the implementation of _VectorTransform" (which is quite short if you don't bother with I simply disagree that we can never deprecate things on the basis that someone may possibly be using them; as always there is a cost-benefit ratio that needs to be considered, and certainly if someone actually complains about it we'll consider it more. |
(Some notes mostly to self: there's already transforms.offset_copy and text.OffsetFrom on the same theme.) |
8cba46e
to
87a5d54
Compare
@anntzer If I understand correctly, hexbin could be implemented without |
The problem is that without _VectorTransform (I'm not particularly in love with the name), collections (or more specifically, _CollectionWithSizes, which PolyCollection (the class returned by hexbin()) inherits) will by default size their components (the hexagons, in this case) to have a size in physical units (points), whereas we want to have them in data units, which is what _VectorTransform achieves. (Previously, this had to be built in to every renderer class, _VectorTransform just factors out that functionality.) We could instead use PatchCollection, which just takes a bunch of patches and plots them as is (see e.g. the very recent thread on the mailing list https://mail.python.org/pipermail/matplotlib-users/2019-May/001663.html); however such an approach would at least lead to more inefficient vector output because the vector file would need to include every hexagon on every point, rather than a single hexagon and encode a list of offsets. In fact, this is the very reason why offset_position exists (#859); that PR indicates that just dropping the amount of data sent from python to agg also significantly accelerates agg. |
Pushing out to 3.3 as I think this needs to be understood a bit better still. It also looks like we currently have the ability to cycle through data transfroms (?!) and there is no documented path for a user who was directly creating the collection and passing |
87a5d54
to
47d0dcd
Compare
a82cd8c
to
9ebea41
Compare
I would like to reiterate the possibility to make
That option is gone if |
9ebea41
to
791f09f
Compare
OK, I made VectorTransform public, but marked it as experimental to allow for later changes depending on actual use.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modulo my question about more agressively calling _unstale_viewLim
.
lib/matplotlib/transforms.py
Outdated
@@ -2612,6 +2612,26 @@ def get_matrix(self): | |||
return self._mtx | |||
|
|||
|
|||
class VectorTransform(Affine2DBase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I‘m not quite happy with the name. „Vector“ has a lot of semantics, but IMHO only a loose connection to „no offset“. Some possible alternatives:
WithoutOffsetTransform
RotationOnlyTransform
IgnoreOffsetTransfrom
Possibly even with an ...Wrapper
suffix to indicate that this modifies / builds upon another transform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I picked vector as it's meant to transform the delta vector between a pair of points, rather than individual points (I agree this may not be obvious). Ignore/WithoutOffset seems to hide the relevant semantics to me and focus more on how they are achieved, and RotationOnly is wrong as there can also be stretch.
I'm open to changing the name, though.
Can you paraphrase that semantics (maybe even directly in the docstring)? I think I probably haven't fully understood
And that's what I've been trying to pick up for the name. That description and the name |
459461c
to
234c905
Compare
Edited the docstring, does this look better? |
Thanks, the extended description looks good. I still feel a mismatch between the class name and the summary line. IMHO they should be on the same level of abstraction. So either
or
I think that, more precisely, the vectors you think of are direction vectors (in contrast to position vectors). Maybe |
234c905
to
5d07a88
Compare
Ah, I see the confusion now. Yes, I meant https://en.wikipedia.org/wiki/Displacement_(geometry), not https://en.wikipedia.org/wiki/Position_(geometry). Pushed a new version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring is good now. I would like to have a second opinion on the name VectorTransform
, which I still find too broad.
DifferenceTransform? DeltaTransform? SizeAndShapeTransform? I'm struggling. It would really be nice to have a name that would be highly evocative--which for me, VectorTransform still is not. It seems that the zeroing of the offset really is the key to understanding what the wrapper is doing. So I tend to favor ZeroOffsetTransform, or NoOffsetTransform, or something like that. Or, if you want to include the mathematical property, it would be DistributiveTransform, since it is modifying a transform to make it distributive with respect to addition. |
DisplacementTransform? OffsetTransform? |
Let‘s briefly discuss in the call. |
I don't believe this came up in any call; I've put it on the agenda for next week (though we might not get to it.) |
On call we settled on |
renamed |
5d07a88
to
df5db91
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bonus points if you have an idea how to sneak the word „delta“ into the docstring. That would make the name even more clear (I know that you‘ve not chosen it). 😄
df5db91
to
4728c32
Compare
done, as "position deltas". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyone can merge on CI green.
4728c32
to
4931a12
Compare
The `offset_position` property of collections is currently set to "data" only for hexbin(), but one can do away with it by just setting the correct offsetTrans instead -- which this PR does. The advantage of doing so is that the correct offsetTrans only needs to be implemented once, whereas support for `offset_position` needs to be implemented for each renderer class separately (including at the C-level for the Agg backend). Note that the *offset_position* argument to `draw_path_collection` is not pending removal because its removal would require coordination with third-party backends; the plan is to just always set it to "screen" after the deprecation period. AffineDeltaTransform can be used as a replacement for `offset_position="data"`. This API is experimental.
rebased |
4931a12
to
4a569ce
Compare
Travis reporting seems broken; there are not currently any builds running. |
The
offset_position
property of collections is currently set to "data"only for hexbin(), but one can do away with it by just setting the
correct offsetTrans instead -- which this PR does. The advantage of
doing so is that the correct offsetTrans only needs to be implemented
once, whereas support for
offset_position
needs to be implemented foreach renderer class separately (including at the C-level for the Agg
backend).
Note that the offset_position argument to
draw_path_collection
isnot pending removal because its removal would require coordination with
third-party backends; the plan is to just always set it to "screen"
after the deprecation period.
If there is demand for it, _VectorTransform could be made a public API.
TLDR: hexbin() currently (effectively) uses its own code-path in renderer code, but that's not needed.
Edit: closes #16461 and (effectively) #16496
PR Summary
PR Checklist