Skip to content

BUG(?): f2py selectedrealkind test failure on macOS-arm64 #21765

@dhomeier

Description

@dhomeier

Describe the issue:

In 1.23.0rc3 (built locally or pip-installed) and 1.24.0dev built on macOS 12.4/M1 (aarch64) test_kind is failing (everything else passing!) on

        for i in range(20):
>           assert selectedrealkind(i) == selected_real_kind(
                i
            ), f"selectedrealkind({i}): expected {selected_real_kind(i)!r} but got {selectedrealkind(i)!r}"
E           AssertionError: selectedrealkind(16): expected 10 but got -1
E           assert -1 == 10
E            +  where -1 = <fortran function selectedrealkind>(16)
E            +  and   10 = selected_real_kind(16)

Modifying the test to parametrise i confirms that the kinds differ for all values 16-20

FAILED tests/test_kind.py::TestKind::test_all[16] - AssertionError: selectedrealkind(16): expected 10 but got -1
FAILED tests/test_kind.py::TestKind::test_all[17] - AssertionError: selectedrealkind(17): expected 10 but got -1
FAILED tests/test_kind.py::TestKind::test_all[18] - AssertionError: selectedrealkind(18): expected 10 but got -1
FAILED tests/test_kind.py::TestKind::test_all[19] - AssertionError: selectedrealkind(19): expected 16 but got -1
FAILED tests/test_kind.py::TestKind::test_all[20] - AssertionError: selectedrealkind(20): expected 16 but got -1

I don't know exactly what f2py functionality is tested here, so the issue may instead be with the Fortran compiler, which is

Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/opt/lib/gcc11/libexec/gcc/aarch64-apple-darwin21.3.0/11.2.0/lto-wrapper
Target: aarch64-apple-darwin21.3.0
Configured with: ../gcc-gcc-11.2.0-arm-20211201/configure --prefix=/opt --prefix=/opt/lib/gcc11 --mandir=/opt/share/man --infodir=/opt/lib/gcc11/info --enable-languages=c,c++,fortran,lto,objc,obj-c++ --with-gmp=/opt --with-libiconv-prefix=/opt --with-isl=/opt --with-mpc=/opt --with-system-zlib --program-suffix=-fsf-11 --disable-multilib --enable-stage1-checking --with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk --with-pkgversion='Fink gcc11 11.2.0-1' --with-bugurl=https://github.com/fink/fink-distributions/issues
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.0 (Fink gcc11 11.2.0-1)

built from https://github.com/fxcoudert/gcc/releases/tag/gcc-11.2.0-arm-20211201
The same gcc11 branch built for x86_64 (natively or on Rosetta) is passing this test on macOS 12.4 and 10.14.

Reproduce the code example:

import numpy.f2py
numpy.f2py.test(verbose=2)

Error message:

===================================================================================== FAILURES =====================================================================================
________________________________________________________________________________ TestKind.test_all _________________________________________________________________________________

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

    def test_all(self):
        selectedrealkind = self.module.selectedrealkind
        selectedintkind = self.module.selectedintkind
    
        for i in range(40):
            assert selectedintkind(i) == selected_int_kind(
                i
            ), f"selectedintkind({i}): expected {selected_int_kind(i)!r} but got {selectedintkind(i)!r}"
    
        for i in range(20):
>           assert selectedrealkind(i) == selected_real_kind(
                i
            ), f"selectedrealkind({i}): expected {selected_real_kind(i)!r} but got {selectedrealkind(i)!r}"
E           AssertionError: selectedrealkind(16): expected 10 but got -1
E           assert -1 == 10
E            +  where -1 = <fortran object>(16)
E            +  and   10 = selected_real_kind(16)

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

../../opt/lib/python3.10/site-packages/numpy/f2py/tests/test_kind.py:24: AssertionError
============================================================================= short test summary info ==============================================================================
FAILED tests/test_kind.py::TestKind::test_all - AssertionError: selectedrealkind(16): expected 10 but got -1
======================================================= 1 failed, 595 passed, 6 skipped, 36 deselected, 3 xfailed in 42.03s ========================================================

NumPy/Python version information:

1.23.0rc3 3.10.5 (main, Jun 10 2022, 23:11:16) [Clang 13.1.6 (clang-1316.0.21.2.5)]
1.24.0.dev0+260.gd2a986272 3.10.5 (main, Jun 10 2022, 23:11:16) [Clang 13.1.6 (clang-1316.0.21.2.5)]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions