[Numpy-discussion] A matrix user in the land of arrays

Robert Kern robert.kern@gmail....
Fri May 9 13:43:34 CDT 2008


On Fri, May 9, 2008 at 1:41 PM, Keith Goodman <kwgoodman@gmail.com> wrote:
> That looks good. But at the end of the function I'll have to convert
> back to a 1d array if the input is 1d
>
> np.whence_you_came_from(x)
>
> I guess there is no way to not test for the shape.

Well, in this case, since you are modifying the data in-place, just
return the original array.

x2 = atleast_2d(x)
x2[i,j] = something
return x

-- 
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