A library for downstream compatibility of Numpy-compatible arrays.
Usage
For an alternative array implementation
importnumpyasnpimportarrayishasaiclassCustomArray(object):"""Your custom ``ndarray`` compatible implementation."""passdefdot(a,b,out=None)""" Your custom implementation of ``np.dot``. """pass# Between your own arraysai.dot.add((CustomArray,CustomArray),dot)# With Numpy Arrays, if you'd like. Can also pass another functionai.dot.add((np.ndarray,CustomArray),dot)ai.dot.add((CustomArray,np.ndarray),dot)
For a downstream library willing to support alternative arrays
importarrayishasaiimportnumpyasnp# Instead of this:np.dot(a,b)# Do this:ai.dot(a,b)