Skip to content

Commit fd798c5

Browse files
authored
Merge branch 'master' into impl-blackman
2 parents 974287b + 58bd91e commit fd798c5

File tree

8 files changed

+194
-265
lines changed

8 files changed

+194
-265
lines changed

dpnp/dpnp_iface_counting.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,19 @@ def count_nonzero(a, axis=None, *, keepdims=False, out=None):
5858
Axis or tuple of axes along which to count non-zeros.
5959
Default value means that non-zeros will be counted along a flattened
6060
version of `a`.
61+
6162
Default: ``None``.
62-
keepdims : bool, optional
63+
keepdims : {None, bool}, optional
6364
If this is set to ``True``, the axes that are counted are left in the
6465
result as dimensions with size one. With this option, the result will
6566
broadcast correctly against the input array.
67+
6668
Default: ``False``.
6769
out : {None, dpnp.ndarray, usm_ndarray}, optional
6870
The array into which the result is written. The data type of `out` must
6971
match the expected shape and the expected data type of the result.
7072
If ``None`` then a new array is returned.
73+
7174
Default: ``None``.
7275
7376
Returns

dpnp/tests/test_indexing.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,15 +1200,17 @@ def test_empty_indices_error(self):
12001200
)
12011201

12021202
def test_empty_indices(self):
1203-
assert_equal(
1204-
dpnp.ravel_multi_index(
1205-
(dpnp.array([], dtype=int), dpnp.array([], dtype=int)), (5, 3)
1206-
),
1207-
[],
1208-
)
1209-
assert_equal(
1210-
dpnp.ravel_multi_index(dpnp.array([[], []], dtype=int), (5, 3)), []
1211-
)
1203+
a = numpy.array([], dtype=int)
1204+
ia = dpnp.array(a)
1205+
result = dpnp.ravel_multi_index((ia, ia), (5, 3))
1206+
expected = numpy.ravel_multi_index((a, a), (5, 3))
1207+
assert_equal(result, expected)
1208+
1209+
a = numpy.array([[], []], dtype=int)
1210+
ia = dpnp.array(a)
1211+
result = dpnp.ravel_multi_index(ia, (5, 3))
1212+
expected = numpy.ravel_multi_index(a, (5, 3))
1213+
assert_equal(result, expected)
12121214

12131215

12141216
class TestUnravelIndex:

dpnp/tests/test_linalg.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ def test_empty(self, shape, p):
293293
expected = numpy.linalg.cond(a, p=p)
294294
assert_dtype_allclose(result, expected)
295295

296-
@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True))
296+
@pytest.mark.parametrize(
297+
"dtype", get_all_dtypes(no_none=True, no_bool=True)
298+
)
297299
@pytest.mark.parametrize(
298300
"shape", [(4, 4), (2, 4, 3, 3)], ids=["(4, 4)", "(2, 4, 3, 3)"]
299301
)
@@ -2408,10 +2410,8 @@ def test_qr(self, dtype, shape, mode):
24082410
if mode in ("complete", "reduced"):
24092411
result = dpnp.linalg.qr(ia, mode)
24102412
dpnp_q, dpnp_r = result.Q, result.R
2411-
assert_almost_equal(
2412-
dpnp.matmul(dpnp_q, dpnp_r),
2413-
a,
2414-
decimal=5,
2413+
assert dpnp.allclose(
2414+
dpnp.matmul(dpnp_q, dpnp_r), ia, atol=1e-05
24152415
)
24162416
else: # mode=="raw"
24172417
dpnp_q, dpnp_r = dpnp.linalg.qr(ia, mode)
@@ -2424,15 +2424,13 @@ def test_qr(self, dtype, shape, mode):
24242424
@pytest.mark.parametrize(
24252425
"shape",
24262426
[(32, 32), (8, 16, 16)],
2427-
ids=[
2428-
"(32, 32)",
2429-
"(8, 16, 16)",
2430-
],
2427+
ids=["(32, 32)", "(8, 16, 16)"],
24312428
)
24322429
@pytest.mark.parametrize("mode", ["r", "raw", "complete", "reduced"])
24332430
def test_qr_large(self, dtype, shape, mode):
24342431
a = generate_random_numpy_array(shape, dtype, seed_value=81)
24352432
ia = dpnp.array(a)
2433+
24362434
if mode == "r":
24372435
np_r = numpy.linalg.qr(a, mode)
24382436
dpnp_r = dpnp.linalg.qr(ia, mode)
@@ -2443,11 +2441,7 @@ def test_qr_large(self, dtype, shape, mode):
24432441
if mode in ("complete", "reduced"):
24442442
result = dpnp.linalg.qr(ia, mode)
24452443
dpnp_q, dpnp_r = result.Q, result.R
2446-
assert_almost_equal(
2447-
dpnp.matmul(dpnp_q, dpnp_r),
2448-
a,
2449-
decimal=5,
2450-
)
2444+
assert dpnp.allclose(dpnp.matmul(dpnp_q, dpnp_r), ia, atol=1e-5)
24512445
else: # mode=="raw"
24522446
dpnp_q, dpnp_r = dpnp.linalg.qr(ia, mode)
24532447
assert_allclose(dpnp_q, np_q, atol=1e-4)
@@ -3169,9 +3163,7 @@ def test_test_tensorinv_errors(self):
31693163
class TestTensorsolve:
31703164
@pytest.mark.parametrize("dtype", get_all_dtypes())
31713165
@pytest.mark.parametrize(
3172-
"axes",
3173-
[None, (1,), (2,)],
3174-
ids=["None", "(1,)", "(2,)"],
3166+
"axes", [None, (1,), (2,)], ids=["None", "(1,)", "(2,)"]
31753167
)
31763168
def test_tensorsolve_axes(self, dtype, axes):
31773169
a = numpy.eye(12).reshape(12, 3, 4).astype(dtype)

0 commit comments

Comments
 (0)