@@ -413,14 +413,14 @@ def max(a, axis=None, out=None, keepdims=False, initial=None, where=True):
413
413
# TODO: get rid of this if condition when dpctl supports it
414
414
for i in range (a .ndim ):
415
415
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 :
421
417
raise ValueError (
422
418
"reduction does not support zero-size arrays"
423
419
)
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 )
424
424
else :
425
425
result = dpnp_array ._create_from_usm_ndarray (
426
426
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):
657
657
# TODO: get rid of this if condition when dpctl supports it
658
658
for i in range (a .ndim ):
659
659
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 :
665
661
raise ValueError (
666
662
"reduction does not support zero-size arrays"
667
663
)
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 )
668
668
else :
669
669
result = dpnp_array ._create_from_usm_ndarray (
670
670
dpt .min (dpt_array , axis = axis , keepdims = keepdims )
0 commit comments