I have the following problem: I wish to create and use numpy array with slight change in operator []. I understand so far it is done by the method __getitem__(self, index). However I am unable to figure how to do it so I declare an array that is "numpy array" in every aspect except of that one issue (say for sake of example I want array[i] to be interpreted as array[i-1]
I tried to solve it following way:
class myarray(np.ndarray):
def __getitem__(self, index):
    return self[index+1]
k = np.linspace(0, 10, 10).view(myarray)
though it's not really working
array = array[1:]?ndarrayis a complicated task. See the code fornp.matrixor masked array to see how involved that is. I'd start with a set of functions that manipulate an array in the desired way. Develop a class only when it is clear that that will make your code clearer.lib.index_tricks.pyfile to get ideas on how use indexing syntax.