question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Numpy 1.16.2 f2py test fail

See original GitHub issue

Reproducing code example:

python -c 'import numpy; numpy.test("full");'

Error message:

_____________________________________________________________________________________________________________ TestKind.test_all ______________________________________________________________________________________________________________

self = <numpy.f2py.tests.test_kind.TestKind object at 0x7f0197e35c88>

    @pytest.mark.slow
    def test_all(self):
        selectedrealkind = self.module.selectedrealkind
        selectedintkind = self.module.selectedintkind
    
        for i in range(40):
            assert_(selectedintkind(i) in [selected_int_kind(i), -1],
                    'selectedintkind(%s): expected %r but got %r' %
                    (i, selected_int_kind(i), selectedintkind(i)))
    
        for i in range(20):
            assert_(selectedrealkind(i) in [selected_real_kind(i), -1],
                    'selectedrealkind(%s): expected %r but got %r' %
>                   (i, selected_real_kind(i), selectedrealkind(i)))
E           AssertionError: selectedrealkind(16): expected 10 but got 16

i          = 16
selectedintkind = <fortran object>
selectedrealkind = <fortran object>
self       = <numpy.f2py.tests.test_kind.TestKind object at 0x7f0197e35c88>

/usr/lib/python3.7/site-packages/numpy/f2py/tests/test_kind.py:34: AssertionError
1 failed, 7409 passed, 92 skipped, 10 xfailed, 3 xpassed in 245.10 seconds

Numpy/Python version information:

1.16.2 3.7.2 (default, Jan 10 2019, 23:51:51) 
[GCC 8.2.1 20181127]

built using icc/MKL

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:42 (32 by maintainers)

github_iconTop GitHub Comments

1reaction
oleksandr-pavlykcommented, Mar 8, 2019

I started to doubt myself, so I whipped up a small reproducer, based on numpy/f2py/tests/src/kind/foo.f90:

subroutine selectedrealkind(p, r, res)
  implicit none

  integer, intent(in) :: p, r
  !f2py integer :: r=0
  integer, intent(out) :: res
  res = selected_real_kind(p, r)

end subroutine

subroutine selectedintkind(p, res)
  implicit none

  integer, intent(in) :: p
  integer, intent(out) :: res
  res = selected_int_kind(p)

end subroutine

program checkrealkind
  integer res
  integer p

  do p = 4, 20, 1
     call selectedrealkind(p, 0, res)
     print *, p, res
  end do

  print *, "Done!"
end program checkrealkind

And compiled it so:

gfortran -o run_gfortran.exe foo.f90
ifort -o run_ifort.exe foo.f90

This is the output:

(def) [11:22:25 vmlin03 f]$ ./run_ifort.exe
           4           4
           5           4
           6           4
           7           8
           8           8
           9           8
          10           8
          11           8
          12           8
          13           8
          14           8
          15           8
          16          16
          17          16
          18          16
          19          16
          20          16
 Done!

(def) [11:25:24 vmlin03 f]$ ./run_gfortran.exe
           4           4
           5           4
           6           4
           7           8
           8           8
           9           8
          10           8
          11           8
          12           8
          13           8
          14           8
          15           8
          16          10
          17          10
          18          10
          19          16
          20          16
 Done!

Confirming the discrepancy.

0reactions
HaoZekecommented, Aug 25, 2021

The OP issue is fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NumPy 1.16.2 Release Notes
NumPy 1.16.2 is a quick release fixing several problems encountered on Windows. ... #12923: MAINT: remove complicated test of multiarray import failure mode....
Read more >
NumPy 1.16.6 Release Notes
The np.testing.utils functions have been updated from 1.19.0-dev0. This improves the function documentation and error messages as well extending the ...
Read more >
NumPy 1.16.0 Release Notes
It is an alias to the more powerful numpy.ndarray.item , not tested, and fails for scalars. The numpy.set_array_ops and numpy.get_array_ops functions are ...
Read more >
Release Notes — NumPy v1.16 Manual
The NumPy 1.16.3 release fixes bugs reported against the 1.16.2 release, ... The changed error message emited by array comparison testing functions may ......
Read more >
NumPy 1.6.2 Release Notes
#1905: explicitly check for NaNs in allclose() ... #1793: fix failing npyio test under py3k ... BUG: Fix f2py test_kind.py test ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found