[SciPy-dev] ticket 464

dmitrey openopt@ukr....
Thu Jul 26 12:30:58 CDT 2007


Alan G Isaac wrote:
> 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.
>   
the matrix is converted to array before the check:
def fmin_powell(func, x0, args=(), xtol=1e-4, ftol=1e-4, maxiter=None,
                maxfun=None, full_output=0, disp=1, retall=0, callback=None,
                direc=None):
...
    x = asfarray(x0).copy()
...
    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."
So I had checked - it works

Regards, D
> But you can work with the flatiter representation.
>
>     if max(x.shape) == 1: x = x.flat.next()
>
> Cheers,
> Alan Isaac
>
>
>
>
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-dev
>
>
>
>   



More information about the Scipy-dev mailing list