10000 BUG: Fixes for building on Cygwin. by charris · Pull Request #18102 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fixes for building on Cygwin. #18102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1926a6b
BLD: Move the configuration defines in Python.h earlier.
DWesl May 14, 2020
7c320f3
DEV: Try to rebase f2py-created modules for fewer fork() failures in …
DWesl May 14, 2020
9cbd7de
TST: Mark the tests that seem to fail due to different floating-point…
DWesl May 14, 2020
60d1964
TST: Try to mark the tests still suseptible to fork() failures on cyg…
DWesl May 14, 2020
6d8f36e
DEV: Revert executable renames for F77/G77 compiler.
DWesl May 18, 2020
c8d1059
BLD: Add functions that fail tests on Cygwin to npy_config.h.
DWesl May 18, 2020
c356079
TST: Describe what I know about the FPE test failure.
DWesl May 18, 2020
faca5fb
STY: A few largely cosmetic changes.
DWesl May 18, 2020
02593e2
DEV: Stop trying to rebase f2py modules.
DWesl May 18, 2020
db30000
Remove xfails from tests that now pass.
DWesl May 19, 2020
66dc53a
Use parametrize for the dtypes in the abs tests.
DWesl May 19, 2020
0d4b4de
Remove xfail mark from an assert function.
DWesl May 20, 2020
0f11301
Remove references to np.complex256
DWesl May 25, 2020
bc209f1
Remove reference to np.complex256 in the other test
DWesl May 25, 2020
c93cb73
Don't add `gfortran` to the list of GNU77 compilers
DWesl May 29, 2020
343127d
Include only 'gfortran' in gnu fcompiler, not absolute version
DWesl Jun 6, 2020
f9bea44
TST: Use usual names for the dtypes in xfail mark
DWesl Jul 9, 2020
f655535
BLD: Remind GCC that .seh_savexmm fails for xmm16-31.
DWesl Jun 17, 2020
d22b665
BLD: Fix code checking for old GCC on cygwin.
DWesl Jun 19, 2020
8e2352b
TST: Only mark fork()-using tests xfail on 32-bit cygwin.
DWesl Jun 19, 2020
c519dd0
BLD: Fix flags added to compiler line for old GCC on MS.
DWesl Jun 19, 2020
33e863b
TST: parametrize test_npymath_complex.
DWesl Jul 9, 2020
853f82a
TST: Clarify the xfail messages for branch cuts.
DWesl Aug 29, 2020
c32f1ce
BLD: Remove probably-unnecessary include.
DWesl Aug 29, 2020
31c1fe1
TST: Try to keep testing code from changing tempfile name.
DWesl Aug 23, 2020
3666fce
BLD: Mark modfl as problematic on cygwin.
DWesl Aug 29, 2020
78e8c95
Undef HAVE_MODFL only on 64-bit cygwin
DWesl Sep 1, 2020
af0de3d
Revert "BLD: Fix flags added to compiler line for old GCC on MS."
DWesl Oct 27, 2020
8fc9a9f
Revert "BLD: Fix code checking for old GCC on cygwin."
DWesl Oct 27, 2020
7c43e16
Revert "BLD: Remind GCC that .seh_savexmm fails for xmm16-31."
DWesl Oct 27, 2020
0c93f5f
MAINT: Fixup setpy.py merge
charris Dec 31, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions numpy/core/include/numpy/npy_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#ifndef NPY_USE_NEW_CASTINGIMPL
#define NPY_USE_NEW_CASTINGIMPL 0
#endif

/*
* using static inline modifiers when defining npy_math functions
* allows the compiler to make optimizations when possible
Expand Down
54 changes: 54 additions & 0 deletions numpy/core/src/common/npy_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,60 @@
#endif
#endif /* defined(_MSC_VER) && defined(__INTEL_COMPILER) */

/* Disable functions that give undesired floating-point outputs on
Cygwin. */
#ifdef __CYGWIN__

#undef HAVE_CABS
#undef HAVE_CABSF
#undef HAVE_CABSL

/* These work for me in C++, even for the failing test case (2 ** 29),
but the tests fail. No idea if the functions I'm getting are used
or not. */
#undef HAVE_LOG2
#undef HAVE_LOG2F
#undef HAVE_LOG2L

/* Complex square root does not use sign of zero to find branch
cuts. */
#undef HAVE_CSQRT
#undef HAVE_CSQRTF
#undef HAVE_CSQRTL

