Make Class Convertable To Ndarray
Other than by subclassing (from list for example) how do I make a python object implicitly convertable to ndarray? Example: import numpy arg=[0,1,2] numpy.dot(arg,arg) # OK, arg is
Solution 1:
__len__
seems to be the key feature: just adding a
def__len__(self):
return3
made the class work in numpy.dot
.
Post a Comment for "Make Class Convertable To Ndarray"