-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add support for coordinate inputs in polyfit. #9369
Merged
Merged
Changes from 4 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
81c1e01
Update polyfit to work with coordinate inputs.
Karl-Krauth f9d968c
Test whether polyfit properly handles coordinate inputs.
Karl-Krauth 2aef0a1
Document polyfit coordinate fix in whats-new.rst.
Karl-Krauth 2a5d6b9
Update get_clean_interp_index's use_coordinate parameter to take a ha…
Karl-Krauth c1dccd5
Replace call to get_clean_interp_index with inline coversion code in …
Karl-Krauth 8248875
Merge remote-tracking branch 'upstream/main' into polyfit-coords
Karl-Krauth a416146
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d5a842e
Declare x as Any type in polyfit.
Karl-Krauth 3fbb437
Merge branch 'polyfit-coords' of github.com:Karl-Krauth/xarray into p…
Karl-Krauth 2dd1bc4
Merge branch 'main' into polyfit-coords
Karl-Krauth a169fe4
Add polyfit output test.
Karl-Krauth 01e7f3a
Use floatize_x to convert coords to floats in polyfit.
Karl-Krauth 5ee4fed
Merge branch 'polyfit-coords' of github.com:Karl-Krauth/xarray into p…
Karl-Krauth 8eddf53
Merge branch 'main' into polyfit-coords
Karl-Krauth feaa1ad
Update dataset.py
Karl-Krauth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This code is a bit strange. I think the
get_clean_interp_index
evolved in a way that makes it not match its signature and doc.Argument "dim" of
get_clean_interp_index
is documented as "Name of the dimension", yet here the name of the coordinate is passed (which might not be a dimension, that's the point). However, thedim
argument has no impact whatsoever on the the result of the function ifuse_coordinate
is a string.Also, the docstring of
use_coordinate
does not mention what happens when a string is passed.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.
Agreed that it is strange, in an ideal world I think the
dim
argument could be either a coordinate or a dimension, anduse_coordinate
just wouldn't be necessary. But I didn't want to change theget_clean_interp_index
signature too much since it seemed to match the publicinterpolate_na
API quite closely, which I'm not familiar with.I also didn't set the
dim
argument toNone
because there seemed to be some downstream use of that variable in the case where the resulting index is a DatetimeIndex.Maybe as a half measure I could update the documentation of
get_clean_interp_index
in this PR to match more closely what the code is actually doing?Alternatively, I could just inline the behaviour of
get_clean_interp_index
that we're actually using since that function seemed to be designed for a different purpose anyway.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.
This would be great if it's a simple add
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.
Done :) although mypy complained at me initially for reassigning
x
to different types. I'm not sure how precise this project wants all its types to be so for now I've just declaredx
asAny
for the sake of brevity.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.
FYI: I am currently working on improvements of
interpolate_na
and discovered similar issues withget_clean_interp_index
. I tried to come up with an improved (and type safe) version of it (see here). However, good to know that polyfit is now independent, in this caseget_clean_interp_index
is only used within missing.py. I will try to write a better docstring for the function before merging.