On 3/16/2009 9:27 AM, Pearu Peterson wrote:

> If a operation produces new array then the new array should have the
> storage properties of the lhs operand.

That would not be enough, as 1+a would behave differently from a+1. The 
former would change storage order and the latter would not.

Broadcasting arrays adds futher to the complexity of the problem.

It seems necessary to something like this to avoid the trap when using f2py:

def some_fortran_function(x):
    if x.flags['C_CONTIGUOUS']:
        shape = x.shape[::-1]
         _x = x.reshape(shape, order='F')
         _y = _f2py_wrapper(_x)
         shape = _y.shape[::-1]
         return y.reshape(shape, order='C')
    else:
         return _f2py_wrapper(x)

And then preferably never use Fortran ordered arrays directly.


Sturla Molden







_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to