[Numpy-discussion] Automatic matrices
Robert Kern
robert.kern at gmail.com
Fri Dec 15 21:49:49 EST 2006
Keith Goodman wrote:
> But are there any unintended consequences of changing from array to asanyarray?
Not by itself, no. That entails that the implementations cannot rely on any
particular behavior of the arrays. The correct(ish) approach looks something
like the following, I believe:
def foo(input):
input_arr = asanyarray(input)
wrapper = input_arr.__array_wrap__
input_arr = asarray(input_arr)
# Do stuff on input_arr to get output_arr (an ndarray).
return wrapper(output_arr)
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the NumPy-Discussion
mailing list