Skip to content

Add cxmax and cxmin methods to Raster - #441

Open
nathanjmcdougall with Copilot wants to merge 3 commits into
developfrom
copilot/add-cxmax-cxmin-methods
Open

Add cxmax and cxmin methods to Raster#441
nathanjmcdougall with Copilot wants to merge 3 commits into
developfrom
copilot/add-cxmax-cxmin-methods

Conversation

Copilot AI commented May 5, 2026

Copy link
Copy Markdown
Contributor
  • Implement cxmax and cxmin methods on Raster class
  • Extract shared _cx_stat helper accepting a nanarg* function to reduce duplication
  • Add tests for the new methods
  • All tests pass, linting clean

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
Copilot AI requested a review from nathanjmcdougall May 5, 2026 02:19
@nathanjmcdougall
nathanjmcdougall marked this pull request as ready for review May 5, 2026 02:33
Comment thread src/rastr/raster.py
with suppress_slice_warning():
return float(np.nansum(self.arr))

def cxmax(self) -> tuple[float, float]:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@t-t-sonarqube

t-t-sonarqube Bot commented May 5, 2026

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set of methods to calculate idxmax-like behaviour

2 participants