[SciPy-User] scalars vs array of length 1

Sturla Molden sturla@molden...
Thu Jul 8 15:59:42 CDT 2010


Victor Eijkhout skrev:
> How do I get that shape to be the same in both cases?
>   
x = (x,) if np.isscalar(x) else x

Scalars are not iterable, which is why

    array([cos(x),sin(x),tan(x)])

 becomes a vector if x is scalar.




More information about the SciPy-User mailing list