[SciPy-dev] ticket 464
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,
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
So I had checked - it works
> But you can work with the flatiter representation.
> if max(x.shape) == 1: x = x.flat.next()
> Alan Isaac
> Scipy-dev mailing list
More information about the Scipy-dev