summaryrefslogtreecommitdiff
path: root/numpy/f2py/docs/simple_session.dat
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/f2py/docs/simple_session.dat')
-rw-r--r--numpy/f2py/docs/simple_session.dat51
1 files changed, 51 insertions, 0 deletions
diff --git a/numpy/f2py/docs/simple_session.dat b/numpy/f2py/docs/simple_session.dat
new file mode 100644
index 000000000..10d9dc962
--- /dev/null
+++ b/numpy/f2py/docs/simple_session.dat
@@ -0,0 +1,51 @@
+>>> 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')