[SciPy-dev] ticket 464

Alan G Isaac aisaac@american....
Thu Jul 26 10:33:15 CDT 2007


On Thu, 26 Jul 2007, dmitrey apparently wrote:
>     rank = len(x.shape)
>     if not -1 < rank < 2:
>         if x.shape == (1,1): x = x.flatten()#matrix(0.3) for example
>         else: raise ValueError, "Initial guess must be a scalar or
> rank-1 sequence."

That won't work.  A flattened matrix is still a matrix.
But you can work with the flatiter representation.

    if max(x.shape) == 1: x = x.flat.next()

Cheers,
Alan Isaac






More information about the Scipy-dev mailing list