Adding mixed positional and keyword to PEP 637

None of the examples posted in use cases show combinations of position and keyword indexing. This feels like an important example, and moreover without it, the discussion of what sentinel to use is less motivated. In discussions, I have mentioned two examples, e.g. distances[4:7, 100:120, 30:40, unit="metres"] Which could make comparisons of arrays with different internal units easier. disributed_array[4:7, 100:120, 30:40, source="worker1"] Which works be a natural way to address data that is *eventually consistent" in a cluster. But other examples are equally good. I think a soft change in an existing example makes it a better API: molecular_energy[4:7, 100:120, 30:40, BasisSet=Z3] These all amount to basically the same thing. They are not "pure indexing" but rather delivering a slice/region of data that is described by some metadata. However, even in the "pure indexing" these types of uses seem likely: observation_region[4:7, 100:120, 30:40, measure=feature.temperature, time=start:end] observation_region[4:7, 100:120, 30:40, measure=feature.pressure, time=start:end] I.e. the underlying array is 5-D, but the spatial dimensions are unnamed (and in the hypothetical there is no inherent orientation like latitude/longitude/altitude), but the 4th and 5th axes describe the variation in which instrument is make a measurement and what timestamps each measurement was made at.

I can offer another example where the new syntax is likely to be of use to numpy. We currently have the following as synonyms: ``` np.copyto(a, b, casting='unsafe') a[...] = b ``` Obviously, it would be nice if we could allow other casting rules for `[]` assignment: ``` np.copyto(a, b, casting='safe') a[..., casting='safe'] = b ``` Eric

I can offer another example where the new syntax is likely to be of use to numpy. We currently have the following as synonyms: ``` np.copyto(a, b, casting='unsafe') a[...] = b ``` Obviously, it would be nice if we could allow other casting rules for `[]` assignment: ``` np.copyto(a, b, casting='safe') a[..., casting='safe'] = b ``` Eric
participants (2)
-
David Mertz
-
Eric Wieser