@@ -151,6 +151,43 @@ def test_loadtxt(type):
151151 numpy .testing .assert_array_equal (dpnp_res , np_res )
152152
153153
154+ @pytest .mark .parametrize ("dtype" ,
155+ [numpy .float64 , numpy .float32 , numpy .int64 , numpy .int32 ],
156+ ids = ['float64' , 'float32' , 'int64' , 'int32' ])
157+ @pytest .mark .parametrize ("type" ,
158+ [numpy .float64 , numpy .float32 , numpy .int64 , numpy .int32 ],
159+ ids = ['float64' , 'float32' , 'int64' , 'int32' ])
160+ @pytest .mark .parametrize ("offset" ,
161+ [0 , 1 ],
162+ ids = ['0' , '1' ])
163+ @pytest .mark .parametrize ("array" ,
164+ [[[0 , 0 ], [0 , 0 ]],
165+ [[1 , 2 ], [1 , 2 ]],
166+ [[1 , 2 ], [3 , 4 ]],
167+ [[0 , 1 , 2 ], [3 , 4 , 5 ], [6 , 7 , 8 ]],
168+ [[0 , 1 , 2 , 3 , 4 ], [5 , 6 , 7 , 8 , 9 ]],
169+ [[[1 , 2 ], [3 , 4 ]], [[1 , 2 ], [2 , 1 ]], [[1 , 3 ], [3 , 1 ]]],
170+ [[[[1 , 2 ], [3 , 4 ]], [[1 , 2 ], [2 , 1 ]]], [[[1 , 3 ], [3 , 1 ]], [[0 , 1 ], [1 , 3 ]]]],
171+ [[[[1 , 2 , 3 ], [3 , 4 , 5 ]], [[1 , 2 , 3 ], [2 , 1 , 0 ]]], [
172+ [[1 , 3 , 5 ], [3 , 1 , 0 ]], [[0 , 1 , 2 ], [1 , 3 , 4 ]]]],
173+ [[[[1 , 2 , 3 ], [4 , 5 , 6 ]], [[7 , 8 , 9 ], [10 , 11 , 12 ]]], [[[13 , 14 , 15 ], [16 , 17 , 18 ]], [[19 , 20 , 21 ], [22 , 23 , 24 ]]]]],
174+ ids = ['[[0, 0], [0, 0]]' ,
175+ '[[1, 2], [1, 2]]' ,
176+ '[[1, 2], [3, 4]]' ,
177+ '[[0, 1, 2], [3, 4, 5], [6, 7, 8]]' ,
178+ '[[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]' ,
179+ '[[[1, 2], [3, 4]], [[1, 2], [2, 1]], [[1, 3], [3, 1]]]' ,
180+ '[[[[1, 2], [3, 4]], [[1, 2], [2, 1]]], [[[1, 3], [3, 1]], [[0, 1], [1, 3]]]]' ,
181+ '[[[[1, 2, 3], [3, 4, 5]], [[1, 2, 3], [2, 1, 0]]], [[[1, 3, 5], [3, 1, 0]], [[0, 1, 2], [1, 3, 4]]]]' ,
182+ '[[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]], [[[13, 14, 15], [16, 17, 18]], [[19, 20, 21], [22, 23, 24]]]]' ])
183+ def test_trace (array , offset , type , dtype ):
184+ a = numpy .array (array , type )
185+ ia = dpnp .array (array , type )
186+ expected = numpy .trace (a , offset = offset , dtype = dtype )
187+ result = dpnp .trace (ia , offset = offset , dtype = dtype )
188+ numpy .testing .assert_array_equal (expected , result )
189+
190+
154191@pytest .mark .parametrize ("N" ,
155192 [0 , 1 , 2 , 3 , 4 ],
156193 ids = ['0' , '1' , '2' , '3' , '4' ])
0 commit comments