ndindex looks super useful. What I love is the way to abstract from the actual index type, thus being able to use integer- and slice-based indexing using the same data type. I had previously struggled in my code to convert integers i to clice(i, i+1), but that was quite confusing when printing that representation back to the user...
Speaking of the user, I have an app where they enter indices in text, and I convert their input into a slice (or Slice/Integer, soon) and use it for some computation. It would be super useful to have a function that converts strings such as 5 or :5:3 into ndindex objects, and also to print ndindex objects back into such canonical string representation.
Given an array a and user input s as above, I would expect
eval(f"a[{s}]") == a[ndindex[s]]
if that makes sense.
Also, str(ndindex[s]) (or ndindex[s].foo()) should return pretty much its input, except for canonicalization.
ndindexlooks super useful. What I love is the way to abstract from the actual index type, thus being able to use integer- and slice-based indexing using the same data type. I had previously struggled in my code to convert integersitoclice(i, i+1), but that was quite confusing when printing that representation back to the user...Speaking of the user, I have an app where they enter indices in text, and I convert their input into a slice (or Slice/Integer, soon) and use it for some computation. It would be super useful to have a function that converts strings such as
5or:5:3intondindexobjects, and also to printndindexobjects back into such canonical string representation.Given an array
aand user inputsas above, I would expectif that makes sense.
Also,
str(ndindex[s])(orndindex[s].foo()) should return pretty much its input, except for canonicalization.