Skip to content

Commit 665d0b8

Browse files
author
Vahid Tavanashad
committed
address comments
1 parent 466fd8d commit 665d0b8

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

dpnp/dpnp_iface_mathematical.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,8 +1163,8 @@ def cumsum(a, axis=None, dtype=None, out=None):
11631163
[4, 5, 6]])
11641164
>>> np.cumsum(a)
11651165
array([ 1, 3, 6, 10, 15, 21])
1166-
>>> np.cumsum(a, dtype=float) # specifies type of output value(s)
1167-
array([ 1., 3., 6., 10., 15., 21.])
1166+
>>> np.cumsum(a, dtype=np.float32) # specifies type of output value(s)
1167+
array([ 1., 3., 6., 10., 15., 21.], dtype=np.float32)
11681168
11691169
>>> np.cumsum(a, axis=0) # sum over rows for each of the 3 columns
11701170
array([[1, 2, 3],
@@ -1175,8 +1175,8 @@ def cumsum(a, axis=None, dtype=None, out=None):
11751175
11761176
``cumsum(b)[-1]`` may not be equal to ``sum(b)``
11771177
1178-
>>> b = np.array([1, 2e-9, 3e-9] * 10000)
1179-
>>> b.cumsum().dtype == b.sum().dtype == np.float64
1178+
>>> b = np.array([1, 2e-7, 3e-7] * 100000, dtype=np.float32)
1179+
>>> b.cumsum().dtype == b.sum().dtype == np.float32
11801180
True
11811181
>>> b.cumsum()[-1] == b.sum()
11821182
array(False)
@@ -1208,16 +1208,16 @@ def cumulative_prod(
12081208
12091209
This function is an Array API compatible alternative to :obj:`dpnp.cumprod`.
12101210
1211-
For full documentation refer to :obj:`numpy.cumprod`.
1211+
For full documentation refer to :obj:`numpy.cumulative_prod`.
12121212
12131213
Parameters
12141214
----------
12151215
x : {dpnp.ndarray, usm_ndarray}
12161216
Input array.
12171217
axis : {None, int}, optional
1218-
Axis along which the cumulative product is computed. The default
1219-
(``None``) is only allowed for one-dimensional arrays. For arrays
1220-
with more than one dimension `axis` is required.
1218+
Axis along which the cumulative product is computed. The default value
1219+
is only allowed for one-dimensional arrays. For arrays with more than
1220+
one dimension `axis` is required.
12211221
Default: ``None``.
12221222
dtype : {None, dtype}, optional
12231223
Type of the returned array and of the accumulator in which the elements
@@ -1262,13 +1262,13 @@ def cumulative_prod(
12621262
The cumulative product for each column (i.e., over the rows) of `b`:
12631263
12641264
>>> b = np.array([[1, 2, 3], [4, 5, 6]])
1265-
>>> np.cumulative_prod(a, axis=0)
1265+
>>> np.cumulative_prod(b, axis=0)
12661266
array([[ 1, 2, 3],
12671267
[ 4, 10, 18]])
12681268
12691269
The cumulative product for each row (i.e. over the columns) of `b`:
12701270
1271-
>>> np.cumulative_prod(a, axis=1)
1271+
>>> np.cumulative_prod(b, axis=1)
12721272
array([[ 1, 2, 6],
12731273
[ 4, 20, 120]])
12741274
@@ -1294,14 +1294,14 @@ def cumulative_sum(
12941294
12951295
This function is an Array API compatible alternative to :obj:`dpnp.cumsum`.
12961296
1297-
For full documentation refer to :obj:`numpy.cumsum`.
1297+
For full documentation refer to :obj:`numpy.cumulative_sum`.
12981298
12991299
Parameters
13001300
----------
13011301
x : {dpnp.ndarray, usm_ndarray}
13021302
Input array.
13031303
axis : {None, int}, optional
1304-
Axis along which the cumulative sum is computed. The default (``None``)
1304+
Axis along which the cumulative sum is computed. The default value
13051305
is only allowed for one-dimensional arrays. For arrays with more than
13061306
one dimension `axis` is required.
13071307
Default: ``None``.
@@ -1345,21 +1345,21 @@ def cumulative_sum(
13451345
array([1, 2, 3, 4, 5, 6])
13461346
>>> np.cumulative_sum(a)
13471347
array([ 1, 3, 6, 10, 15, 21])
1348-
>>> np.cumulative_sum(a, dtype=float) # specifies type of output value(s)
1349-
array([ 1., 3., 6., 10., 15., 21.])
1348+
>>> np.cumulative_sum(a, dtype=np.float32) # specifies output dtype
1349+
array([ 1., 3., 6., 10., 15., 21.], dtype=np.float32)
13501350
13511351
>>> b = np.array([[1, 2, 3], [4, 5, 6]])
1352-
>>> np.cumsum(b, axis=0) # sum over rows for each of the 3 columns
1352+
>>> np.cumulative_sum(b, axis=0) # sum over rows for each of the 3 columns
13531353
array([[1, 2, 3],
13541354
[5, 7, 9]])
1355-
>>> np.cumsum(b, axis=1) # sum over columns for each of the 2 rows
1355+
>>> np.cumulative_sum(b, axis=1) # sum over columns for each of the 2 rows
13561356
array([[ 1, 3, 6],
13571357
[ 4, 9, 15]])
13581358
13591359
``cumulative_sum(c)[-1]`` may not be equal to ``sum(c)``
13601360
1361-
>>> c = np.array([1, 2e-9, 3e-9] * 1000000)
1362-
>>> np.cumulative_sum(c).dtype == c.sum().dtype == np.float64
1361+
>>> c = np.array([1, 2e-7, 3e-7] * 100000, dtype=np.float32)
1362+
>>> np.cumulative_sum(c).dtype == c.sum().dtype == np.float32
13631363
True
13641364
>>> np.cumulative_sum(c)[-1] == c.sum()
13651365
array(False)

tests/test_mathematical.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def test_out_dtype(self, arr_dt, out_dt, dtype):
424424
assert_array_equal(expected, result)
425425
assert result is iout
426426

427-
@testing.with_requires("numpy>=2.0.0")
427+
@testing.with_requires("numpy>=2.1.0")
428428
def test_include_initial(self):
429429
a = numpy.arange(8).reshape(2, 2, 2)
430430
ia = dpnp.array(a)
@@ -528,7 +528,7 @@ def test_out_dtype(self, arr_dt, out_dt, dtype):
528528
assert_array_equal(expected, result)
529529
assert result is iout
530530

531-
@testing.with_requires("numpy>=2.0.0")
531+
@testing.with_requires("numpy>=2.1.0")
532532
def test_include_initial(self):
533533
a = numpy.arange(8).reshape(2, 2, 2)
534534
ia = dpnp.array(a)

tests/test_sycl_queue.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,8 @@ def test_meshgrid(device):
450450
pytest.param("count_nonzero", [3, 0, 2, -1.2]),
451451
pytest.param("cumprod", [[1, 2, 3], [4, 5, 6]]),
452452
pytest.param("cumsum", [[1, 2, 3], [4, 5, 6]]),
453+
pytest.param("cumulative_prod", [1, 2, 3, 4, 5, 6]),
454+
pytest.param("cumulative_sum", [1, 2, 3, 4, 5, 6]),
453455
pytest.param("degrees", [numpy.pi, numpy.pi / 2, 0]),
454456
pytest.param("diagonal", [[[1, 2], [3, 4]]]),
455457
pytest.param("diff", [1.0, 2.0, 4.0, 7.0, 0.0]),

tests/test_usm_type.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,8 @@ def test_norm(usm_type, ord, axis):
585585
pytest.param("cumlogsumexp", [1.0, 2.0, 4.0, 7.0]),
586586
pytest.param("cumprod", [[1, 2, 3], [4, 5, 6]]),
587587
pytest.param("cumsum", [[1, 2, 3], [4, 5, 6]]),
588+
pytest.param("cumulative_prod", [1, 2, 3, 4, 5, 6]),
589+
pytest.param("cumulative_sum", [1, 2, 3, 4, 5, 6]),
588590
pytest.param("degrees", [numpy.pi, numpy.pi / 2, 0]),
589591
pytest.param("diagonal", [[[1, 2], [3, 4]]]),
590592
pytest.param("diff", [1.0, 2.0, 4.0, 7.0, 0.0]),

0 commit comments

Comments
 (0)