Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 8fa1e4296360f3be1a3b549c79f675b4 > files > 998

numpy-1.4.1-6.fc14.x86_64.rpm

>>> import pytest
>>> import f2pytest
>>> import pyforttest
>>> print f2pytest.foo.__doc__
foo - Function signature:
  a = foo(a)
Required arguments:
  a : input rank-2 array('f') with bounds (m,n)
Return objects:
  a : rank-2 array('f') with bounds (m,n)

>>> print pyforttest.foo.__doc__
foo(a)

>>> pytest.foo([[1,2],[3,4]])
array([[12, 14],
       [24, 26]])
>>> f2pytest.foo([[1,2],[3,4]])  # F2PY can handle arbitrary input sequences
array([[ 12.,  14.],
       [ 24.,  26.]],'f')
>>> pyforttest.foo([[1,2],[3,4]])
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
pyforttest.error: foo, argument A: Argument intent(inout) must be an array.

>>> import Numeric
>>> a=Numeric.array([[1,2],[3,4]],'f')
>>> f2pytest.foo(a)
array([[ 12.,  14.],
       [ 24.,  26.]],'f')
>>> a   # F2PY makes a copy when input array is not Fortran contiguous
array([[ 1.,  2.],
       [ 3.,  4.]],'f')
>>> a=Numeric.transpose(Numeric.array([[1,3],[2,4]],'f'))
>>> a
array([[ 1.,  2.],
       [ 3.,  4.]],'f')
>>> f2pytest.foo(a)
array([[ 12.,  14.],
       [ 24.,  26.]],'f')
>>> a   # F2PY passes Fortran contiguous input array directly to Fortran
array([[ 12.,  14.],
       [ 24.,  26.]],'f')
# See intent(copy), intent(overwrite), intent(inplace), intent(inout)
# attributes documentation to enhance the above behavior.

>>> a=Numeric.array([[1,2],[3,4]],'f')
>>> pyforttest.foo(a)
>>> a   # Huh? Pyfort 8.5 gives wrong results..
array([[ 12.,  23.],
       [ 15.,  26.]],'f')