doctest fortran I/O synchronization
I'm trying to make a doctest to verify that the different flow patterns of f2py interfaces work with different varieties of numarrays (normal, byte-swapped, misaligned, dis-contiguous, type-converted). I'm trying to test this out under Linux with g77, and (it seems like) I'm having trouble synchronizing the Fortran I/O with Python's C I/O. Given foo.f: subroutine in_c(a,m,n) real*8 a(n,m) Cf2py intent(in,c) a Cf2py depend(a) :: n=shape(a,0), m=shape(a,1) do j=1,m do i=1,n write (6,1) a(i,j) 1 format( $, 1F3.0, ', ') enddo print *,'' enddo end And given f2py_tests.py: """
foo.in_f(a) 0., 5., 10., 1., 6., 11., 2., 7., 12., 3., 8., 13., 4., 9., 14., """ import foo, numarray
def test(): import doctest global a t = doctest.Tester(globs=globals()) a = numarray.arange(15., shape=(3,5)) t.runstring(__doc__, "c_array") return t.summarize() I get this: [jmiller@halloween ~/f2py_tests]$ python f2py_tests.py 0., 5., 10., 1., 6., 11., 2., 7., 12., 3., 8., 13., 4., 9., 14., ***************************************************************** Failure in example: foo.in_f(a) from line #1 of c_array Expected: 0., 5., 10., 1., 6., 11., 2., 7., 12., 3., 8., 13., 4., 9., 14., Got: ***************************************************************** 1 items had failures: 1 of 1 in c_array ***Test Failed*** 1 failures. Where it appears that the output from the first example somehow escapes the C I/O system I presume doctest is using. The actual test I'm writing has multiple examples, and the fortran I/O *does* make it into the doctest after the first example but remains out of sync. Does anyone have an explanation and/or fix for this problem? -- Todd Miller jmiller@stsci.edu STSCI / ESS / SSB
participants (3)
-
David M. Cooke
-
Pearu Peterson
-
Todd Miller