summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHood Chatham <roberthoodchatham@gmail.com>2022-11-10 11:54:21 -0800
committerHood Chatham <roberthoodchatham@gmail.com>2022-11-11 02:52:06 -0800
commit08c6e9c142e619ac5175b6a13342ba2f2c571ddd (patch)
tree8be92e0f2d27dd9c888fde95c2dfe46a305ba892
parent6aacc5167983d7c6f8689d7039294f2fc0d5f5fb (diff)
downloadnumpy-08c6e9c142e619ac5175b6a13342ba2f2c571ddd.tar.gz
TST: Skip tests that are not currently supported in wasm
-rw-r--r--numpy/core/tests/test_casting_floatingpoint_errors.py3
-rw-r--r--numpy/core/tests/test_cython.py3
-rw-r--r--numpy/core/tests/test_datetime.py4
-rw-r--r--numpy/core/tests/test_errstate.py4
-rw-r--r--numpy/core/tests/test_half.py4
-rw-r--r--numpy/core/tests/test_indexing.py3
-rw-r--r--numpy/core/tests/test_limited_api.py3
-rw-r--r--numpy/core/tests/test_mem_policy.py4
-rw-r--r--numpy/core/tests/test_nditer.py3
-rw-r--r--numpy/core/tests/test_nep50_promotions.py2
-rw-r--r--numpy/core/tests/test_numeric.py7
-rw-r--r--numpy/core/tests/test_regression.py3
-rw-r--r--numpy/core/tests/test_ufunc.py5
-rw-r--r--numpy/core/tests/test_umath.py29
-rw-r--r--numpy/distutils/tests/test_build_ext.py2
-rw-r--r--numpy/distutils/tests/test_exec_command.py5
-rw-r--r--numpy/distutils/tests/test_shell_utils.py3
-rw-r--r--numpy/f2py/tests/test_abstract_interface.py3
-rw-r--r--numpy/f2py/tests/util.py5
-rw-r--r--numpy/fft/tests/test_pocketfft.py3
-rw-r--r--numpy/lib/tests/test_format.py5
-rw-r--r--numpy/lib/tests/test_function_base.py3
-rw-r--r--numpy/lib/tests/test_io.py4
-rw-r--r--numpy/linalg/tests/test_linalg.py5
-rw-r--r--numpy/ma/tests/test_core.py3
-rw-r--r--numpy/random/tests/test_extending.py3
-rw-r--r--numpy/random/tests/test_generator_mt19937.py4
-rw-r--r--numpy/random/tests/test_random.py3
-rw-r--r--numpy/random/tests/test_randomstate.py3
-rw-r--r--numpy/testing/_private/utils.py3
-rw-r--r--numpy/tests/test_public_api.py2
-rw-r--r--numpy/tests/test_reloading.py10
-rw-r--r--numpy/tests/test_scripts.py3
33 files changed, 125 insertions, 24 deletions
diff --git a/numpy/core/tests/test_casting_floatingpoint_errors.py b/numpy/core/tests/test_casting_floatingpoint_errors.py
index 4fafc4ed8..d83180171 100644
--- a/numpy/core/tests/test_casting_floatingpoint_errors.py
+++ b/numpy/core/tests/test_casting_floatingpoint_errors.py
@@ -1,6 +1,6 @@
import pytest
from pytest import param
-
+from numpy.testing import IS_WASM
import numpy as np
@@ -136,6 +136,7 @@ def check_operations(dtype, value):
yield flat_assignment
+@pytest.mark.skipif(IS_WASM, reason="no wasm fp exception support")
@pytest.mark.parametrize(["value", "dtype"], values_and_dtypes())
@pytest.mark.filterwarnings("ignore::numpy.ComplexWarning")
def test_floatingpoint_errors_casting(dtype, value):
diff --git a/numpy/core/tests/test_cython.py b/numpy/core/tests/test_cython.py
index a31d9460e..f4aac4a36 100644
--- a/numpy/core/tests/test_cython.py
+++ b/numpy/core/tests/test_cython.py
@@ -5,6 +5,7 @@ import sys
import pytest
import numpy as np
+from numpy.testing import IS_WASM
# This import is copied from random.tests.test_extending
try:
@@ -30,6 +31,8 @@ pytestmark = pytest.mark.skipif(cython is None, reason="requires cython")
@pytest.fixture
def install_temp(request, tmp_path):
# Based in part on test_cython from random.tests.test_extending
+ if IS_WASM:
+ pytest.skip("No subprocess")
here = os.path.dirname(__file__)
ext_dir = os.path.join(here, "examples", "cython")
diff --git a/numpy/core/tests/test_datetime.py b/numpy/core/tests/test_datetime.py
index baae77a35..693eed0e2 100644
--- a/numpy/core/tests/test_datetime.py
+++ b/numpy/core/tests/test_datetime.py
@@ -4,6 +4,7 @@ import numpy as np
import datetime
import pytest
from numpy.testing import (
+ IS_WASM,
assert_, assert_equal, assert_raises, assert_warns, suppress_warnings,
assert_raises_regex, assert_array_equal,
)
@@ -1294,6 +1295,7 @@ class TestDateTime:
def test_timedelta_floor_divide(self, op1, op2, exp):
assert_equal(op1 // op2, exp)
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
@pytest.mark.parametrize("op1, op2", [
# div by 0
(np.timedelta64(10, 'us'),
@@ -1368,6 +1370,7 @@ class TestDateTime:
expected = (op1 // op2, op1 % op2)
assert_equal(divmod(op1, op2), expected)
+ @pytest.mark.skipif(IS_WASM, reason="does not work in wasm")
@pytest.mark.parametrize("op1, op2", [
# reuse cases from floordiv
# div by 0
@@ -1993,6 +1996,7 @@ class TestDateTime:
with assert_raises_regex(TypeError, "common metadata divisor"):
val1 % val2
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_timedelta_modulus_div_by_zero(self):
with assert_warns(RuntimeWarning):
actual = np.timedelta64(10, 's') % np.timedelta64(0, 's')
diff --git a/numpy/core/tests/test_errstate.py b/numpy/core/tests/test_errstate.py
index 184a37300..3a5647f6f 100644
--- a/numpy/core/tests/test_errstate.py
+++ b/numpy/core/tests/test_errstate.py
@@ -2,7 +2,7 @@ import pytest
import sysconfig
import numpy as np
-from numpy.testing import assert_, assert_raises
+from numpy.testing import assert_, assert_raises, IS_WASM
# The floating point emulation on ARM EABI systems lacking a hardware FPU is
# known to be buggy. This is an attempt to identify these hosts. It may not
@@ -12,6 +12,7 @@ hosttype = sysconfig.get_config_var('HOST_GNU_TYPE')
arm_softfloat = False if hosttype is None else hosttype.endswith('gnueabi')
class TestErrstate:
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
@pytest.mark.skipif(arm_softfloat,
reason='platform/cpu issue with FPU (gh-413,-15562)')
def test_invalid(self):
@@ -24,6 +25,7 @@ class TestErrstate:
with assert_raises(FloatingPointError):
np.sqrt(a)
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
@pytest.mark.skipif(arm_softfloat,
reason='platform/cpu issue with FPU (gh-15562)')
def test_divide(self):
diff --git a/numpy/core/tests/test_half.py b/numpy/core/tests/test_half.py
index 2205cc80c..ca849ad52 100644
--- a/numpy/core/tests/test_half.py
+++ b/numpy/core/tests/test_half.py
@@ -3,7 +3,7 @@ import pytest
import numpy as np
from numpy import uint16, float16, float32, float64
-from numpy.testing import assert_, assert_equal, _OLD_PROMOTION
+from numpy.testing import assert_, assert_equal, _OLD_PROMOTION, IS_WASM
def assert_raises_fpe(strmatch, callable, *args, **kwargs):
@@ -483,6 +483,8 @@ class TestHalf:
@pytest.mark.skipif(platform.machine() == "armv5tel",
reason="See gh-413.")
+ @pytest.mark.skipif(IS_WASM,
+ reason="fp exceptions don't work in wasm.")
def test_half_fpe(self):
with np.errstate(all='raise'):
sx16 = np.array((1e-4,), dtype=float16)
diff --git a/numpy/core/tests/test_indexing.py b/numpy/core/tests/test_indexing.py
index c8e52679f..74075639c 100644
--- a/numpy/core/tests/test_indexing.py
+++ b/numpy/core/tests/test_indexing.py
@@ -10,7 +10,7 @@ from numpy.core._multiarray_tests import array_indexing
from itertools import product
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_raises_regex,
- assert_array_equal, assert_warns, HAS_REFCOUNT,
+ assert_array_equal, assert_warns, HAS_REFCOUNT, IS_WASM
)
@@ -563,6 +563,7 @@ class TestIndexing:
with pytest.raises(IndexError):
arr[(index,) * num] = 1.
+ @pytest.mark.skipif(IS_WASM, reason="no threading")
def test_structured_advanced_indexing(self):
# Test that copyswap(n) used by integer array indexing is threadsafe
# for structured datatypes, see gh-15387. This test can behave randomly.
diff --git a/numpy/core/tests/test_limited_api.py b/numpy/core/tests/test_limited_api.py
index 3f9bf346c..725de19bd 100644
--- a/numpy/core/tests/test_limited_api.py
+++ b/numpy/core/tests/test_limited_api.py
@@ -5,7 +5,10 @@ import sys
import sysconfig
import pytest
+from numpy.testing import IS_WASM
+
+@pytest.mark.skipif(IS_WASM, reason="Can't start subprocess")
@pytest.mark.xfail(
sysconfig.get_config_var("Py_DEBUG"),
reason=(
diff --git a/numpy/core/tests/test_mem_policy.py b/numpy/core/tests/test_mem_policy.py
index 3dae36d5a..d5dfbc38b 100644
--- a/numpy/core/tests/test_mem_policy.py
+++ b/numpy/core/tests/test_mem_policy.py
@@ -5,7 +5,7 @@ import pytest
import numpy as np
import threading
import warnings
-from numpy.testing import extbuild, assert_warns
+from numpy.testing import extbuild, assert_warns, IS_WASM
import sys
@@ -18,6 +18,8 @@ def get_module(tmp_path):
"""
if sys.platform.startswith('cygwin'):
pytest.skip('link fails on cygwin')
+ if IS_WASM:
+ pytest.skip("Can't build module inside Wasm")
functions = [
("get_default_policy", "METH_NOARGS", """
Py_INCREF(PyDataMem_DefaultHandler);
diff --git a/numpy/core/tests/test_nditer.py b/numpy/core/tests/test_nditer.py
index cdbe87a45..b88afdfa1 100644
--- a/numpy/core/tests/test_nditer.py
+++ b/numpy/core/tests/test_nditer.py
@@ -9,7 +9,7 @@ import numpy.core._multiarray_tests as _multiarray_tests
from numpy import array, arange, nditer, all
from numpy.testing import (
assert_, assert_equal, assert_array_equal, assert_raises,
- HAS_REFCOUNT, suppress_warnings, break_cycles
+ IS_WASM, HAS_REFCOUNT, suppress_warnings, break_cycles
)
@@ -2025,6 +2025,7 @@ def test_buffered_cast_error_paths():
buf = next(it)
buf[...] = "a" # cannot be converted to int.
+@pytest.mark.skipif(IS_WASM, reason="Cannot start subprocess")
@pytest.mark.skipif(not HAS_REFCOUNT, reason="PyPy seems to not hit this.")
def test_buffered_cast_error_paths_unraisable():
# The following gives an unraisable error. Pytest sometimes captures that
diff --git a/numpy/core/tests/test_nep50_promotions.py b/numpy/core/tests/test_nep50_promotions.py
index 5d4917c94..3c0316960 100644
--- a/numpy/core/tests/test_nep50_promotions.py
+++ b/numpy/core/tests/test_nep50_promotions.py
@@ -9,6 +9,7 @@ import operator
import numpy as np
import pytest
+from numpy.testing import IS_WASM
@pytest.fixture(scope="module", autouse=True)
@@ -19,6 +20,7 @@ def _weak_promotion_enabled():
np._set_promotion_state(state)
+@pytest.mark.skipif(IS_WASM, reason="wasm doesn't have support for fp errors")
def test_nep50_examples():
with pytest.warns(UserWarning, match="result dtype changed"):
res = np.uint8(1) + 2
diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py
index 9a7e95eaf..3cc168b34 100644
--- a/numpy/core/tests/test_numeric.py
+++ b/numpy/core/tests/test_numeric.py
@@ -12,7 +12,7 @@ from numpy.random import rand, randint, randn
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_raises_regex,
assert_array_equal, assert_almost_equal, assert_array_almost_equal,
- assert_warns, assert_array_max_ulp, HAS_REFCOUNT
+ assert_warns, assert_array_max_ulp, HAS_REFCOUNT, IS_WASM
)
from numpy.core._rational_tests import rational
@@ -556,6 +556,7 @@ class TestSeterr:
np.seterr(**old)
assert_(np.geterr() == old)
+ @pytest.mark.skipif(IS_WASM, reason="no wasm fp exception support")
@pytest.mark.skipif(platform.machine() == "armv5tel", reason="See gh-413.")
def test_divide_err(self):
with np.errstate(divide='raise'):
@@ -565,6 +566,7 @@ class TestSeterr:
np.seterr(divide='ignore')
np.array([1.]) / np.array([0.])
+ @pytest.mark.skipif(IS_WASM, reason="no wasm fp exception support")
def test_errobj(self):
olderrobj = np.geterrobj()
self.called = 0
@@ -638,6 +640,7 @@ class TestFloatExceptions:
self.assert_raises_fpe(fpeerr, flop, sc1[()], sc2[()])
# Test for all real and complex float types
+ @pytest.mark.skipif(IS_WASM, reason="no wasm fp exception support")
@pytest.mark.parametrize("typecode", np.typecodes["AllFloat"])
def test_floating_exceptions(self, typecode):
# Test basic arithmetic function errors
@@ -697,6 +700,7 @@ class TestFloatExceptions:
self.assert_raises_fpe(invalid,
lambda a, b: a*b, ftype(0), ftype(np.inf))
+ @pytest.mark.skipif(IS_WASM, reason="no wasm fp exception support")
def test_warnings(self):
# test warning code path
with warnings.catch_warnings(record=True) as w:
@@ -1584,6 +1588,7 @@ class TestNonzero:
a = np.array([[ThrowsAfter(15)]]*10)
assert_raises(ValueError, np.nonzero, a)
+ @pytest.mark.skipif(IS_WASM, reason="wasm doesn't have threads")
def test_structured_threadsafety(self):
# Nonzero (and some other functions) should be threadsafe for
# structured datatypes, see gh-15387. This test can behave randomly.
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index 427e868e8..160e4a3a4 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -12,7 +12,7 @@ from numpy.testing import (
assert_, assert_equal, IS_PYPY, assert_almost_equal,
assert_array_equal, assert_array_almost_equal, assert_raises,
assert_raises_regex, assert_warns, suppress_warnings,
- _assert_valid_refcount, HAS_REFCOUNT, IS_PYSTON
+ _assert_valid_refcount, HAS_REFCOUNT, IS_PYSTON, IS_WASM
)
from numpy.testing._private.utils import _no_tracing, requires_memory
from numpy.compat import asbytes, asunicode, pickle
@@ -326,6 +326,7 @@ class TestRegression:
assert_raises(ValueError, bfa)
assert_raises(ValueError, bfb)
+ @pytest.mark.xfail(IS_WASM, reason="not sure why")
@pytest.mark.parametrize("index",
[np.ones(10, dtype=bool), np.arange(10)],
ids=["boolean-arr-index", "integer-arr-index"])
diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py
index 5f5434a1d..21b0d9e46 100644
--- a/numpy/core/tests/test_ufunc.py
+++ b/numpy/core/tests/test_ufunc.py
@@ -13,7 +13,7 @@ import numpy.core._rational_tests as _rational_tests
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_array_equal,
assert_almost_equal, assert_array_almost_equal, assert_no_warnings,
- assert_allclose, HAS_REFCOUNT, suppress_warnings
+ assert_allclose, HAS_REFCOUNT, suppress_warnings, IS_WASM
)
from numpy.testing._private.utils import requires_memory
from numpy.compat import pickle
@@ -700,6 +700,7 @@ class TestUfunc:
a = np.ones(500, dtype=np.float64)
assert_almost_equal((a / 10.).sum() - a.size / 10., 0, 13)
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_sum(self):
for dt in (int, np.float16, np.float32, np.float64, np.longdouble):
for v in (0, 1, 2, 7, 8, 9, 15, 16, 19, 127,
@@ -2538,6 +2539,7 @@ def test_ufunc_input_casterrors(bad_offset):
np.add(arr, arr, dtype=np.intp, casting="unsafe")
+@pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
@pytest.mark.parametrize("bad_offset", [0, int(np.BUFSIZE * 1.5)])
def test_ufunc_input_floatingpoint_error(bad_offset):
value = 123
@@ -2584,6 +2586,7 @@ def test_reduce_casterrors(offset):
assert out[()] < value * offset
+@pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
@pytest.mark.parametrize("method",
[np.add.accumulate, np.add.reduce,
pytest.param(lambda x: np.add.reduceat(x, [0]), id="reduceat"),
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index d98eca792..e0f91e326 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -17,7 +17,7 @@ from numpy.testing import (
assert_, assert_equal, assert_raises, assert_raises_regex,
assert_array_equal, assert_almost_equal, assert_array_almost_equal,
assert_array_max_ulp, assert_allclose, assert_no_warnings, suppress_warnings,
- _gen_alignment_data, assert_array_almost_equal_nulp
+ _gen_alignment_data, assert_array_almost_equal_nulp, IS_WASM
)
from numpy.testing._private.utils import _glibc_older_than
@@ -377,6 +377,7 @@ class TestDivision:
assert_equal(x // 100, [0, 0, 0, 1, -1, -1, -1, -1, -2])
assert_equal(x % 100, [5, 10, 90, 0, 95, 90, 10, 0, 80])
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
@pytest.mark.parametrize("dtype,ex_val", itertools.product(
np.sctypes['int'] + np.sctypes['uint'], (
(
@@ -462,6 +463,7 @@ class TestDivision:
np.array([], dtype=dtype) // 0
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
@pytest.mark.parametrize("dtype,ex_val", itertools.product(
np.sctypes['int'] + np.sctypes['uint'], (
"np.array([fo.max, 1, 2, 1, 1, 2, 3], dtype=dtype)",
@@ -523,6 +525,8 @@ class TestDivision:
quotient_array = np.array([quotient]*5)
assert all(dividend_array // divisor == quotient_array), msg
else:
+ if IS_WASM:
+ pytest.skip("fp errors don't work in wasm")
with np.errstate(divide='raise', invalid='raise'):
with pytest.raises(FloatingPointError):
dividend // divisor
@@ -569,6 +573,7 @@ class TestDivision:
assert_equal(np.signbit(x//1), 0)
assert_equal(np.signbit((-x)//1), 1)
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
@pytest.mark.parametrize('dtype', np.typecodes['Float'])
def test_floor_division_errors(self, dtype):
fnan = np.array(np.nan, dtype=dtype)
@@ -683,6 +688,7 @@ class TestRemainder:
else:
assert_(b > rem >= 0, msg)
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
@pytest.mark.xfail(sys.platform.startswith("darwin"),
reason="MacOS seems to not give the correct 'invalid' warning for "
"`fmod`. Hopefully, others always do.")
@@ -709,6 +715,7 @@ class TestRemainder:
# inf / 0 does not set any flags, only the modulo creates a NaN
np.divmod(finf, fzero)
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
@pytest.mark.xfail(sys.platform.startswith("darwin"),
reason="MacOS seems to not give the correct 'invalid' warning for "
"`fmod`. Hopefully, others always do.")
@@ -730,6 +737,7 @@ class TestRemainder:
fn(fone, fnan)
fn(fnan, fone)
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_float_remainder_overflow(self):
a = np.finfo(np.float64).tiny
with np.errstate(over='ignore', invalid='ignore'):
@@ -851,6 +859,7 @@ class TestDivisionIntegerOverflowsAndDivideByZero:
helper_lambdas['min-zero'], helper_lambdas['neg_min-zero'])
}
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
@pytest.mark.parametrize("dtype", np.typecodes["Integer"])
def test_signed_division_overflow(self, dtype):
to_check = interesting_binop_operands(np.iinfo(dtype).min, -1, dtype)
@@ -877,6 +886,7 @@ class TestDivisionIntegerOverflowsAndDivideByZero:
assert extractor(res1) == np.iinfo(op1.dtype).min
assert extractor(res2) == 0
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
@pytest.mark.parametrize("dtype", np.typecodes["AllInteger"])
def test_divide_by_zero(self, dtype):
# Note that the return value cannot be well defined here, but NumPy
@@ -896,6 +906,7 @@ class TestDivisionIntegerOverflowsAndDivideByZero:
assert extractor(res1) == 0
assert extractor(res2) == 0
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
@pytest.mark.parametrize("dividend_dtype",
np.sctypes['int'])
@pytest.mark.parametrize("divisor_dtype",
@@ -1147,6 +1158,7 @@ class TestLog2:
v = np.log2(2.**i)
assert_equal(v, float(i), err_msg='at exponent %d' % i)
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_log2_special(self):
assert_equal(np.log2(1.), 0.)
assert_equal(np.log2(np.inf), np.inf)
@@ -1305,6 +1317,7 @@ class TestSpecialFloats:
assert_raises(FloatingPointError, np.exp, np.float64(-1000.))
assert_raises(FloatingPointError, np.exp, np.float64(-1E19))
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_log_values(self):
with np.errstate(all='ignore'):
x = [np.nan, np.nan, np.inf, np.nan, -np.inf, np.nan]
@@ -1354,6 +1367,7 @@ class TestSpecialFloats:
a = np.array(1e9, dtype='float32')
np.log(a)
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_sincos_values(self):
with np.errstate(all='ignore'):
x = [np.nan, np.nan, np.nan, np.nan]
@@ -1394,6 +1408,7 @@ class TestSpecialFloats:
yf = np.array(y, dtype=dt)
assert_equal(np.abs(yf), xf)
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_square_values(self):
x = [np.nan, np.nan, np.inf, np.inf]
y = [np.nan, -np.nan, np.inf, -np.inf]
@@ -1411,6 +1426,7 @@ class TestSpecialFloats:
assert_raises(FloatingPointError, np.square,
np.array(1E200, dtype='d'))
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_reciprocal_values(self):
with np.errstate(all='ignore'):
x = [np.nan, np.nan, 0.0, -0.0, np.inf, -np.inf]
@@ -1425,6 +1441,7 @@ class TestSpecialFloats:
assert_raises(FloatingPointError, np.reciprocal,
np.array(-0.0, dtype=dt))
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_tan(self):
with np.errstate(all='ignore'):
in_ = [np.nan, -np.nan, 0.0, -0.0, np.inf, -np.inf]
@@ -1441,6 +1458,7 @@ class TestSpecialFloats:
assert_raises(FloatingPointError, np.tan,
np.array(-np.inf, dtype=dt))
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_arcsincos(self):
with np.errstate(all='ignore'):
in_ = [np.nan, -np.nan, np.inf, -np.inf]
@@ -1467,6 +1485,7 @@ class TestSpecialFloats:
out_arr = np.array(out, dtype=dt)
assert_equal(np.arctan(in_arr), out_arr)
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_sinh(self):
in_ = [np.nan, -np.nan, np.inf, -np.inf]
out = [np.nan, np.nan, np.inf, -np.inf]
@@ -1483,6 +1502,7 @@ class TestSpecialFloats:
assert_raises(FloatingPointError, np.sinh,
np.array(1200.0, dtype='d'))
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_cosh(self):
in_ = [np.nan, -np.nan, np.inf, -np.inf]
out = [np.nan, np.nan, np.inf, np.inf]
@@ -1515,6 +1535,7 @@ class TestSpecialFloats:
out_arr = np.array(out, dtype=dt)
assert_equal(np.arcsinh(in_arr), out_arr)
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_arccosh(self):
with np.errstate(all='ignore'):
in_ = [np.nan, -np.nan, np.inf, -np.inf, 1.0, 0.0]
@@ -1530,6 +1551,7 @@ class TestSpecialFloats:
assert_raises(FloatingPointError, np.arccosh,
np.array(value, dtype=dt))
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_arctanh(self):
with np.errstate(all='ignore'):
in_ = [np.nan, -np.nan, np.inf, -np.inf, 1.0, -1.0, 2.0]
@@ -1565,6 +1587,7 @@ class TestSpecialFloats:
assert_raises(FloatingPointError, np.exp2,
np.array(value, dtype=dt))
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_expm1(self):
with np.errstate(all='ignore'):
in_ = [np.nan, -np.nan, np.inf, -np.inf]
@@ -3701,6 +3724,7 @@ class TestComplexFunctions:
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_WASM, reason="doesn't work")
def test_precisions_consistent(self):
z = 1 + 1j
for f in self.funcs:
@@ -3710,6 +3734,7 @@ class TestComplexFunctions:
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_WASM, reason="doesn't work")
def test_branch_cuts(self):
# check branch cuts and continuity on them
_check_branch_cut(np.log, -0.5, 1j, 1, -1, True)
@@ -3735,6 +3760,7 @@ class TestComplexFunctions:
_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_WASM, reason="doesn't work")
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)
@@ -3779,6 +3805,7 @@ class TestComplexFunctions:
b = cfunc(p)
assert_(abs(a - b) < atol, "%s %s: %s; cmath: %s" % (fname, p, a, b))
+ @pytest.mark.xfail(IS_WASM, reason="doesn't work")
@pytest.mark.parametrize('dtype', [np.complex64, np.complex_, np.longcomplex])
def test_loss_of_precision(self, dtype):
"""Check loss of precision in complex arc* functions"""
diff --git a/numpy/distutils/tests/test_build_ext.py b/numpy/distutils/tests/test_build_ext.py
index c007159f5..372100fc0 100644
--- a/numpy/distutils/tests/test_build_ext.py
+++ b/numpy/distutils/tests/test_build_ext.py
@@ -5,7 +5,9 @@ import subprocess
import sys
from textwrap import indent, dedent
import pytest
+from numpy.testing import IS_WASM
+@pytest.mark.skipif(IS_WASM, reason="cannot start subprocess in wasm")
@pytest.mark.slow
def test_multi_fortran_libs_link(tmp_path):
'''
diff --git a/numpy/distutils/tests/test_exec_command.py b/numpy/distutils/tests/test_exec_command.py
index 157bd8427..d1a20056a 100644
--- a/numpy/distutils/tests/test_exec_command.py
+++ b/numpy/distutils/tests/test_exec_command.py
@@ -1,10 +1,12 @@
import os
+import pytest
import sys
from tempfile import TemporaryFile
from numpy.distutils import exec_command
from numpy.distutils.exec_command import get_pythonexe
-from numpy.testing import tempdir, assert_, assert_warns
+from numpy.testing import tempdir, assert_, assert_warns, IS_WASM
+
# In python 3 stdout, stderr are text (unicode compliant) devices, so to
# emulate them import StringIO from the io module.
@@ -93,6 +95,7 @@ def test_exec_command_stderr():
exec_command.exec_command("cd '.'")
+@pytest.mark.skipif(IS_WASM, reason="Cannot start subprocess")
class TestExecCommand:
def setup_method(self):
self.pyexe = get_pythonexe()
diff --git a/numpy/distutils/tests/test_shell_utils.py b/numpy/distutils/tests/test_shell_utils.py
index 32bd283e5..696d38ddd 100644
--- a/numpy/distutils/tests/test_shell_utils.py
+++ b/numpy/distutils/tests/test_shell_utils.py
@@ -4,6 +4,7 @@ import json
import sys
from numpy.distutils import _shell_utils
+from numpy.testing import IS_WASM
argv_cases = [
[r'exe'],
@@ -49,6 +50,7 @@ def runner(Parser):
raise NotImplementedError
+@pytest.mark.skipif(IS_WASM, reason="Cannot start subprocess")
@pytest.mark.parametrize('argv', argv_cases)
def test_join_matches_subprocess(Parser, runner, argv):
"""
@@ -64,6 +66,7 @@ def test_join_matches_subprocess(Parser, runner, argv):
assert json.loads(json_out) == argv
+@pytest.mark.skipif(IS_WASM, reason="Cannot start subprocess")
@pytest.mark.parametrize('argv', argv_cases)
def test_roundtrip(Parser, argv):
"""
diff --git a/numpy/f2py/tests/test_abstract_interface.py b/numpy/f2py/tests/test_abstract_interface.py
index 29e4b0647..42902913e 100644
--- a/numpy/f2py/tests/test_abstract_interface.py
+++ b/numpy/f2py/tests/test_abstract_interface.py
@@ -1,9 +1,12 @@
from pathlib import Path
+import pytest
import textwrap
from . import util
from numpy.f2py import crackfortran
+from numpy.testing import IS_WASM
+@pytest.mark.skipif(IS_WASM, reason="Cannot start subprocess")
class TestAbstractInterface(util.F2PyTest):
sources = [util.getpath("tests", "src", "abstract_interface", "foo.f90")]
diff --git a/numpy/f2py/tests/util.py b/numpy/f2py/tests/util.py
index ad8c7a37e..1534c4e7d 100644
--- a/numpy/f2py/tests/util.py
+++ b/numpy/f2py/tests/util.py
@@ -20,7 +20,7 @@ import numpy
from pathlib import Path
from numpy.compat import asbytes, asstr
-from numpy.testing import temppath
+from numpy.testing import temppath, IS_WASM
from importlib import import_module
#
@@ -187,6 +187,9 @@ def _get_compiler_status():
return _compiler_status
_compiler_status = (False, False, False)
+ if IS_WASM:
+ # Can't run compiler from inside WASM.
+ return _compiler_status
# XXX: this is really ugly. But I don't know how to invoke Distutils
# in a safer way...
diff --git a/numpy/fft/tests/test_pocketfft.py b/numpy/fft/tests/test_pocketfft.py
index 392644237..122a9fac9 100644
--- a/numpy/fft/tests/test_pocketfft.py
+++ b/numpy/fft/tests/test_pocketfft.py
@@ -2,7 +2,7 @@ import numpy as np
import pytest
from numpy.random import random
from numpy.testing import (
- assert_array_equal, assert_raises, assert_allclose
+ assert_array_equal, assert_raises, assert_allclose, IS_WASM
)
import threading
import queue
@@ -268,6 +268,7 @@ def test_fft_with_order(dtype, order, fft):
raise ValueError()
+@pytest.mark.skipif(IS_WASM, reason="Cannot start thread")
class TestFFTThreadSafe:
threads = 16
input_shape = (800, 200)
diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py
index 08878a1f9..ab9472020 100644
--- a/numpy/lib/tests/test_format.py
+++ b/numpy/lib/tests/test_format.py
@@ -283,7 +283,7 @@ from io import BytesIO
import numpy as np
from numpy.testing import (
assert_, assert_array_equal, assert_raises, assert_raises_regex,
- assert_warns, IS_PYPY,
+ assert_warns, IS_PYPY, IS_WASM
)
from numpy.testing._private.utils import requires_memory
from numpy.lib import format
@@ -459,6 +459,7 @@ def test_long_str():
assert_array_equal(long_str_arr, long_str_arr2)
+@pytest.mark.skipif(IS_WASM, reason="memmap doesn't work correctly")
@pytest.mark.slow
def test_memmap_roundtrip(tmpdir):
for i, arr in enumerate(basic_arrays + record_arrays):
@@ -526,6 +527,7 @@ def test_load_padded_dtype(tmpdir, dt):
assert_array_equal(arr, arr1)
+@pytest.mark.xfail(IS_WASM, reason="Emscripten NODEFS has a buggy dup")
def test_python2_python3_interoperability():
fname = 'win64python2.npy'
path = os.path.join(os.path.dirname(__file__), 'data', fname)
@@ -675,6 +677,7 @@ def test_version_2_0():
assert_raises(ValueError, format.write_array, f, d, (1, 0))
+@pytest.mark.skipif(IS_WASM, reason="memmap doesn't work correctly")
def test_version_2_0_memmap(tmpdir):
# requires more than 2 byte for header
dt = [(("%d" % i) * 100, float) for i in range(500)]
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 88d4987e6..c5b31ebf4 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -15,7 +15,7 @@ from numpy import ma
from numpy.testing import (
assert_, assert_equal, assert_array_equal, assert_almost_equal,
assert_array_almost_equal, assert_raises, assert_allclose, IS_PYPY,
- assert_warns, assert_raises_regex, suppress_warnings, HAS_REFCOUNT,
+ assert_warns, assert_raises_regex, suppress_warnings, HAS_REFCOUNT, IS_WASM
)
import numpy.lib.function_base as nfb
from numpy.random import rand
@@ -3754,6 +3754,7 @@ class TestMedian:
b[2] = np.nan
assert_equal(np.median(a, (0, 2)), b)
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work correctly")
def test_empty(self):
# mean(empty array) emits two warnings: empty slice and divide by 0
a = np.array([], dtype=float)
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index a5462749f..4699935ca 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -25,7 +25,7 @@ from numpy.testing import (
assert_warns, assert_, assert_raises_regex, assert_raises,
assert_allclose, assert_array_equal, temppath, tempdir, IS_PYPY,
HAS_REFCOUNT, suppress_warnings, assert_no_gc_cycles, assert_no_warnings,
- break_cycles
+ break_cycles, IS_WASM
)
from numpy.testing._private.utils import requires_memory
@@ -243,6 +243,7 @@ class TestSavezLoad(RoundtripTest):
assert_equal(a, l.f.file_a)
assert_equal(b, l.f.file_b)
+ @pytest.mark.skipif(IS_WASM, reason="Cannot start thread")
def test_savez_filename_clashes(self):
# Test that issue #852 is fixed
# and savez functions in multithreaded environment
@@ -2539,6 +2540,7 @@ class TestPathUsage:
break_cycles()
break_cycles()
+ @pytest.mark.xfail(IS_WASM, reason="memmap doesn't work correctly")
def test_save_load_memmap_readwrite(self):
# Test that pathlib.Path instances can be written mem-mapped.
with temppath(suffix='.npy') as path:
diff --git a/numpy/linalg/tests/test_linalg.py b/numpy/linalg/tests/test_linalg.py
index f871a5f8e..b1dbd4c22 100644
--- a/numpy/linalg/tests/test_linalg.py
+++ b/numpy/linalg/tests/test_linalg.py
@@ -19,7 +19,7 @@ from numpy.linalg.linalg import _multi_dot_matrix_chain_order
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_array_equal,
assert_almost_equal, assert_allclose, suppress_warnings,
- assert_raises_regex, HAS_LAPACK64,
+ assert_raises_regex, HAS_LAPACK64, IS_WASM
)
@@ -1063,6 +1063,7 @@ class TestMatrixPower:
assert_raises(LinAlgError, matrix_power, np.array([[1], [2]], dt), 1)
assert_raises(LinAlgError, matrix_power, np.ones((4, 3, 2), dt), 1)
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_exceptions_not_invertible(self, dt):
if dt in self.dtnoinv:
return
@@ -1845,6 +1846,7 @@ def test_byteorder_check():
assert_array_equal(res, routine(sw_arr))
+@pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_generalized_raise_multiloop():
# It should raise an error even if the error doesn't occur in the
# last iteration of the ufunc inner loop
@@ -1908,6 +1910,7 @@ def test_xerbla_override():
pytest.skip('Numpy xerbla not linked in.')
+@pytest.mark.skipif(IS_WASM, reason="Cannot start subprocess")
@pytest.mark.slow
def test_sdot_bug_8577():
# Regression test that loading certain other libraries does not
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
index f32038a01..028f64c61 100644
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -21,7 +21,7 @@ import numpy.ma.core
import numpy.core.fromnumeric as fromnumeric
import numpy.core.umath as umath
from numpy.testing import (
- assert_raises, assert_warns, suppress_warnings
+ assert_raises, assert_warns, suppress_warnings, IS_WASM
)
from numpy import ndarray
from numpy.compat import asbytes
@@ -4365,6 +4365,7 @@ class TestMaskedArrayFunctions:
assert_equal(test, ctrl)
assert_equal(test.mask, ctrl.mask)
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
def test_where(self):
# Test the where function
x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.])
diff --git a/numpy/random/tests/test_extending.py b/numpy/random/tests/test_extending.py
index 04b13cb8c..d5898d25b 100644
--- a/numpy/random/tests/test_extending.py
+++ b/numpy/random/tests/test_extending.py
@@ -6,6 +6,7 @@ import sys
import warnings
import numpy as np
from numpy.distutils.misc_util import exec_mod_from_location
+from numpy.testing import IS_WASM
try:
import cffi
@@ -41,6 +42,8 @@ else:
# too old or wrong cython, skip the test
cython = None
+
+@pytest.mark.skipif(IS_WASM, reason="Can't start subprocess")
@pytest.mark.skipif(cython is None, reason="requires cython")
@pytest.mark.slow
def test_cython(tmp_path):
diff --git a/numpy/random/tests/test_generator_mt19937.py b/numpy/random/tests/test_generator_mt19937.py
index 1710df8ca..54a5b73a3 100644
--- a/numpy/random/tests/test_generator_mt19937.py
+++ b/numpy/random/tests/test_generator_mt19937.py
@@ -8,7 +8,7 @@ from numpy.linalg import LinAlgError
from numpy.testing import (
assert_, assert_raises, assert_equal, assert_allclose,
assert_warns, assert_no_warnings, assert_array_equal,
- assert_array_almost_equal, suppress_warnings)
+ assert_array_almost_equal, suppress_warnings, IS_WASM)
from numpy.random import Generator, MT19937, SeedSequence, RandomState
@@ -1391,6 +1391,7 @@ class TestRandomDist:
[5, 5, 3, 1, 2, 4]]])
assert_array_equal(actual, desired)
+ @pytest.mark.skipif(IS_WASM, reason="fp errors don't work in wasm")
@pytest.mark.parametrize("method", ["svd", "eigh", "cholesky"])
def test_multivariate_normal(self, method):
random = Generator(MT19937(self.seed))
@@ -2452,6 +2453,7 @@ class TestBroadcast:
assert actual.shape == (3, 0, 7, 4)
+@pytest.mark.skipif(IS_WASM, reason="can't start thread")
class TestThread:
# make sure each state produces the same sequence even in threads
def setup_method(self):
diff --git a/numpy/random/tests/test_random.py b/numpy/random/tests/test_random.py
index 6b4c82bc9..0f4e7925a 100644
--- a/numpy/random/tests/test_random.py
+++ b/numpy/random/tests/test_random.py
@@ -6,7 +6,7 @@ import numpy as np
from numpy.testing import (
assert_, assert_raises, assert_equal, assert_warns,
assert_no_warnings, assert_array_equal, assert_array_almost_equal,
- suppress_warnings
+ suppress_warnings, IS_WASM
)
from numpy import random
import sys
@@ -1615,6 +1615,7 @@ class TestBroadcast:
assert_raises(ValueError, logseries, bad_p_two * 3)
+@pytest.mark.skipif(IS_WASM, reason="can't start thread")
class TestThread:
# make sure each state produces the same sequence even in threads
def setup_method(self):
diff --git a/numpy/random/tests/test_randomstate.py b/numpy/random/tests/test_randomstate.py
index be9a9c339..8b911cb3a 100644
--- a/numpy/random/tests/test_randomstate.py
+++ b/numpy/random/tests/test_randomstate.py
@@ -8,7 +8,7 @@ import pytest
from numpy.testing import (
assert_, assert_raises, assert_equal, assert_warns,
assert_no_warnings, assert_array_equal, assert_array_almost_equal,
- suppress_warnings
+ suppress_warnings, IS_WASM
)
from numpy.random import MT19937, PCG64
@@ -1894,6 +1894,7 @@ class TestBroadcast:
assert_raises(ValueError, logseries, bad_p_two * 3)
+@pytest.mark.skipif(IS_WASM, reason="can't start thread")
class TestThread:
# make sure each state produces the same sequence even in threads
def setup_method(self):
diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py
index 26b2aac4d..ea1dc28b5 100644
--- a/numpy/testing/_private/utils.py
+++ b/numpy/testing/_private/utils.py
@@ -34,7 +34,7 @@ __all__ = [
'assert_array_max_ulp', 'assert_warns', 'assert_no_warnings',
'assert_allclose', 'IgnoreException', 'clear_and_catch_warnings',
'SkipTest', 'KnownFailureException', 'temppath', 'tempdir', 'IS_PYPY',
- 'HAS_REFCOUNT', 'suppress_warnings', 'assert_array_compare',
+ 'HAS_REFCOUNT', "IS_WASM", 'suppress_warnings', 'assert_array_compare',
'assert_no_gc_cycles', 'break_cycles', 'HAS_LAPACK64', 'IS_PYSTON',
'_OLD_PROMOTION'
]
@@ -48,6 +48,7 @@ class KnownFailureException(Exception):
KnownFailureTest = KnownFailureException # backwards compat
verbose = 0
+IS_WASM = platform.machine() in ["wasm32", "wasm64"]
IS_PYPY = sys.implementation.name == 'pypy'
IS_PYSTON = hasattr(sys, "pyston_version_info")
HAS_REFCOUNT = getattr(sys, 'getrefcount', None) is not None and not IS_PYSTON
diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py
index 92a34bf91..0c652e01f 100644
--- a/numpy/tests/test_public_api.py
+++ b/numpy/tests/test_public_api.py
@@ -9,6 +9,7 @@ import warnings
import numpy as np
import numpy
import pytest
+from numpy.testing import IS_WASM
try:
import ctypes
@@ -62,6 +63,7 @@ def test_numpy_namespace():
assert bad_results == allowlist
+@pytest.mark.skipif(IS_WASM, reason="can't start subprocess")
@pytest.mark.parametrize('name', ['testing', 'Tester'])
def test_import_lazy_import(name):
"""Make sure we can actually use the modules we lazy load.
diff --git a/numpy/tests/test_reloading.py b/numpy/tests/test_reloading.py
index 8d8c8aa34..a1f360089 100644
--- a/numpy/tests/test_reloading.py
+++ b/numpy/tests/test_reloading.py
@@ -1,6 +1,13 @@
-from numpy.testing import assert_raises, assert_warns, assert_, assert_equal
+from numpy.testing import (
+ assert_raises,
+ assert_warns,
+ assert_,
+ assert_equal,
+ IS_WASM,
+)
from numpy.compat import pickle
+import pytest
import sys
import subprocess
import textwrap
@@ -37,6 +44,7 @@ def test_novalue():
protocol=proto)) is np._NoValue)
+@pytest.mark.skipif(IS_WASM, reason="can't start subprocess")
def test_full_reimport():
"""At the time of writing this, it is *not* truly supported, but
apparently enough users rely on it, for it to be an annoying change
diff --git a/numpy/tests/test_scripts.py b/numpy/tests/test_scripts.py
index 5aa8191bb..892c04eef 100644
--- a/numpy/tests/test_scripts.py
+++ b/numpy/tests/test_scripts.py
@@ -9,7 +9,7 @@ from os.path import join as pathjoin, isfile, dirname
import subprocess
import numpy as np
-from numpy.testing import assert_equal
+from numpy.testing import assert_equal, IS_WASM
is_inplace = isfile(pathjoin(dirname(np.__file__), '..', 'setup.py'))
@@ -41,6 +41,7 @@ def test_f2py(f2py_cmd):
assert_equal(stdout.strip(), np.__version__.encode('ascii'))
+@pytest.mark.skipif(IS_WASM, reason="Cannot start subprocess")
def test_pep338():
stdout = subprocess.check_output([sys.executable, '-mnumpy.f2py', '-v'])
assert_equal(stdout.strip(), np.__version__.encode('ascii'))