/* C++ Real asinh works fine, complex asinh says asinh(1e-20+0j) =
0 */
#undef HAVE_CASINH
#undef HAVE_CASINHF
#undef HAVE_CASINHL

/* _check_branch_cut(np.arcsin, ...) fails */
#undef HAVE_CASIN
#undef HAVE_CASINF
#undef HAVE_CASINL

/* Branch cuts for arccosine also fail */
#undef HAVE_CACOS
#undef HAVE_CACOSF
#undef HAVE_CACOSL

/* Branch cuts for arctan fail as well */
#undef HAVE_CATAN
#undef HAVE_CATANF
#undef HAVE_CATANL

/* check_loss_of_precision fails in arctanh */
#undef HAVE_CATANH
#undef HAVE_CATANHF
#undef HAVE_CATANHL

/* modfl segfaults on 64-bit Cygwin 3.1.5-3.1.7 */
#ifdef __x86_64__
#undef HAVE_MODFL
#endif

#endif

/* powl gives zero division warning on OS X, see gh-8307 */
#if defined(HAVE_POWL) && defined(NPY_OS_DARWIN)
#undef HAVE_POWL
Expand Down
45 changes: 29 additions & 16 deletions numpy/core/tests/test_multiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -8576,23 +8576,36 @@ class MyAlwaysEqualNew(MyAlwaysEqual):
assert_equal(array != my_always_equal, 'ne')


def test_npymath_complex():
@pytest.mark.parametrize(
["fun", "npfun", "x", "y", "dtype"],
[
pytest.param(
fun, npfun, x, y, dtype, marks=pytest.mark.xfail(
sys.platform == "cygwin" and
dtype in (np.clongdouble,) and
fun == _multiarray_tests.npy_cabs and
np.isinf([x, y]).any() and np.isnan([x, y]).any(),
reason='abs(inf+nanj) short-circuits to inf',
strict=True,
)
)
for (fun, npfun), x, y, dtype in itertools.product(
[
(_multiarray_tests.npy_cabs, np.absolute),
(_multiarray_tests.npy_carg, np.angle),
],
[1, np.inf, -np.inf, np.nan],
[1, np.inf, -np.inf, np.nan],
[np.complex64, np.complex128, np.clongdouble],
)
],
)
def test_npymath_complex(fun, npfun, x, y, dtype):
# Smoketest npymath functions
from numpy.core._multiarray_tests import (
npy_cabs, npy_carg)

funcs = {npy_cabs: np.absolute,
npy_carg: np.angle}
vals = (1, np.inf, -np.inf, np.nan)
types = (np.complex64, np.complex128, np.clongdouble)

for fun, npfun in funcs.items():
for x, y in itertools.product(vals, vals):
for t in types:
z = t(complex(x, y))
got = fun(z)
expected = npfun(z)
assert_allclose(got, expected)
z = dtype(complex(x, y))
got = fun(z)
expected = npfun(z)
assert_allclose(got, expected)


def test_npymath_real():
Expand Down
6 changes: 6 additions & 0 deletions numpy/core/tests/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,12 @@ def assert_op_raises_fpe(self, fpeerr, flop, sc1, sc2):
self.assert_raises_fpe(fpeerr, flop, sc1, sc2[()])
self.assert_raises_fpe(fpeerr, flop, sc1[()], sc2[()])

@pytest.mark.xfail(
sys.platform == "cygwin",
reason="complex256(2 ** (2 ** nexp_256)) is inf+infj without OverflowError",
raises=AssertionError,
strict=True,
)
def test_floating_exceptions(self):
# Test basic arithmetic function errors
with np.errstate(all='raise'):
Expand Down
87 changes: 61 additions & 26 deletions numpy/core/tests/test_scalarmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,32 +653,67 @@ def test_result(self):


class TestAbs:
def _test_abs_func(self, absfunc):
for tp in floating_types + complex_floating_types:
x = tp(-1.5)
assert_equal(absfunc(x), 1.5)
x = tp(0.0)
res = absfunc(x)
# assert_equal() checks zero signedness
assert_equal(res, 0.0)
x = tp(-0.0)
res = absfunc(x)
assert_equal(res, 0.0)

x = tp(np.finfo(tp).max)
assert_equal(absfunc(x), x.real)

x = tp(np.finfo(tp).tiny)
assert_equal(absfunc(x), x.real)

x = tp(np.finfo(tp).min)
assert_equal(absfunc(x), -x.real)

def test_builtin_abs(self):
self._test_abs_func(abs)

