Skip to content
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

maint: issues in test_spec_elementwise_functions.py for numpy 2 implementation #59

Closed
Closed
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
2 changes: 2 additions & 0 deletions tests/mypy.ini.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mypy]
ignore_missing_imports = True
36 changes: 26 additions & 10 deletions tests/test_spec_elementwise_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,23 @@
import awkward as ak
import numpy as np

with warnings.catch_warnings():
warnings.simplefilter("ignore")
import numpy.array_api as xp

import pytest

import ragged
"""
with warnings.catch_warnings():
warnings.simplefilter("ignore")
import array_api_strict as xp
"""
has_complex_dtype = True

if np.lib.NumpyVersion(np.__version__) < '2.0.0b1':
with warnings.catch_warnings():
warnings.simplefilter("ignore")
import array_api_strict as xp
has_complex_dtype = np.dtype("complex128") in xp._dtypes._all_dtypes
else:
xp = np

devices = ["cpu"]
try:
Expand Down Expand Up @@ -377,14 +387,20 @@ def test_ceil(device, x):
@pytest.mark.parametrize("device", devices)
def test_ceil_int(device, x_int):
result = ragged.ceil(x_int.to_device(device))
print(x_int.dtype)
print(ragged.ceil(x_int.to_device(device)).dtype)
assert type(result) is type(x_int)
assert result.shape == x_int.shape
assert xp.ceil(first(x_int)) == first(result)
assert xp.ceil(first(x_int)).dtype == result.dtype

print((first(x_int)).dtype)
print((xp.ceil(first(x_int))).dtype)
print(first(result).dtype)
assert np.ceil(first(x_int)).dtype == result.dtype
print((np.ceil(first(x_int))).dtype)
print(result.dtype)

@pytest.mark.skipif(
np.dtype("complex128") not in xp._dtypes._all_dtypes,
not has_complex_dtype,
reason=f"complex not allowed in np.array_api version {np.__version__}",
)
@pytest.mark.parametrize("device", devices)
Expand Down Expand Up @@ -571,7 +587,7 @@ def test_greater_equal_method(device, x, y):


@pytest.mark.skipif(
np.dtype("complex128") not in xp._dtypes._all_dtypes,
not has_complex_dtype,
reason=f"complex not allowed in np.array_api version {np.__version__}",
)
@pytest.mark.parametrize("device", devices)
Expand Down Expand Up @@ -838,7 +854,7 @@ def test_pow_inplace_method(device, x, y):


@pytest.mark.skipif(
np.dtype("complex128") not in xp._dtypes._all_dtypes,
not has_complex_dtype,
reason=f"complex not allowed in np.array_api version {np.__version__}",
)
@pytest.mark.parametrize("device", devices)
Expand Down Expand Up @@ -888,7 +904,7 @@ def test_round(device, x):


@pytest.mark.skipif(
np.dtype("complex128") not in xp._dtypes._all_dtypes,
not has_complex_dtype,
reason=f"complex not allowed in np.array_api version {np.__version__}",
)
@pytest.mark.parametrize("device", devices)
Expand Down
Loading