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

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

Already on GitHub?Sign in to your account

Closed
dstansby wants to merge5 commits intomatplotlib:masterfromdstansby:un-convert

Conversation

@dstansby
Copy link
Member

@dstansbydstansby commentedSep 25, 2018
edited
Loading

Inspired by#7462, and not-so-recent units discussions on the mailing list, I have made a minimal implementation of having anun_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 aaccepts_units decorator (see#10411 for an attempt at this) that would automatically catch issues such as#15332 ,

@jklymak
Copy link
Member

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.x=dict(orig=Xorig, converted=currentconversion)

@dstansby
Copy link
MemberAuthor

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 theConversionInterface. If needed, what is returned can depend on theunits attribute of the axis, which can change from e.g.m tocm.

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.xlim/ylim are almost never the same as an actual data point passed in.

@dstansbydstansbyforce-pushed theun-convert branch 3 times, most recently from3e22cfc to78dda48CompareSeptember 25, 2018 17:06
@jklymak
Copy link
Member

The date converter will acceptdatetime.datetime,datetime.date andnumpy.datetime64 right now. If we convert to ordinal (days since epoch) as we do now, how will we know the correct inversion? Practically this could have an effect if the user overrides the datetime64 conversion, but not the datetime.datetime, and converts, but then the inversion puts the date back in datetime units.

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.

@dstansby
Copy link
MemberAuthor

That makes sense; we can just make different copies of eachConversionInterface, that inherit everything from aDateConverter, but just have different methods to convert the units back.

@dstansbydstansbyforce-pushed theun-convert branch 3 times, most recently frome50d728 to79acf30CompareSeptember 26, 2018 09:28
@dstansbydstansby changed the titleAdd the ability for unit converters to convert back to data with units[WIP] Add the ability for unit converters to convert back to data with unitsSep 26, 2018
@dstansbydstansbyforce-pushed theun-convert branch 2 times, most recently fromec80e48 to15ddfa9CompareOctober 2, 2018 09:42
@dstansby
Copy link
MemberAuthor

Still needs:

  • API changes (or what's new?)
  • Separate un-converters for each of the date types

@jklymakjklymak modified the milestones:v3.1.0,v3.2.0Feb 26, 2019
@dstansbydstansbyforce-pushed theun-convert branch 2 times, most recently from61c05d2 to67bde14CompareMay 24, 2019 14:55
@dstansbydstansbyforce-pushed theun-convert branch 2 times, most recently from22f7fed to5449bcdCompareJuly 22, 2019 08:04
@dstansbydstansby modified the milestones:v3.2.0,v3.3.0Aug 17, 2019
@dstansbydstansbyforce-pushed theun-convert branch 2 times, most recently from54c996e to3e837ddCompareAugust 17, 2019 10:46
@dstansbydstansbyforce-pushed theun-convert branch 3 times, most recently from985b499 to35a73a2CompareSeptember 27, 2019 11:39
@jklymak
Copy link
Member

@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.

@dstansby
Copy link
MemberAuthor

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.

@jklymak
Copy link
Member

That seems reasonable. There is a paper document.https://paper.dropbox.com/doc/Matplotlib-4.0-WTYwd0NQaSHTjtLUZwkNx

@QuLogicQuLogic modified the milestones:v3.3.0,v3.4.0May 2, 2020
@jklymakjklymak marked this pull request as draftJuly 23, 2020 16:34
@dstansby
Copy link
MemberAuthor

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.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@dstansby@jklymak@QuLogic@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp