我是第一次进入SciPy LinAlg模块,并且看到了以下功能:
def _makearray(a):
new = asarray(a)
wrap = getattr(a, "__array_prepare__", new.__array_wrap__)
return new, wrap
Run Code Online (Sandbox Code Playgroud)
到底是__array_wrap__做什么的?我找到了文档,但是我不明白这个解释:
At the end of every ufunc, this method is called on the input object with the
highest array priority, or the output object if one was specified. The ufunc-
computed array is passed in and whatever is returned is passed to the user.
Subclasses inherit a default implementation of this method, which transforms the
array into a new instance …Run Code Online (Sandbox Code Playgroud)