Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
24 changes: 16 additions & 8 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV

- name: Install dpnp
run: mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
run: mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
env:
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
MAMBA_NO_LOW_SPEED_LIMIT: 1
Expand All @@ -173,24 +173,28 @@ jobs:
python -c "import dpnp; print(dpnp.__version__)"

- name: Run tests
env:
DPNP_TEST_ALL_TYPES: 1
if: env.RERUN_TESTS_ON_FAILURE != 'true'
run: |
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests

- name: Run tests
env:
DPNP_TEST_ALL_TYPES: 1
if: env.RERUN_TESTS_ON_FAILURE == 'true'
id: run_tests_linux
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
with:
timeout_minutes: 10
timeout_minutes: 45
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
retry_on: any
command: |
. $CONDA/etc/profile.d/conda.sh
. $CONDA/etc/profile.d/mamba.sh
mamba activate ${{ env.TEST_ENV_NAME }}

python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests

test_windows:
name: Test ['windows-2019', python='${{ matrix.python }}']
Expand Down Expand Up @@ -282,7 +286,7 @@ jobs:
- name: Install dpnp
run: |
@echo on
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
env:
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
MAMBA_NO_LOW_SPEED_LIMIT: 1
Expand All @@ -309,20 +313,24 @@ jobs:
python -c "import dpnp; print(dpnp.__version__)"

- name: Run tests
env:
DPNP_TEST_ALL_TYPES: 1
if: env.RERUN_TESTS_ON_FAILURE != 'true'
run: |
pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests

- name: Run tests
env:
DPNP_TEST_ALL_TYPES: 1
if: env.RERUN_TESTS_ON_FAILURE == 'true'
id: run_tests_win
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
with:
timeout_minutes: 15
timeout_minutes: 45
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
retry_on: any
command: |
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests

upload:
name: Upload ['${{ matrix.os }}', python='${{ matrix.python }}']
Expand Down
15 changes: 14 additions & 1 deletion doc/reference/dtypes_table.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,35 @@ Table below shows a list of all supported data types (dtypes) and constants of t
- Constants
* -
- :obj:`bool <numpy.bool_>`
- :obj:`int8 <numpy.int8>`
- :obj:`int16 <numpy.int16>`
- :obj:`int32 <numpy.int32>`
- :obj:`int64 <numpy.int64>`
- :obj:`uint8 <numpy.uint8>`
- :obj:`uint16 <numpy.uint16>`
- :obj:`uint32 <numpy.uint32>`
- :obj:`uint64 <numpy.uint64>`
- :obj:`float32 <numpy.float32>`
- :obj:`float64 <numpy.float64>`
- :obj:`complex64 <numpy.complex64>`
- :obj:`complex128 <numpy.complex128>`
-
- :obj:`bool_ <numpy.bool_>`
- :obj:`byte <numpy.byte>`
- :obj:`cdouble <numpy.cdouble>`
- :obj:`csingle <numpy.csingle>`
- :obj:`double <numpy.double>`
- :obj:`float16 <numpy.float16>`
- :obj:`int <numpy.int>`
- :obj:`int_ <numpy.int_>`
- :obj:`intc <numpy.intc>`
- :obj:`intp <numpy.intp>`
- :obj:`longlong <numpy.longlong>`
- :obj:`single <numpy.single>`
- :obj:`ubyte <numpy.ubyte>`
- :obj:`uintc <numpy.uintc>`
- :obj:`uintp <numpy.uintp>`
- :obj:`ushort <numpy.ushort>`
- :obj:`ulonglong <numpy.ulonglong>`
-
- :obj:`e <numpy.e>`
- :obj:`euler_gamma <numpy.euler_gamma>`
Expand Down
32 changes: 30 additions & 2 deletions dpnp/dpnp_iface_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
__all__ = [
"bool",
"bool_",
"byte",
"cdouble",
"complex128",
"complex64",
Expand All @@ -57,21 +58,34 @@
"iinfo",
"inexact",
"inf",
"int",
"int_",
"int8",
"int16",
"int32",
"int64",
"integer",
"intc",
"intp",
"issubdtype",
"is_type_supported",
"longlong",
"nan",
"newaxis",
"number",
"pi",
"short",
"signedinteger",
"single",
"ubyte",
"uint8",
"uint16",
"uint32",
"uint64",
"uintc",
"uintp",
"unsignedinteger",
"ushort",
"ulonglong",
]


Expand All @@ -81,6 +95,7 @@
# =============================================================================
bool = numpy.bool_
bool_ = numpy.bool_
byte = numpy.byte
cdouble = numpy.cdouble
complex128 = numpy.complex128
complex64 = numpy.complex64
Expand All @@ -93,16 +108,29 @@
float64 = numpy.float64
floating = numpy.floating
inexact = numpy.inexact
int = numpy.int_
int_ = numpy.int_
int8 = numpy.int8
int16 = numpy.int16
int32 = numpy.int32
int64 = numpy.int64
integer = numpy.integer
intc = numpy.intc
intp = numpy.intp
longlong = numpy.longlong
number = numpy.number
short = numpy.short
signedinteger = numpy.signedinteger
single = numpy.single
ubyte = numpy.ubyte
uint8 = numpy.uint8
uint16 = numpy.uint16
uint32 = numpy.uint32
uint64 = numpy.uint64
uintc = numpy.uintc
uintp = numpy.uintp
unsignedinteger = numpy.unsignedinteger
ushort = numpy.ushort
ulonglong = numpy.ulonglong


# =============================================================================
Expand Down
3 changes: 3 additions & 0 deletions dpnp/tests/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import os

all_types = int(os.getenv("DPNP_TEST_ALL_TYPES", 0))
13 changes: 13 additions & 0 deletions dpnp/tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from numpy.testing import assert_allclose, assert_array_equal

