On 17.07.20 22:11, Todd wrote:
On Fri, Jul 17, 2020 at 12:19 PM David Mertz <mertz@gnosis.cx <mailto:mertz@gnosis.cx>> wrote:
Fwiw, I'm probably -0 on the feature itself. Someone suggested it could be useful for xarray, but I'm not sure now what that would look like. If someone had an example, I could easily be moved.
Here is what it currently looks like to assign values to indices in xarray (adapted from a tutorial):
ds["empty"].loc[dict(lon=5, lat=6)] = 10
This could be changed to:
ds["empty"][lon=5, lat=6] = 10
This becomes even a bigger advantage if we include slicing, which I think we should:
ds["empty"].loc[dict(lon=slice(1, 5), lat=slice(3, None))] = 10
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. Only when positional and keyword arguments are mixed, it becomes difficult to distinguish (for both the reader and the method).
to
ds["empty"][lon=1:5, lat=6:] = 10