@@ -2075,9 +2075,6 @@ def test_matrix_transpose():
2075
2075
2076
2076
2077
2077
class TestNorm :
2078
- def setup_method (self ):
2079
- numpy .random .seed (42 )
2080
-
2081
2078
@pytest .mark .usefixtures ("suppress_divide_numpy_warnings" )
2082
2079
@pytest .mark .parametrize (
2083
2080
"shape" , [(0 ,), (5 , 0 ), (2 , 0 , 3 )], ids = ["(0,)" , "(5, 0)" , "(2, 0, 3)" ]
@@ -2099,15 +2096,16 @@ def test_empty(self, shape, ord, axis, keepdims):
2099
2096
# Improper number of dimensions to norm
2100
2097
assert_raises (ValueError , dpnp .linalg .norm , ia , ** kwarg )
2101
2098
assert_raises (ValueError , numpy .linalg .norm , a , ** kwarg )
2102
- elif (
2103
- axis is None
2104
- and ord in [- 2 , - 1 , 0 , 3 ]
2105
- and a .ndim != 1
2106
- and a .shape [- 1 ] == 0
2107
- ):
2108
- # reduction cannot be performed over zero-size axes
2109
- assert_raises (ValueError , dpnp .linalg .norm , ia , ** kwarg )
2110
- assert_raises (ValueError , numpy .linalg .norm , a , ** kwarg )
2099
+ elif axis is None and a .ndim != 1 and a .shape [- 1 ] == 0 :
2100
+ # TODO: when similar changes in numpy are available,
2101
+ # instead of assert_equal with zero, we should compare with numpy
2102
+ if ord in [- 2 , - 1 , 0 , 3 ]:
2103
+ # reduction cannot be performed over zero-size axes
2104
+ assert_raises (ValueError , dpnp .linalg .norm , ia , ** kwarg )
2105
+ assert_raises (ValueError , numpy .linalg .norm , a , ** kwarg )
2106
+ else :
2107
+ # ord in [None, 1, 2]
2108
+ assert_equal (dpnp .linalg .norm (ia , ** kwarg ), 0 )
2111
2109
else :
2112
2110
result = dpnp .linalg .norm (ia , ** kwarg )
2113
2111
expected = numpy .linalg .norm (a , ** kwarg )
@@ -2303,6 +2301,8 @@ def test_matrix_norm_empty(self, dtype, shape_axis):
2303
2301
shape , axis = shape_axis [0 ], shape_axis [1 ]
2304
2302
x = dpnp .zeros (shape , dtype = dtype )
2305
2303
2304
+ # TODO: when similar changes in numpy are available,
2305
+ # instead of assert_equal with zero, we should compare with numpy
2306
2306
assert_equal (dpnp .linalg .norm (x , axis = axis , ord = "fro" ), 0 )
2307
2307
assert_equal (dpnp .linalg .norm (x , axis = axis , ord = "nuc" ), 0 )
2308
2308
assert_equal (dpnp .linalg .norm (x , axis = axis , ord = 2 ), 0 )
@@ -2313,6 +2313,8 @@ def test_matrix_norm_empty(self, dtype, shape_axis):
2313
2313
@pytest .mark .parametrize ("axis" , [None , 0 ])
2314
2314
def test_vector_norm_empty (self , dtype , axis ):
2315
2315
x = dpnp .zeros (0 , dtype = dtype )
2316
+ # TODO: when similar changes in numpy are available,
2317
+ # instead of assert_equal with zero, we should compare with numpy
2316
2318
assert_equal (dpnp .linalg .vector_norm (x , axis = axis , ord = 1 ), 0 )
2317
2319
assert_equal (dpnp .linalg .vector_norm (x , axis = axis , ord = 2 ), 0 )
2318
2320
assert_equal (dpnp .linalg .vector_norm (x , axis = axis , ord = dpnp .inf ), 0 )
0 commit comments