On Sun, Jul 19, 2020 at 6:35 PM Dominik Vilsmeier <dominik.vilsme...@gmx.de> wrote:
> But this looks unnecessarily complicated. Why can't xarray allow the > following: > > ds["empty"]["lon", 1:5, "lat", 3:] = 10 > > which looks very close to the proposed syntax below. Not that I'm against > the proposal but I think that any use case involving *only* keyword > arguments isn't a very strong one, because it can easily be solved that way > without a change to existing syntax. > Xarray already allows positional slices in multiple dimensions. The existing dict weirdness is to have a way to introduce the named dimensions. But suppose that the array in question had a first listed 'altitude'. I think nowadays, we can write: arr.loc[50:60, 1:5, 3:] If we only reference dimensions by number not by name. Under the "commas separate keys from values" this would be difficult: arr.loc[50:60, "lon", 1:5, "lat", 3:] Yes, I can imagine a rule like "If it is a slice that wasn't preceded by a string, treat it as positional, otherwise if it is a string treat it as a key, but treat the next thing after a string as the slice value corresponding to that key." That seems more error prone and harder to grok than the potential: arr.loc[50:60, lon=1:5, lat=3:] Where you'd still just have to know that "axis 0 is altitude" of your particular array.
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/XNJL45PE6DFYTMB6SUYESPG5HNY62A4I/ Code of Conduct: http://python.org/psf/codeofconduct/