Relative Content

Tag Archive for pythonnumpyclassadditionnumpy-ndarray

Different behavior in custom class between left addition/right addition with a numpy array

I am writing a class where one of the stored attributes is cast to an integer in the constuctor. I am also overloading left/right addition, where adding/subtracting an integer means to shift this attribute over by that integer. In principle, addition commutes in all contexts with my class, so as a user I would not expect there to be any difference between left and right addition.

Different behavior in custom class between left addition/right addition with a numpy array

I am writing a class where one of the stored attributes is cast to an integer in the constuctor. I am also overloading left/right addition, where adding/subtracting an integer means to shift this attribute over by that integer. In principle, addition commutes in all contexts with my class, so as a user I would not expect there to be any difference between left and right addition.