@@ -2096,7 +2096,12 @@ def test_empty(self, shape, ord, axis, keepdims):
20962096 # Improper number of dimensions to norm
20972097 assert_raises (ValueError , dpnp .linalg .norm , ia , ** kwarg )
20982098 assert_raises (ValueError , numpy .linalg .norm , a , ** kwarg )
2099- elif axis is None and a .ndim != 1 and a .shape [- 1 ] == 0 :
2099+ elif (
2100+ axis is None
2101+ and ord is not None
2102+ and a .ndim != 1
2103+ and a .shape [- 1 ] == 0
2104+ ):
21002105 if ord in [- 2 , - 1 , 0 , 3 ]:
21012106 # reduction cannot be performed over zero-size axes
21022107 assert_raises (ValueError , dpnp .linalg .norm , ia , ** kwarg )
@@ -2106,6 +2111,7 @@ def test_empty(self, shape, ord, axis, keepdims):
21062111 # of assert_equal with zero, we should compare with numpy
21072112 # ord in [None, 1, 2]
21082113 assert_equal (dpnp .linalg .norm (ia , ** kwarg ), 0 )
2114+ assert_raises (ValueError , numpy .linalg .norm , a , ** kwarg )
21092115 else :
21102116 result = dpnp .linalg .norm (ia , ** kwarg )
21112117 expected = numpy .linalg .norm (a , ** kwarg )
@@ -2297,29 +2303,23 @@ def test_matrix_norm(self, ord, keepdims):
22972303 @pytest .mark .parametrize (
22982304 "shape_axis" , [[(2 , 0 ), None ], [(2 , 0 ), (0 , 1 )], [(0 , 2 ), (0 , 1 )]]
22992305 )
2300- def test_matrix_norm_empty (self , dtype , shape_axis ):
2306+ @pytest .mark .parametrize ("ord" , [None , "fro" , "nuc" , 1 , 2 , dpnp .inf ])
2307+ def test_matrix_norm_empty (self , dtype , shape_axis , ord ):
23012308 shape , axis = shape_axis [0 ], shape_axis [1 ]
23022309 x = dpnp .zeros (shape , dtype = dtype )
23032310
23042311 # TODO: when similar changes in numpy are available,
23052312 # instead of assert_equal with zero, we should compare with numpy
2306- assert_equal (dpnp .linalg .norm (x , axis = axis ), 0 )
2307- assert_equal (dpnp .linalg .norm (x , axis = axis , ord = "fro" ), 0 )
2308- assert_equal (dpnp .linalg .norm (x , axis = axis , ord = "nuc" ), 0 )
2309- assert_equal (dpnp .linalg .norm (x , axis = axis , ord = 2 ), 0 )
2310- assert_equal (dpnp .linalg .norm (x , axis = axis , ord = 1 ), 0 )
2311- assert_equal (dpnp .linalg .norm (x , axis = axis , ord = dpnp .inf ), 0 )
2313+ assert_equal (dpnp .linalg .norm (x , axis = axis , ord = ord ), 0 )
23122314
23132315 @pytest .mark .parametrize ("dtype" , [dpnp .float32 , dpnp .int32 ])
23142316 @pytest .mark .parametrize ("axis" , [None , 0 ])
2315- def test_vector_norm_empty (self , dtype , axis ):
2317+ @pytest .mark .parametrize ("ord" , [None , 1 , 2 , dpnp .inf ])
2318+ def test_vector_norm_empty (self , dtype , axis , ord ):
23162319 x = dpnp .zeros (0 , dtype = dtype )
23172320 # TODO: when similar changes in numpy are available,
23182321 # instead of assert_equal with zero, we should compare with numpy
2319- assert_equal (dpnp .linalg .vector_norm (x , axis = axis ), 0 )
2320- assert_equal (dpnp .linalg .vector_norm (x , axis = axis , ord = 1 ), 0 )
2321- assert_equal (dpnp .linalg .vector_norm (x , axis = axis , ord = 2 ), 0 )
2322- assert_equal (dpnp .linalg .vector_norm (x , axis = axis , ord = dpnp .inf ), 0 )
2322+ assert_equal (dpnp .linalg .vector_norm (x , axis = axis , ord = ord ), 0 )
23232323
23242324 @testing .with_requires ("numpy>=2.0" )
23252325 @pytest .mark .parametrize (
0 commit comments