[Numpy-discussion] buggy fortran array reshape ?

Fabrice Pardo Fabrice.Pardo at Lpn.cnrs.fr
Wed Apr 22 13:13:10 EDT 2009


After reshaping a Fortran array, the new array doesn't share data
with original array.
I will be glad if someone can explain the strange behaviour of this
program. Is it a numpy bug ? 

#vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
def check_bug(order):
    a = numpy.ndarray((3,2),order=order,dtype=int)
    a[0,0] = 1
    b = a.reshape((6,))
    a[0,0] = 2
    print b[0]

check_bug('C') # 2, good
check_bug('F') # 1, wrong ???
print(numpy.version.version) # 1.2.1
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

-- 
FP




More information about the NumPy-Discussion mailing list