def test_numpy_abs(self):
self._test_abs_func(np.abs)
def _test_abs_func(self, absfunc, tp):
x = tp(-1.5)
assert_equal(absfunc(x), 1.5)
x = tp(0.0)
res = absfunc(x)
# assert_equal() checks zero signedness
assert_equal(res, 0.0)
x = tp(-0.0)
res = absfunc(x)
assert_equal(res, 0.0)

x = tp(np.finfo(tp).max)
assert_equal(absfunc(x), x.real)

x = tp(np.finfo(tp).tiny)
assert_equal(absfunc(x), x.real)

x = tp(np.finfo(tp).min)
assert_equal(absfunc(x), -x.real)

@pytest.mark.parametrize(
"dtype",
[
pytest.param(
dtype,
marks=(
pytest.mark.xfail(
sys.platform == 'cygwin',
reason='abs(np.complex256.max) overflows',
raises=AssertionError,
strict=True,
)
if sys.platform == 'cygwin' and dtype == np.complex256 else ()
)
)
for dtype in floating_types + complex_floating_types
],
)
def test_builtin_abs(self, dtype):
self._test_abs_func(abs, dtype)

@pytest.mark.parametrize(
"dtype",
[
pytest.param(
dtype,
marks=(
pytest.mark.xfail(
sys.platform == 'cygwin',
reason='abs(np.complex256.max) overflows',
raises=RuntimeWarning,
strict=True,
)
if sys.platform == 'cygwin' and dtype == np.complex256 else ()
)
)
for dtype in floating_types + complex_floating_types
],
)
def test_numpy_abs(self, dtype):
self._test_abs_func(np.abs, dtype)


class TestBitShifts:
Expand Down
10 changes: 10 additions & 0 deletions numpy/core/tests/test_umath.py

Original file line number Diff line number Diff line change
Expand Up @@ -3011,6 +3011,11 @@ def test_precisions_consistent(self):
assert_almost_equal(fcf, fcd, decimal=6, err_msg='fch-fcd %s' % f)
assert_almost_equal(fcl, fcd, decimal=15, err_msg='fch-fcl %s' % f)

@pytest.mark.xfail(
sys.platform == 'cygwin',
reason='Cygwin does not use the sign of zero for branch cuts along an axis',
strict=True,
)
def test_branch_cuts(self):
# check branch cuts and continuity on them
_check_branch_cut(np.log, -0.5, 1j, 1, -1, True)
Expand All @@ -3036,6 +3041,11 @@ def test_branch_cuts(self):
_check_branch_cut(np.arccosh, [0-2j, 2j, 2], [1, 1, 1j], 1, 1)
_check_branch_cut(np.arctanh, [0-2j, 2j, 0], [1, 1, 1j], 1, 1)

@pytest.mark.xfail(
sys.platform == 'cygwin',
reason='Cygwin does not use sign of zero for branch cuts along an axis',
strict=True,
)
def test_branch_cuts_complex64(self):
# check branch cuts and continuity on them
_check_branch_cut(np.log, -0.5, 1j, 1, -1, True, np.complex64)
Expand Down
6 changes: 4 additions & 2 deletions numpy/distutils/fcompiler/gnu.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,10 @@ def get_flags_arch(self):
return []

def runtime_library_dir_option(self, dir):
if sys.platform == 'win32':
# Linux/Solaris/Unix support RPATH, Windows does not
if (
sys.platform[:3] == 'aix' or sys.platform == 'win32' or sys.platform == 'cygwin'
):
# Linux/Solaris/Unix support RPATH, Windows and AIX do not
raise NotImplementedError

# TODO: could use -Xlinker here, if it's supported
Expand Down
2 changes: 1 addition & 1 deletion numpy/distutils/tests/test_system_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def test_overrides(self):

# Also, the values will be taken from a section named '[DEFAULT]'
with open(cfg, 'r') as fid:
dflt = fid.read().replace('mkl', 'DEFAULT')
dflt = fid.read().replace('[mkl]', '[DEFAULT]', 1)
with open(cfg, 'w') as fid:
fid.write(dflt)
info = mkl_info()
Expand Down
7 changes: 7 additions & 0 deletions numpy/f2py/tests/test_compile_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import numpy.f2py

from numpy.testing import assert_equal
from numpy.testing._private.utils import IS_32BIT_CYGWIN
from . import util


