@@ -414,14 +414,14 @@ def max(a, axis=None, out=None, keepdims=False, initial=None, where=True):
414
414
axis = (axis ,) if isinstance (axis , int ) else axis
415
415
for i in range (a .ndim ):
416
416
if a .shape [i ] == 0 :
417
- if i not in axis :
418
- indices = [i for i in range (a .ndim ) if i not in axis ]
419
- res_shape = tuple ([a .shape [i ] for i in indices ])
420
- result = dpnp .empty (res_shape , dtype = a .dtype )
421
- else :
417
+ if axis is None or i in axis :
422
418
raise ValueError (
423
419
"reduction does not support zero-size arrays"
424
420
)
421
+ else :
422
+ indices = [i for i in range (a .ndim ) if i not in axis ]
423
+ res_shape = tuple ([a .shape [i ] for i in indices ])
424
+ result = dpnp .empty (res_shape , dtype = a .dtype )
425
425
else :
426
426
result = dpnp_array ._create_from_usm_ndarray (
427
427
dpt .max (dpt_array , axis = axis , keepdims = keepdims )
@@ -658,14 +658,14 @@ def min(a, axis=None, out=None, keepdims=False, initial=None, where=True):
658
658
# TODO: get rid of this if condition when dpctl supports it
659
659
for i in range (a .ndim ):
660
660
if a .shape [i ] == 0 :
661
- if i not in axis :
662
- indices = [i for i in range (a .ndim ) if i not in axis ]
663
- res_shape = tuple ([a .shape [i ] for i in indices ])
664
- result = dpnp .empty (res_shape , dtype = a .dtype )
665
- else :
661
+ if axis is None or i in axis :
666
662
raise ValueError (
667
663
"reduction does not support zero-size arrays"
668
664
)
665
+ else :
666
+ indices = [i for i in range (a .ndim ) if i not in axis ]
667
+ res_shape = tuple ([a .shape [i ] for i in indices ])
668
+ result = dpnp .empty (res_shape , dtype = a .dtype )
669
669
else :
670
670
result = dpnp_array ._create_from_usm_ndarray (
671
671
dpt .min (dpt_array , axis = axis , keepdims = keepdims )
0 commit comments