import dpnp
from dpnp.tests import config


def assert_dtype_allclose(
Expand Down Expand Up @@ -88,6 +89,18 @@ def get_integer_dtypes():
Build a list of integer types supported by DPNP.
"""

if config.all_types:
return [
dpnp.int8,
dpnp.int16,
dpnp.int32,
dpnp.int64,
dpnp.uint8,
dpnp.uint16,
dpnp.uint32,
dpnp.uint64,
]

return [dpnp.int32, dpnp.int64]


Expand Down
30 changes: 18 additions & 12 deletions dpnp/tests/test_arraypad.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ class TestPad:
"empty": {},
}

@pytest.mark.parametrize("mode", _all_modes.keys())
# .keys() returns set which is not ordered
# consistent order is required by xdist plugin
_modes = sorted(_all_modes.keys())

@pytest.mark.parametrize("mode", _modes)
def test_basic(self, mode):
a_np = numpy.arange(100)
a_dp = dpnp.array(a_np)
Expand All @@ -43,7 +47,7 @@ def test_basic(self, mode):
else:
assert_array_equal(result, expected)

@pytest.mark.parametrize("mode", _all_modes.keys())
@pytest.mark.parametrize("mode", _modes)
def test_memory_layout_persistence(self, mode):
"""Test if C and F order is preserved for all pad modes."""
x = dpnp.ones((5, 10), order="C")
Expand All @@ -52,13 +56,13 @@ def test_memory_layout_persistence(self, mode):
assert dpnp.pad(x, 5, mode).flags.f_contiguous

@pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True))
@pytest.mark.parametrize("mode", _all_modes.keys())
@pytest.mark.parametrize("mode", _modes)
def test_dtype_persistence(self, dtype, mode):
arr = dpnp.zeros((3, 2, 1), dtype=dtype)
result = dpnp.pad(arr, 1, mode=mode)
assert result.dtype == dtype

@pytest.mark.parametrize("mode", _all_modes.keys())
@pytest.mark.parametrize("mode", _modes)
def test_non_contiguous_array(self, mode):
a_np = numpy.arange(24).reshape(4, 6)[::2, ::2]
a_dp = dpnp.arange(24).reshape(4, 6)[::2, ::2]
Expand All @@ -73,12 +77,14 @@ def test_non_contiguous_array(self, mode):

# TODO: include "linear_ramp" when dpnp issue gh-2084 is resolved
@pytest.mark.parametrize("pad_width", [0, (0, 0), ((0, 0), (0, 0))])
@pytest.mark.parametrize("mode", _all_modes.keys() - {"linear_ramp"})
@pytest.mark.parametrize(
"mode", [m for m in _modes if m not in {"linear_ramp"}]
)
def test_zero_pad_width(self, pad_width, mode):
arr = dpnp.arange(30).reshape(6, 5)
assert_array_equal(arr, dpnp.pad(arr, pad_width, mode=mode))

@pytest.mark.parametrize("mode", _all_modes.keys())
@pytest.mark.parametrize("mode", _modes)
def test_pad_non_empty_dimension(self, mode):
a_np = numpy.ones((2, 0, 2))
a_dp = dpnp.array(a_np)
Expand All @@ -95,14 +101,14 @@ def test_pad_non_empty_dimension(self, mode):
((3, 4, 5), (0, 1, 2)),
],
)
@pytest.mark.parametrize("mode", _all_modes.keys())
@pytest.mark.parametrize("mode", _modes)
def test_misshaped_pad_width1(self, pad_width, mode):
arr = dpnp.arange(30).reshape((6, 5))
match = "operands could not be broadcast together"
with pytest.raises(ValueError, match=match):
dpnp.pad(arr, pad_width, mode)

@pytest.mark.parametrize("mode", _all_modes.keys())
@pytest.mark.parametrize("mode", _modes)
def test_misshaped_pad_width2(self, mode):
arr = dpnp.arange(30).reshape((6, 5))
match = (
Expand All @@ -115,7 +121,7 @@ def test_misshaped_pad_width2(self, mode):
@pytest.mark.parametrize(
"pad_width", [-2, (-2,), (3, -1), ((5, 2), (-2, 3)), ((-4,), (2,))]
)
@pytest.mark.parametrize("mode", _all_modes.keys())
@pytest.mark.parametrize("mode", _modes)
def test_negative_pad_width(self, pad_width, mode):
arr = dpnp.arange(30).reshape((6, 5))
match = "index can't contain negative values"
Expand All @@ -126,14 +132,14 @@ def test_negative_pad_width(self, pad_width, mode):
"pad_width",
["3", "word", None, 3.4, complex(1, -1), ((-2.1, 3), (3, 2))],
)
@pytest.mark.parametrize("mode", _all_modes.keys())
@pytest.mark.parametrize("mode", _modes)
def test_bad_type(self, pad_width, mode):
arr = dpnp.arange(30).reshape((6, 5))
match = "`pad_width` must be of integral type."
with pytest.raises(TypeError, match=match):
dpnp.pad(arr, pad_width, mode)

@pytest.mark.parametrize("mode", _all_modes.keys())
@pytest.mark.parametrize("mode", _modes)
def test_kwargs(self, mode):
"""Test behavior of pad's kwargs for the given mode."""
allowed = self._all_modes[mode]
Expand Down Expand Up @@ -439,7 +445,7 @@ def test_pad_empty_dim_valid(self, mode):

@pytest.mark.parametrize(
"mode",
_all_modes.keys() - {"constant", "empty"},
[m for m in _modes if m not in {"constant", "empty"}],
)
def test_pad_empty_dim_invalid(self, mode):
match = (
Expand Down
Loading
Loading