Skip to content

Commit 5401195

Browse files
committed
add axis==None condition for zero-size array
1 parent 6cd7272 commit 5401195

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

dpnp/dpnp_iface_statistics.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -413,14 +413,14 @@ def max(a, axis=None, out=None, keepdims=False, initial=None, where=True):
413413
# TODO: get rid of this if condition when dpctl supports it
414414
for i in range(a.ndim):
415415
if a.shape[i] == 0:
416-
if i not in axis:
417-
indices = [i for i in range(a.ndim) if i not in axis]
418-
res_shape = tuple([a.shape[i] for i in indices])
419-
result = dpnp.empty(res_shape, dtype=a.dtype)
420-
else:
416+
if axis is None or i in axis:
421417
raise ValueError(
422418
"reduction does not support zero-size arrays"
423419
)
420+
else:
421+
indices = [i for i in range(a.ndim) if i not in axis]
422+
res_shape = tuple([a.shape[i] for i in indices])
423+
result = dpnp.empty(res_shape, dtype=a.dtype)
424424
else:
425425
result = dpnp_array._create_from_usm_ndarray(
426426
dpt.max(dpt_array, axis=axis, keepdims=keepdims)
@@ -657,14 +657,14 @@ def min(a, axis=None, out=None, keepdims=False, initial=None, where=True):
657657
# TODO: get rid of this if condition when dpctl supports it
658658
for i in range(a.ndim):
659659
if a.shape[i] == 0:
660-
if i not in axis:
661-
indices = [i for i in range(a.ndim) if i not in axis]
662-
res_shape = tuple([a.shape[i] for i in indices])
663-
result = dpnp.empty(res_shape, dtype=a.dtype)
664-
else:
660+
if axis is None or i in axis:
665661
raise ValueError(
666662
"reduction does not support zero-size arrays"
667663
)
664+
else:
665+
indices = [i for i in range(a.ndim) if i not in axis]
666+
res_shape = tuple([a.shape[i] for i in indices])
667+
result = dpnp.empty(res_shape, dtype=a.dtype)
668668
else:
669669
result = dpnp_array._create_from_usm_ndarray(
670670
dpt.min(dpt_array, axis=axis, keepdims=keepdims)

0 commit comments

Comments
 (0)