Skip to content

Why must lat=slice() arguments be decreasing? #6327

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

Closed
brianmapes opened this issue Mar 3, 2022 · 2 comments
Closed

Why must lat=slice() arguments be decreasing? #6327

brianmapes opened this issue Mar 3, 2022 · 2 comments
Labels
needs triage Issue that has not been reviewed by xarray team member

Comments

@brianmapes
Copy link

What is your issue?

Many meteorological grids seem to have latitude decreasing. I am constantly forgetting this, and getting garbled results when I use slice(lat1,lat2). I can't think of any use case for which this slice ordering needs to be such a pitfall. Couldn't slice.py be set up to return the indicated interval, no matter which order the arguments are passed?

Would any user have any meaningful analysis fail if this convenience were programmed in to slice.py?

"Indexing axes with monotonic decreasing labels also works, as long as the slice or .loc arguments are also decreasing"

(Forgive a first-timer if this is the wrong place/format for this question. I searched past issues for slice and order and found no existing issue.)

@brianmapes brianmapes added the needs triage Issue that has not been reviewed by xarray team member label Mar 3, 2022
@keewis
Copy link
Collaborator

keewis commented Mar 3, 2022

see #1613 for a pretty thorough discussion. Very short summary: we inherit this behavior from pandas

@dcherian
Copy link
Contributor

dcherian commented Mar 3, 2022

@brianmapes could you comment on that thread with your opinion of a new xr.Between object that would explicitly ignore underlying coordinate order.

In the mean time I'm closing this issue as a duplicate of #1613

@dcherian dcherian closed this as completed Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue that has not been reviewed by xarray team member
Projects
None yet
Development

No branches or pull requests

3 participants