Add cxmax and cxmin methods to Raster - #441
Open
nathanjmcdougall with Copilot wants to merge 3 commits into
Open
Add cxmax and cxmin methods to Raster#441nathanjmcdougall with Copilot wants to merge 3 commits into
nathanjmcdougall with Copilot wants to merge 3 commits into
Conversation
Add methods that return the (x, y) coordinate of the cell centre containing the maximum/minimum value in the raster, ignoring NaN values. Raises ValueError if all values are NaN. Agent-Logs-Url: https://github.com/tonkintaylor/rastr/sessions/ced63491-361a-409a-9829-c72aa72847f7 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add methods for calculating idxmax-like behaviour with coordinates
Add cxmax and cxmin methods to Raster
May 5, 2026
nathanjmcdougall
marked this pull request as ready for review
May 5, 2026 02:33
nathanjmcdougall
requested changes
May 5, 2026
| with suppress_slice_warning(): | ||
| return float(np.nansum(self.arr)) | ||
|
|
||
| def cxmax(self) -> tuple[float, float]: |
Contributor
There was a problem hiding this comment.
@copilot there's a lot of duplication between these methods. And in the future we might make it worse with cxquantile etc.
So I'd really like a shared helper, maybe named something like _cx_stat accepting a nanarg* method or equivalent
Contributor
Author
There was a problem hiding this comment.
Extracted a _cx_stat helper that accepts a nanarg* function and a name string. cxmax and cxmin are now one-liners delegating to it, so adding cxquantile etc. won't duplicate the coordinate lookup logic. See bb196fd.
Agent-Logs-Url: https://github.com/tonkintaylor/rastr/sessions/89d84575-b59c-47d4-8e0d-8fae4da252c2 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
|
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.

0 New Issues
0 Fixed Issues
0 Accepted Issues
cxmaxandcxminmethods on Raster class_cx_stathelper accepting ananarg*function to reduce duplication