8000 BLD: Fix features.h detection and blocklist complex trig funcs on musl by mbargull · Pull Request #25092 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BLD: Fix features.h detection and blocklist complex trig funcs on musl #25092

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

Merged
merged 5 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#mesondefine HAVE___DECLSPEC_THREAD_

/* Optional headers */
#mesondefine HAVE_FEATURES_H
#mesondefine HAVE_XLOCALE_H
#mesondefine HAVE_DLFCN_H
#mesondefine HAVE_EXECINFO_H
Expand Down
23 changes: 22 additions & 1 deletion numpy/_core/src/common/npy_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,29 @@
#undef HAVE_CACOSHL

#endif /* __GLIBC_PREREQ(2, 18) */
#endif /* defined(__GLIBC_PREREQ) */
#else /* defined(__GLIBC) */
/* musl linux?, see issue #25092 */

#undef HAVE_CASIN
#undef HAVE_CASINF
#undef HAVE_CASINL
#undef HAVE_CASINH
#undef HAVE_CASINHF
#undef HAVE_CASINHL
#undef HAVE_CATAN
#undef HAVE_CATANF
#undef HAVE_CATANL
#undef HAVE_CATANH
#undef HAVE_CATANHF
#undef HAVE_CATANHL
#undef HAVE_CACOS
#undef HAVE_CACOSF
#undef HAVE_CACOSL
#undef HAVE_CACOSH
#undef HAVE_CACOSHF
#undef HAVE_CACOSHL

#endif /* defined(__GLIBC) */
#endif /* defined(HAVE_FEATURES_H) */

#endif /* NUMPY_CORE_SRC_COMMON_NPY_CONFIG_H_ */
27 changes: 7 additions & 20 deletions numpy/_core/tests/test_umath.py < 10000 svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copy">
Original file line number Diff line number Diff line change
Expand Up @@ -1354,21 +1354,9 @@ def test_log_values(self):

# test log() of max for dtype does not raise
for dt in ['f', 'd', 'g']:
try:
with np.errstate(all='raise'):
x = np.finfo(dt).max
np.log(x)
except FloatingPointError as exc:
if dt == 'g' and IS_MUSL:
# FloatingPointError is known to occur on longdouble
# for musllinux_x86_64 x is very large
pytest.skip(
"Overflow has occurred for"
" np.log(np.finfo(np.longdouble).max)"
)
else:
raise exc

with np.errstate(all='raise'):
x = np.finfo(dt).max
np.log(x)
def test_log_strides(self):
np.random.seed(42)
strides = np.array([-4,-3,-2,-1,1,2,3,4])
Expand Down Expand Up @@ -1712,6 +1700,9 @@ def test_arctanh(self):
assert_raises(FloatingPointError, np.arctanh,
np.array(value, dtype=dt))

# Make sure glibc < 2.18 atanh is not used, issue 25087
assert np.signbit(np.arctanh(-1j).real)

# See: https://github.com/numpy/numpy/issues/20448
@pytest.mark.xfail(
_glibc_older_than("2.17"),
Expand Down Expand Up @@ -1896,9 +1887,9 @@ def test_ldexp(self, dtype, stride):
class TestFRExp:
@pytest.mark.parametrize("stride", [-4,-2,-1,1,2,4])
@pytest.mark.parametrize("dtype", ['f', 'd'])
@pytest.mark.xfail(IS_MUSL, reason="gh23048")
@pytest.mark.skipif(not sys.platform.startswith('linux'),
reason="np.frexp gives different answers for NAN/INF on windows and linux")
@pytest.mark.xfail(IS_MUSL, reason="gh23049")
def test_frexp(self, dtype, stride):
arr = np.array([np.nan, np.nan, np.inf, -np.inf, 0.0, -0.0, 1.0, -1.0], dtype=dtype)
mant_true = np.array([np.nan, np.nan, np.inf, -np.inf, 0.0, -0.0, 0.5, -0.5], dtype=dtype)
Expand Down Expand Up @@ -4135,7 +4126,6 @@ def test_it(self):
assert_almost_equal(fz.real, fr, err_msg='real part %s' % f)
assert_almost_equal(fz.imag, 0., err_msg='imag part %s' % f)

@pytest.mark.xfail(IS_MUSL, reason="gh23049")
@pytest.mark.xfail(IS_WASM, reason="doesn't work")
def test_precisions_consistent(self):
z = 1 + 1j
Expand All @@ -4146,7 +4136,6 @@ 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(IS_MUSL, reason="gh23049")
@pytest.mark.xfail(IS_WASM, reason="doesn't work")
def test_branch_cuts(self):
# check branch cuts and continuity on them
Expand All @@ -4173,7 +4162,6 @@ 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(IS_MUSL, reason="gh23049")
@pytest.mark.xfail(IS_WASM, reason="doesn't work")
def test_branch_cuts_complex64(self):
# check branch cuts and continuity on them
Expand Down Expand Up @@ -4227,7 +4215,6 @@ def test_against_cmath(self):
_glibc_older_than("2.18"),
reason="Older glibc versions are imprecise (maybe passes with SIMD?)"
)
@pytest.mark.xfail(IS_MUSL, reason="gh23049")
@pytest.mark.xfail(IS_WASM, reason="doesn't work")
@pytest.mark.parametrize('dtype', [
np.complex64, np.complex128, np.clongdouble
Expand Down
0