Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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: 1 addition & 1 deletion dpnp/dpnp_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class dpnp_array:
def __init__(
self,
shape,
dtype="f8",
dtype=None,
buffer=None,
offset=0,
strides=None,
Expand Down
1 change: 1 addition & 0 deletions tests/helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from sys import platform

import dpctl
import pytest
Comment thread
vlad-perevezentsev marked this conversation as resolved.
Outdated

import dpnp

Expand Down
42 changes: 5 additions & 37 deletions tests/skipped_tests.tbl
Original file line number Diff line number Diff line change
Expand Up @@ -39,43 +39,11 @@ tests/third_party/intel/test_zero_copy_test1.py::test_dpnp_interaction_with_dpct
tests/test_arraymanipulation.py::TestHstack::test_generator
tests/test_arraymanipulation.py::TestVstack::test_generator

tests/test_dparray.py::test_astype[[]-float64-float64]
tests/test_dparray.py::test_astype[[]-float64-float32]
tests/test_dparray.py::test_astype[[]-float64-int64]
tests/test_dparray.py::test_astype[[]-float64-int32]
tests/test_dparray.py::test_astype[[]-float64-bool]
tests/test_dparray.py::test_astype[[]-float64-complex]
tests/test_dparray.py::test_astype[[]-float32-float64]
tests/test_dparray.py::test_astype[[]-float32-float32]
tests/test_dparray.py::test_astype[[]-float32-int64]
tests/test_dparray.py::test_astype[[]-float32-int32]
tests/test_dparray.py::test_astype[[]-float32-bool]
tests/test_dparray.py::test_astype[[]-float32-complex]
tests/test_dparray.py::test_astype[[]-int64-float64]
tests/test_dparray.py::test_astype[[]-int64-float32]
tests/test_dparray.py::test_astype[[]-int64-int64]
tests/test_dparray.py::test_astype[[]-int64-int32]
tests/test_dparray.py::test_astype[[]-int64-bool]
tests/test_dparray.py::test_astype[[]-int64-complex]
tests/test_dparray.py::test_astype[[]-int32-float64]
tests/test_dparray.py::test_astype[[]-int32-float32]
tests/test_dparray.py::test_astype[[]-int32-int64]
tests/test_dparray.py::test_astype[[]-int32-int32]
tests/test_dparray.py::test_astype[[]-int32-bool]
tests/test_dparray.py::test_astype[[]-int32-complex]
tests/test_dparray.py::test_astype[[]-bool-float64]
tests/test_dparray.py::test_astype[[]-bool-float32]
tests/test_dparray.py::test_astype[[]-bool-int64]
tests/test_dparray.py::test_astype[[]-bool-int32]
tests/test_dparray.py::test_astype[[]-bool-bool]
tests/test_dparray.py::test_astype[[]-bool-complex]
tests/test_dparray.py::test_astype[[]-complex-float64]
tests/test_dparray.py::test_astype[[]-complex-float32]
tests/test_dparray.py::test_astype[[]-complex-int64]
tests/test_dparray.py::test_astype[[]-complex-int32]
tests/test_dparray.py::test_astype[[]-complex-bool]
tests/test_dparray.py::test_astype[[]-complex-complex]

tests/test_linalg.py::test_cond[None-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
tests/test_linalg.py::test_cond[None-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
tests/test_linalg.py::test_cond[1-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
tests/test_linalg.py::test_cond[1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
tests/test_linalg.py::test_cond[-1-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
tests/test_linalg.py::test_cond[-1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
tests/test_linalg.py::test_cond[1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
tests/test_linalg.py::test_cond[-2-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
Expand Down
37 changes: 0 additions & 37 deletions tests/skipped_tests_gpu.tbl
Original file line number Diff line number Diff line change
Expand Up @@ -239,43 +239,6 @@ tests/third_party/intel/test_zero_copy_test1.py::test_dpnp_interaction_with_dpct
tests/test_arraymanipulation.py::TestHstack::test_generator
tests/test_arraymanipulation.py::TestVstack::test_generator

tests/test_dparray.py::test_astype[[]-float64-float64]
tests/test_dparray.py::test_astype[[]-float64-float32]
tests/test_dparray.py::test_astype[[]-float64-int64]
tests/test_dparray.py::test_astype[[]-float64-int32]
tests/test_dparray.py::test_astype[[]-float64-bool]
tests/test_dparray.py::test_astype[[]-float64-complex]
tests/test_dparray.py::test_astype[[]-float32-float64]
tests/test_dparray.py::test_astype[[]-float32-float32]
tests/test_dparray.py::test_astype[[]-float32-int64]
tests/test_dparray.py::test_astype[[]-float32-int32]
tests/test_dparray.py::test_astype[[]-float32-bool]
tests/test_dparray.py::test_astype[[]-float32-complex]
tests/test_dparray.py::test_astype[[]-int64-float64]
tests/test_dparray.py::test_astype[[]-int64-float32]
tests/test_dparray.py::test_astype[[]-int64-int64]
tests/test_dparray.py::test_astype[[]-int64-int32]
tests/test_dparray.py::test_astype[[]-int64-bool]
tests/test_dparray.py::test_astype[[]-int64-complex]
tests/test_dparray.py::test_astype[[]-int32-float64]
tests/test_dparray.py::test_astype[[]-int32-float32]
tests/test_dparray.py::test_astype[[]-int32-int64]
tests/test_dparray.py::test_astype[[]-int32-int32]
tests/test_dparray.py::test_astype[[]-int32-bool]
tests/test_dparray.py::test_astype[[]-int32-complex]
tests/test_dparray.py::test_astype[[]-bool-float64]
tests/test_dparray.py::test_astype[[]-bool-float32]
tests/test_dparray.py::test_astype[[]-bool-int64]
tests/test_dparray.py::test_astype[[]-bool-int32]
tests/test_dparray.py::test_astype[[]-bool-bool]
tests/test_dparray.py::test_astype[[]-bool-complex]
tests/test_dparray.py::test_astype[[]-complex-float64]
tests/test_dparray.py::test_astype[[]-complex-float32]
tests/test_dparray.py::test_astype[[]-complex-int64]
tests/test_dparray.py::test_astype[[]-complex-int32]
tests/test_dparray.py::test_astype[[]-complex-bool]
tests/test_dparray.py::test_astype[[]-complex-complex]

tests/test_linalg.py::test_cond[-1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
tests/test_linalg.py::test_cond[1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
tests/test_linalg.py::test_cond[-2-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
Expand Down
51 changes: 18 additions & 33 deletions tests/test_amin_amax.py
Original file line number Diff line number Diff line change
@@ -1,61 +1,46 @@
import numpy
import pytest
from numpy.testing import assert_allclose, assert_array_equal

import dpnp

from .helper import get_all_dtypes

@pytest.mark.parametrize("type", [numpy.float64], ids=["float64"])
def test_amax_float64(type):

@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True))
def test_amax(dtype):
a = numpy.array(
[
[[-2.0, 3.0], [9.1, 0.2]],
[[-2.0, 5.0], [-2, -1.2]],
[[1.0, -2.0], [5.0, -1.1]],
]
],
dtype=dtype,
)
ia = dpnp.array(a)

for axis in range(len(a)):
result = dpnp.amax(ia, axis=axis)
expected = numpy.amax(a, axis=axis)
numpy.testing.assert_array_equal(expected, result)


@pytest.mark.parametrize("type", [numpy.int64], ids=["int64"])
def test_amax_int(type):
a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9])
ia = dpnp.array(a)

result = dpnp.amax(ia)
expected = numpy.amax(a)
numpy.testing.assert_array_equal(expected, result)
assert_allclose(expected, result)


@pytest.mark.parametrize("type", [numpy.float64], ids=["float64"])
def test_amin_float64(type):
@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True))
def test_amin(dtype):
a = numpy.array(
[
[[-2.0, 3.0], [9.1, 0.2]],
[[-2.0, 5.0], [-2, -1.2]],
[[1.0, -2.0], [5.0, -1.1]],
]
],
dtype=dtype,
)
ia = dpnp.array(a)

for axis in range(len(a)):
result = dpnp.amin(ia, axis=axis)
expected = numpy.amin(a, axis=axis)
numpy.testing.assert_array_equal(expected, result)


@pytest.mark.parametrize("type", [numpy.int64], ids=["int64"])
def test_amin_int(type):
a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9])
ia = dpnp.array(a)

result = dpnp.amin(ia)
expected = numpy.amin(a)
numpy.testing.assert_array_equal(expected, result)
assert_allclose(expected, result)


def _get_min_max_input(type, shape):
Expand All @@ -79,14 +64,14 @@ def _get_min_max_input(type, shape):
@pytest.mark.parametrize(
"shape", [(4,), (2, 3), (4, 5, 6)], ids=["(4,)", "(2,3)", "(4,5,6)"]
)
def test_amax(type, shape):
def test_amax_diff_shape(type, shape):
a = _get_min_max_input(type, shape)

ia = dpnp.array(a)
Comment thread
vlad-perevezentsev marked this conversation as resolved.

np_res = numpy.amax(a)
dpnp_res = dpnp.amax(ia)
numpy.testing.assert_array_equal(dpnp_res, np_res)
assert_array_equal(dpnp_res, np_res)

np_res = a.max()
dpnp_res = ia.max()
Expand All @@ -102,15 +87,15 @@ def test_amax(type, shape):
@pytest.mark.parametrize(
"shape", [(4,), (2, 3), (4, 5, 6)], ids=["(4,)", "(2,3)", "(4,5,6)"]
)
def test_amin(type, shape):
def test_amin_diff_shape(type, shape):
Comment thread
vlad-perevezentsev marked this conversation as resolved.
Outdated
a = _get_min_max_input(type, shape)

ia = dpnp.array(a)

np_res = numpy.amin(a)
dpnp_res = dpnp.amin(ia)
numpy.testing.assert_array_equal(dpnp_res, np_res)
assert_array_equal(dpnp_res, np_res)

np_res = a.min()
dpnp_res = ia.min()
numpy.testing.assert_array_equal(dpnp_res, np_res)
assert_array_equal(dpnp_res, np_res)
24 changes: 21 additions & 3 deletions tests/test_arraycreation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

import dpnp

from .helper import get_all_dtypes
from .helper import (
get_all_dtypes,
has_support_aspect64,
)


@pytest.mark.parametrize(
Expand Down Expand Up @@ -115,7 +118,12 @@ def test_eye(N, M, k, dtype, order):


@pytest.mark.usefixtures("allow_fall_back_on_numpy")
@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False))
@pytest.mark.parametrize(
"dtype",
get_all_dtypes(
no_float16=False, no_none=False if has_support_aspect64() else True
),
)
def test_frombuffer(dtype):
buffer = b"12345678ABCDEF00"
func = lambda xp: xp.frombuffer(buffer, dtype=dtype)
Expand Down Expand Up @@ -607,7 +615,17 @@ def test_linspace(start, stop, num, dtype):
if numpy.issubdtype(dtype, dpnp.integer):
assert_allclose(func(numpy), func(dpnp), rtol=1)
else:
assert_allclose(func(numpy), func(dpnp), atol=numpy.finfo(dtype).eps)
if dtype is None and not has_support_aspect64():
assert_allclose(
func(numpy),
func(dpnp),
rtol=1e-06,
atol=numpy.finfo("float32").eps,
)
else:
assert_allclose(
func(numpy), func(dpnp), rtol=1e-06, atol=numpy.finfo(dtype).eps
)
Comment thread
vlad-perevezentsev marked this conversation as resolved.
Outdated


@pytest.mark.parametrize(
Expand Down
Loading