Skip to content
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
20 changes: 11 additions & 9 deletions dpnp/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,15 +1200,17 @@ def test_empty_indices_error(self):
)

def test_empty_indices(self):
assert_equal(
dpnp.ravel_multi_index(
(dpnp.array([], dtype=int), dpnp.array([], dtype=int)), (5, 3)
),
[],
)
assert_equal(
dpnp.ravel_multi_index(dpnp.array([[], []], dtype=int), (5, 3)), []
)
a = numpy.array([], dtype=int)
ia = dpnp.array(a)
result = dpnp.ravel_multi_index((ia, ia), (5, 3))
expected = numpy.ravel_multi_index((a, a), (5, 3))
assert_equal(result, expected)

a = numpy.array([[], []], dtype=int)
ia = dpnp.array(a)
result = dpnp.ravel_multi_index(ia, (5, 3))
expected = numpy.ravel_multi_index(a, (5, 3))
assert_equal(result, expected)


class TestUnravelIndex:
Expand Down
26 changes: 9 additions & 17 deletions dpnp/tests/test_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ def test_empty(self, shape, p):
expected = numpy.linalg.cond(a, p=p)
assert_dtype_allclose(result, expected)

@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True))
@pytest.mark.parametrize(
"dtype", get_all_dtypes(no_none=True, no_bool=True)
)
@pytest.mark.parametrize(
"shape", [(4, 4), (2, 4, 3, 3)], ids=["(4, 4)", "(2, 4, 3, 3)"]
)
Expand Down Expand Up @@ -2408,10 +2410,8 @@ def test_qr(self, dtype, shape, mode):
if mode in ("complete", "reduced"):
result = dpnp.linalg.qr(ia, mode)
dpnp_q, dpnp_r = result.Q, result.R
assert_almost_equal(
dpnp.matmul(dpnp_q, dpnp_r),
a,
decimal=5,
assert dpnp.allclose(
dpnp.matmul(dpnp_q, dpnp_r), ia, atol=1e-05
)
else: # mode=="raw"
dpnp_q, dpnp_r = dpnp.linalg.qr(ia, mode)
Expand All @@ -2424,15 +2424,13 @@ def test_qr(self, dtype, shape, mode):
@pytest.mark.parametrize(
"shape",
[(32, 32), (8, 16, 16)],
ids=[
"(32, 32)",
"(8, 16, 16)",
],
ids=["(32, 32)", "(8, 16, 16)"],
)
@pytest.mark.parametrize("mode", ["r", "raw", "complete", "reduced"])
def test_qr_large(self, dtype, shape, mode):
a = generate_random_numpy_array(shape, dtype, seed_value=81)
ia = dpnp.array(a)

if mode == "r":
np_r = numpy.linalg.qr(a, mode)
dpnp_r = dpnp.linalg.qr(ia, mode)
Expand All @@ -2443,11 +2441,7 @@ def test_qr_large(self, dtype, shape, mode):
if mode in ("complete", "reduced"):
result = dpnp.linalg.qr(ia, mode)
dpnp_q, dpnp_r = result.Q, result.R
assert_almost_equal(
dpnp.matmul(dpnp_q, dpnp_r),
a,
decimal=5,
)
assert dpnp.allclose(dpnp.matmul(dpnp_q, dpnp_r), ia, atol=1e-5)
else: # mode=="raw"
dpnp_q, dpnp_r = dpnp.linalg.qr(ia, mode)
assert_allclose(dpnp_q, np_q, atol=1e-4)
Expand Down Expand Up @@ -3169,9 +3163,7 @@ def test_test_tensorinv_errors(self):
class TestTensorsolve:
@pytest.mark.parametrize("dtype", get_all_dtypes())
@pytest.mark.parametrize(
"axes",
[None, (1,), (2,)],
ids=["None", "(1,)", "(2,)"],
"axes", [None, (1,), (2,)], ids=["None", "(1,)", "(2,)"]
)
def test_tensorsolve_axes(self, dtype, axes):
a = numpy.eye(12).reshape(12, 3, 4).astype(dtype)
Expand Down
Loading
Loading