-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[WIP] Add the ability for unit converters to convert back to data with units #12270
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
Many of the converters convert from different units to matplotlib values. I.e. the date converters. So how will you invert if the inversion is non-unique? As pointed out a few times, I think any co-ordinate that gets unitized should go ahead and be converted, but we should pack the original in w/ the conversion. Then we can always get back to where we started. I.e. |
Can you give an example of the different date units? The way I've set it up, doing how the back-conversion is done is entirely up to the implementation of the Although that is potentially a good idea, it doesn't cover cases where the conversion back is not being done on a data point, e.g. |
3e22cfc
to
78dda48
Compare
The date converter will accept More to the point, if we change the units of the axis, inverting and then re-converting is not garaunteed to be correct if we don't get the original data. I'm not sure I follow the xlim/ylim issue. I don't see any reason xlim/ylim can't be wrapped in the same way as other data. |
That makes sense; we can just make different copies of each |
e50d728
to
79acf30
Compare
ec80e48
to
15ddfa9
Compare
Still needs:
|
61c05d2
to
67bde14
Compare
22f7fed
to
5449bcd
Compare
54c996e
to
3e837dd
Compare
985b499
to
35a73a2
Compare
35a73a2
to
fc958e6
Compare
@dstansby, I think this should be discussed more before more work is done. As I understand it, the plan for 4.0 is to have a new way of carrying the data around inside Matplotlib. That may be a pipe dream, in which case something like this may be a good half measure, but we should make sure this fits in the roadmap? @dopplershift @tacaswell were particularly interested in better units support. |
Thanks for pointing that out - is there a roadmap for 4.0 or anything written down anywhere about the changes to data-carrying? Either way I'm kind of happy to carry on playing with this and writing it up on a zero-merge-expectation basis. |
That seems reasonable. There is a paper document. https://paper.dropbox.com/doc/Matplotlib-4.0-WTYwd0NQaSHTjtLUZwkNx |
I think there's another version of this kicking around somewhere, and it's clear that something like this needs some more careful thought and design, so I'm going to close this. |
Inspired by #7462, and not-so-recent units discussions on the mailing list, I have made a minimal implementation of having an
un_convert
method forConversionInterface
classes. The benifit of this is that Matplotlib can re-convert from "axis coordinates" to "data/unit coordinates", and return data with units. This is particularly useful for things likeginput
.I will write this up more in the future, but for to keep a paper trail this is a pre-requisite for a
accepts_units
decorator (see #10411 for an attempt at this) that would automatically catch issues such as #15332 ,