Expand All @@ -26,6 +27,8 @@ def setup_module():
"extra_args", [['--noopt', '--debug'], '--noopt --debug', '']
)
@pytest.mark.leaks_references(reason="Imported module seems never deleted.")
@pytest.mark.xfail(IS_32BIT_CYGWIN, reason="Random fork failures",
raises=BlockingIOError)
def test_f2py_init_compile(extra_args):
# flush through the f2py __init__ compile() function code path as a
# crude test for input handling following migration from
Expand Down Expand Up @@ -83,6 +86,8 @@ def test_f2py_init_compile(extra_args):
del sys.modules[modname]


@pytest.mark.xfail(IS_32BIT_CYGWIN, reason="Random fork failures",
raises=BlockingIOError)
def test_f2py_init_compile_failure():
# verify an appropriate integer status value returned by
# f2py.compile() when invalid Fortran is provided
Expand Down Expand Up @@ -111,6 +116,8 @@ def test_f2py_init_compile_bad_cmd():
@pytest.mark.parametrize('fsource',
['program test_f2py\nend program test_f2py',
b'program test_f2py\nend program test_f2py',])
@pytest.mark.xfail(IS_32BIT_CYGWIN, reason="Random fork failures",
raises=BlockingIOError)
def test_compile_from_strings(tmpdir, fsource):
# Make sure we can compile str and bytes gh-12796
cwd = os.getcwd()
Expand Down
7 changes: 7 additions & 0 deletions numpy/f2py/tests/util.py
57AE
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from numpy.compat import asbytes, asstr
from numpy.testing import temppath
from numpy.testing._private.utils import IS_32BIT_CYGWIN
from importlib import import_module

#
Expand Down Expand Up @@ -317,6 +318,12 @@ class F2PyTest:
module = None
module_name = None

# Pytest seems to ignore this, but I'm not sure where else to put
# it, besides trying to make a metaclass that decorates every
# method of a subclass of F2PyTest
@pytest.mark.xfail(IS_32BIT_CYGWIN,
reason='Fork() randomly fails on cygwin',
raises=BlockingIOError)
def setup(self):
if sys.platform == 'win32':
pytest.skip('Fails with MinGW64 Gfortran (Issue #9673)')
Expand Down
3 changes: 3 additions & 0 deletions numpy/linalg/tests/test_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1837,6 +1837,9 @@ def test_xerbla_override():


@pytest.mark.slow
@pytest.mark.xfail(sys.platform == 'cygwin',
reason='Fork() fails randomly on cygwin',
raises=BlockingIOError)
def test_sdot_bug_8577():
# Regression test that loading certain other libraries does not
# result to wrong results in float32 linear algebra.
Expand Down
2 changes: 1 addition & 1 deletion numpy/random/src/distributions/random_hypergeometric.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <stdint.h>
#include "numpy/random/distributions.h"
#include "logfactorial.h"
#include <stdint.h>

/*
* Generate a sample from the hypergeometric distribution.
Expand Down
4 changes: 4 additions & 0 deletions F438 numpy/random/tests/test_extending.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
import warnings
import numpy as np
from numpy.testing._private.utils import IS_32BIT_CYGWIN

try:
import cffi
Expand Down Expand Up @@ -42,6 +43,9 @@

@pytest.mark.skipif(cython is None, reason="requires cython")
@pytest.mark.slow
@pytest.mark.xfail(IS_32BIT_CYGWIN,
reason="Random fork() failures",
raises=BlockingIOError)
def test_cython(tmp_path):
srcdir = os.path.join(os.path.dirname(__file__), '..')
shutil.copytree(srcdir, tmp_path / 'random')
Expand Down
3 changes: 2 additions & 1 deletion numpy/testing/_private/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
'SkipTest', 'KnownFailureException', 'temppath', 'tempdir', 'IS_PYPY',
'HAS_REFCOUNT', 'suppress_warnings', 'assert_array_compare',
'_assert_valid_refcount', '_gen_alignment_data', 'assert_no_gc_cycles',
'break_cycles', 'HAS_LAPACK64'
'break_cycles', 'HAS_LAPACK64', 'IS_32BIT_CYGWIN'
]


Expand All @@ -48,6 +48,7 @@ class KnownFailureException(Exception):
verbose = 0

IS_PYPY = platform.python_implementation() == 'PyPy'
IS_32BIT_CYGWIN = (sys.platform == 'cygwin' and (sys.maxsize >> 30) == 1)
HAS_REFCOUNT = getattr(sys, 'getrefcount', None) is not None
HAS_LAPACK64 = numpy.linalg.lapack_lite._ilp64

Expand Down
Loading
0