Repository navigation
Don't pass reduction kwargs to coord_func in Coarsen reductions - #11938
Open
tushar-mahalya wants to merge 1 commit into
Open
tushar-mahalya wants to merge 1 commit into
tushar-mahalya wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Coarsen reductions forward their
**kwargsto the reduction of every coordinate along a coarsened dimension, not just to the data reduction. Soda.coarsen(time=2).sum(min_count=1)raisesTypeError: nanmean() got an unexpected keyword argument 'min_count'as soon asdahas atimecoordinate.std(ddof=1)andreduce(np.std, ddof=1)fail the same way.The kwargs are meant for the data reduction, and
coord_funcis configured separately, so I removed them from the two coordinate calls inDataArrayCoarsenandDatasetCoarsen. This follows the discussion in the issue, where the suggestion for passing arguments tocoord_funcisfunctools.partial.One behaviour change:
skipnano longer reaches the coordinates either.test_coarsen_skipnaonly passedskipna=Falsethrough to a coordinate because its variable was namedxalong dimensionx, which made it the index coordinate. I renamed the variable tovso the test checks the data, which is what its comments describe. Coordinates are now reduced with theircoord_funcdefaults.Checklist
whats-new.rstAI Disclosure
Tools: Claude Code. It found the issue, wrote the fix, tests and a first draft of this description. I reviewed the diff and the reasoning, reproduced the bug and ran the tests myself.
[This PR was opened by Claude Code on behalf of Tushar Sharma, who reviewed and approved it.]