@@ -150,11 +150,7 @@ class TestCholesky:
150
150
[[[7 , 2 ], [2 , 7 ]], [[8 , 3 ], [3 , 8 ]]],
151
151
],
152
152
],
153
- ids = [
154
- "2D_array" ,
155
- "3D_array" ,
156
- "4D_array" ,
157
- ],
153
+ ids = ["2D_array" , "3D_array" , "4D_array" ],
158
154
)
159
155
@pytest .mark .parametrize ("dtype" , get_all_dtypes (no_bool = True ))
160
156
def test_cholesky (self , array , dtype ):
@@ -174,11 +170,7 @@ def test_cholesky(self, array, dtype):
174
170
[[[7 , 2 ], [2 , 7 ]], [[8 , 3 ], [3 , 8 ]]],
175
171
],
176
172
],
177
- ids = [
178
- "2D_array" ,
179
- "3D_array" ,
180
- "4D_array" ,
181
- ],
173
+ ids = ["2D_array" , "3D_array" , "4D_array" ],
182
174
)
183
175
@pytest .mark .parametrize ("dtype" , get_all_dtypes (no_bool = True ))
184
176
def test_cholesky_upper (self , array , dtype ):
@@ -221,11 +213,7 @@ def test_cholesky_upper(self, array, dtype):
221
213
[[[7 , 2 ], [2 , 7 ]], [[8 , 3 ], [3 , 8 ]]],
222
214
],
223
215
],
224
- ids = [
225
- "2D_array" ,
226
- "3D_array" ,
227
- "4D_array" ,
228
- ],
216
+ ids = ["2D_array" , "3D_array" , "4D_array" ],
229
217
)
230
218
@pytest .mark .parametrize ("dtype" , get_all_dtypes (no_bool = True ))
231
219
def test_cholesky_upper_numpy (self , array , dtype ):
@@ -260,16 +248,8 @@ def test_cholesky_strides(self):
260
248
261
249
@pytest .mark .parametrize (
262
250
"shape" ,
263
- [
264
- (0 , 0 ),
265
- (3 , 0 , 0 ),
266
- (0 , 2 , 2 ),
267
- ],
268
- ids = [
269
- "(0, 0)" ,
270
- "(3, 0, 0)" ,
271
- "(0, 2, 2)" ,
272
- ],
251
+ [(0 , 0 ), (3 , 0 , 0 ), (0 , 2 , 2 )],
252
+ ids = ["(0, 0)" , "(3, 0, 0)" , "(0, 2, 2)" ],
273
253
)
274
254
def test_cholesky_empty (self , shape ):
275
255
a = numpy .empty (shape )
@@ -322,7 +302,7 @@ def test_cond_empty(self, shape, p):
322
302
"p" , [None , - dpnp .inf , - 2 , - 1 , 1 , 2 , dpnp .inf , "fro" ]
323
303
)
324
304
def test_cond (self , dtype , shape , p ):
325
- a = generate_random_numpy_array (shape , dtype , low = - 5 , high = 5 )
305
+ a = generate_random_numpy_array (shape , dtype )
326
306
ia = dpnp .array (a )
327
307
328
308
result = dpnp .linalg .cond (ia , p = p )
@@ -342,7 +322,7 @@ def test_cond_bool(self, p):
342
322
343
323
@pytest .mark .parametrize ("p" , [- dpnp .inf , - 1 , 1 , dpnp .inf , "fro" ])
344
324
def test_cond_nan_input (self , p ):
345
- a = generate_random_numpy_array ((3 , 3 ), low = - 10 , high = 10 )
325
+ a = generate_random_numpy_array ((3 , 3 ))
346
326
a [1 , 1 ] = numpy .nan
347
327
ia = dpnp .array (a )
348
328
@@ -354,7 +334,7 @@ def test_cond_nan_input(self, p):
354
334
"p" , [None , - dpnp .inf , - 2 , - 1 , 1 , 2 , dpnp .inf , "fro" ]
355
335
)
356
336
def test_cond_nan (self , p ):
357
- a = generate_random_numpy_array ((2 , 2 , 2 , 2 ), low = - 5 , high = 5 )
337
+ a = generate_random_numpy_array ((2 , 2 , 2 , 2 ))
358
338
a [0 , 0 ] = 0
359
339
a [1 , 1 ] = 0
360
340
ia = dpnp .array (a )
@@ -405,11 +385,7 @@ class TestDet:
405
385
[[[1 , 3 ], [3 , 1 ]], [[0 , 1 ], [1 , 3 ]]],
406
386
],
407
387
],
408
- ids = [
409
- "2D_array" ,
410
- "3D_array" ,
411
- "4D_array" ,
412
- ],
388
+ ids = ["2D_array" , "3D_array" , "4D_array" ],
413
389
)
414
390
@pytest .mark .parametrize ("dtype" , get_all_dtypes (no_bool = True ))
415
391
def test_det (self , array , dtype ):
@@ -523,35 +499,21 @@ def assert_eigen_decomposition(self, a, w, v, rtol=1e-5, atol=1e-5):
523
499
a [i ].dot (v [i ]), w [i ] * v [i ], rtol = rtol , atol = atol
524
500
)
525
501
526
- @pytest .mark .parametrize (
527
- "func" ,
528
- [
529
- "eig" ,
530
- "eigvals" ,
531
- "eigh" ,
532
- "eigvalsh" ,
533
- ],
534
- )
502
+ @pytest .mark .parametrize ("func" , ["eig" , "eigvals" , "eigh" , "eigvalsh" ])
535
503
@pytest .mark .parametrize (
536
504
"shape" ,
537
505
[(2 , 2 ), (2 , 3 , 3 ), (2 , 2 , 3 , 3 )],
538
- ids = ["(2,2)" , "(2,3, 3)" , "(2,2,3, 3)" ],
506
+ ids = ["(2, 2)" , "(2, 3, 3)" , "(2, 2, 3, 3)" ],
539
507
)
540
508
@pytest .mark .parametrize ("dtype" , get_all_dtypes (no_bool = True ))
541
- @pytest .mark .parametrize (
542
- "order" ,
543
- [
544
- "C" ,
545
- "F" ,
546
- ],
547
- )
509
+ @pytest .mark .parametrize ("order" , ["C" , "F" ])
548
510
def test_eigenvalues (self , func , shape , dtype , order ):
549
511
# Set a `hermitian` flag for generate_random_numpy_array() to
550
512
# get a symmetric array for eigh() and eigvalsh() or
551
513
# non-symmetric for eig() and eigvals()
552
514
is_hermitian = func in ("eigh, eigvalsh" )
553
515
a = generate_random_numpy_array (
554
- shape , dtype , hermitian = is_hermitian , seed_value = 81
516
+ shape , dtype , hermitian = is_hermitian , seed_value = 81 , low = - 2 , high = 2
555
517
)
556
518
a_order = numpy .array (a , order = order )
557
519
a_dp = dpnp .array (a , order = order )
@@ -574,13 +536,7 @@ def test_eigenvalues(self, func, shape, dtype, order):
574
536
assert_dtype_allclose (w_dp , w )
575
537
576
538
# eigh() and eigvalsh() are tested in cupy tests
577
- @pytest .mark .parametrize (
578
- "func" ,
579
- [
580
- "eig" ,
581
- "eigvals" ,
582
- ],
583
- )
539
+ @pytest .mark .parametrize ("func" , ["eig" , "eigvals" ])
584
540
@pytest .mark .parametrize (
585
541
"shape" ,
586
542
[(0 , 0 ), (2 , 0 , 0 ), (0 , 3 , 3 )],
@@ -603,15 +559,7 @@ def test_eigenvalue_empty(self, func, shape, dtype):
603
559
604
560
assert_dtype_allclose (w_dp , w )
605
561
606
- @pytest .mark .parametrize (
607
- "func" ,
608
- [
609
- "eig" ,
610
- "eigvals" ,
611
- "eigh" ,
612
- "eigvalsh" ,
613
- ],
614
- )
562
+ @pytest .mark .parametrize ("func" , ["eig" , "eigvals" , "eigh" , "eigvalsh" ])
615
563
def test_eigenvalue_errors (self , func ):
616
564
a_dp = dpnp .array ([[1 , 3 ], [3 , 2 ]], dtype = "float32" )
617
565
@@ -1737,11 +1685,7 @@ class TestInv:
1737
1685
[[[1 , 3 ], [3 , 1 ]], [[0 , 1 ], [1 , 3 ]]],
1738
1686
],
1739
1687
],
1740
- ids = [
1741
- "2D_array" ,
1742
- "3D_array" ,
1743
- "4D_array" ,
1744
- ],
1688
+ ids = ["2D_array" , "3D_array" , "4D_array" ],
1745
1689
)
1746
1690
@pytest .mark .parametrize ("dtype" , get_all_dtypes (no_bool = True ))
1747
1691
def test_inv (self , array , dtype ):
@@ -1776,16 +1720,8 @@ def test_inv_strides(self):
1776
1720
1777
1721
@pytest .mark .parametrize (
1778
1722
"shape" ,
1779
- [
1780
- (0 , 0 ),
1781
- (3 , 0 , 0 ),
1782
- (0 , 2 , 2 ),
1783
- ],
1784
- ids = [
1785
- "(0, 0)" ,
1786
- "(3, 0, 0)" ,
1787
- "(0, 2, 2)" ,
1788
- ],
1723
+ [(0 , 0 ), (3 , 0 , 0 ), (0 , 2 , 2 )],
1724
+ ids = ["(0, 0)" , "(3, 0, 0)" , "(0, 2, 2)" ],
1789
1725
)
1790
1726
def test_inv_empty (self , shape ):
1791
1727
a = numpy .empty (shape )
@@ -1882,8 +1818,8 @@ def test_lstsq(self, a_shape, b_shape, dtype):
1882
1818
@pytest .mark .parametrize ("a_dtype" , get_all_dtypes ())
1883
1819
@pytest .mark .parametrize ("b_dtype" , get_all_dtypes ())
1884
1820
def test_lstsq_diff_type (self , a_dtype , b_dtype ):
1885
- a_np = generate_random_numpy_array ((2 , 2 ), a_dtype , low = - 5 , high = 5 )
1886
- b_np = generate_random_numpy_array (2 , b_dtype , low = - 5 , high = 5 )
1821
+ a_np = generate_random_numpy_array ((2 , 2 ), a_dtype )
1822
+ b_np = generate_random_numpy_array (2 , b_dtype )
1887
1823
a_dp = dpnp .array (a_np )
1888
1824
b_dp = dpnp .array (b_np )
1889
1825
@@ -2030,11 +1966,7 @@ def test_matrix_rank_hermitian(self, data, dtype):
2030
1966
(numpy .array (0.99e-6 ), numpy .array (1.01e-6 )),
2031
1967
(numpy .array ([0.99e-6 ]), numpy .array ([1.01e-6 ])),
2032
1968
],
2033
- ids = [
2034
- "float" ,
2035
- "0-D array" ,
2036
- "1-D array" ,
2037
- ],
1969
+ ids = ["float" , "0-D array" , "1-D array" ],
2038
1970
)
2039
1971
def test_matrix_rank_tolerance (self , high_tol , low_tol ):
2040
1972
a = numpy .eye (4 )
@@ -2209,7 +2141,7 @@ def test_norm_0D(self, ord, axis):
2209
2141
@pytest .mark .parametrize ("axis" , [0 , None ])
2210
2142
@pytest .mark .parametrize ("keepdims" , [True , False ])
2211
2143
def test_norm_1D (self , dtype , ord , axis , keepdims ):
2212
- a = generate_random_numpy_array (10 , dtype , low = - 5 , high = 5 )
2144
+ a = generate_random_numpy_array (10 , dtype )
2213
2145
ia = dpnp .array (a )
2214
2146
2215
2147
result = dpnp .linalg .norm (ia , ord = ord , axis = axis , keepdims = keepdims )
@@ -2226,7 +2158,7 @@ def test_norm_1D(self, dtype, ord, axis, keepdims):
2226
2158
)
2227
2159
@pytest .mark .parametrize ("keepdims" , [True , False ])
2228
2160
def test_norm_2D (self , dtype , ord , axis , keepdims ):
2229
- a = generate_random_numpy_array ((3 , 5 ), dtype , low = - 5 , high = 5 )
2161
+ a = generate_random_numpy_array ((3 , 5 ), dtype )
2230
2162
ia = dpnp .array (a )
2231
2163
if (axis in [- 1 , 0 , 1 ] and ord in ["nuc" , "fro" ]) or (
2232
2164
(isinstance (axis , tuple ) or axis is None ) and ord == 3
@@ -2253,7 +2185,7 @@ def test_norm_2D(self, dtype, ord, axis, keepdims):
2253
2185
)
2254
2186
@pytest .mark .parametrize ("keepdims" , [True , False ])
2255
2187
def test_norm_ND (self , dtype , ord , axis , keepdims ):
2256
- a = generate_random_numpy_array ((2 , 3 , 4 , 5 ), dtype , low = - 5 , high = 5 )
2188
+ a = generate_random_numpy_array ((2 , 3 , 4 , 5 ), dtype )
2257
2189
ia = dpnp .array (a )
2258
2190
if (axis in [- 1 , 0 , 1 ] and ord in ["nuc" , "fro" ]) or (
2259
2191
isinstance (axis , tuple ) and ord == 3
@@ -2284,7 +2216,7 @@ def test_norm_ND(self, dtype, ord, axis, keepdims):
2284
2216
)
2285
2217
@pytest .mark .parametrize ("keepdims" , [True , False ])
2286
2218
def test_norm_usm_ndarray (self , dtype , ord , axis , keepdims ):
2287
- a = generate_random_numpy_array ((2 , 3 , 4 , 5 ), dtype , low = - 5 , high = 5 )
2219
+ a = generate_random_numpy_array ((2 , 3 , 4 , 5 ), dtype )
2288
2220
ia = dpt .asarray (a )
2289
2221
if (axis in [- 1 , 0 , 1 ] and ord in ["nuc" , "fro" ]) or (
2290
2222
isinstance (axis , tuple ) and ord == 3
@@ -2361,7 +2293,7 @@ def test_norm_strided_ND(self, axis, stride):
2361
2293
)
2362
2294
@pytest .mark .parametrize ("keepdims" , [True , False ])
2363
2295
def test_matrix_norm (self , ord , keepdims ):
2364
- a = generate_random_numpy_array ((3 , 5 ), low = - 5 , high = 5 )
2296
+ a = generate_random_numpy_array ((3 , 5 ))
2365
2297
ia = dpnp .array (a )
2366
2298
2367
2299
result = dpnp .linalg .matrix_norm (ia , ord = ord , keepdims = keepdims )
@@ -2387,7 +2319,7 @@ def test_vector_norm_0D(self, ord):
2387
2319
@pytest .mark .parametrize ("axis" , [0 , None ])
2388
2320
@pytest .mark .parametrize ("keepdims" , [True , False ])
2389
2321
def test_vector_norm_1D (self , ord , axis , keepdims ):
2390
- a = generate_random_numpy_array (10 , low = - 5 , high = 5 )
2322
+ a = generate_random_numpy_array (10 )
2391
2323
ia = dpnp .array (a )
2392
2324
2393
2325
result = dpnp .linalg .vector_norm (
@@ -2588,8 +2520,8 @@ def test_solve_nrhs_greater_n(self, dtype):
2588
2520
@pytest .mark .parametrize ("a_dtype" , get_all_dtypes (no_bool = True ))
2589
2521
@pytest .mark .parametrize ("b_dtype" , get_all_dtypes (no_bool = True ))
2590
2522
def test_solve_diff_type (self , a_dtype , b_dtype ):
2591
- a_np = generate_random_numpy_array ((2 , 2 ), a_dtype , low = - 5 , high = 5 )
2592
- b_np = generate_random_numpy_array (2 , b_dtype , low = - 5 , high = 5 )
2523
+ a_np = generate_random_numpy_array ((2 , 2 ), a_dtype )
2524
+ b_np = generate_random_numpy_array (2 , b_dtype )
2593
2525
a_dp = dpnp .array (a_np )
2594
2526
b_dp = dpnp .array (b_np )
2595
2527
@@ -2877,9 +2809,7 @@ def test_svd(self, dtype, shape):
2877
2809
@pytest .mark .parametrize ("dtype" , get_float_complex_dtypes ())
2878
2810
@pytest .mark .parametrize ("compute_vt" , [True , False ])
2879
2811
@pytest .mark .parametrize (
2880
- "shape" ,
2881
- [(2 , 2 ), (16 , 16 )],
2882
- ids = ["(2, 2)" , "(16, 16)" ],
2812
+ "shape" , [(2 , 2 ), (16 , 16 )], ids = ["(2, 2)" , "(16, 16)" ]
2883
2813
)
2884
2814
def test_svd_hermitian (self , dtype , compute_vt , shape ):
2885
2815
# Set seed_value=81 to prevent
@@ -3025,15 +2955,13 @@ def test_pinv(self, dtype, shape):
3025
2955
3026
2956
@pytest .mark .parametrize ("dtype" , get_float_complex_dtypes ())
3027
2957
@pytest .mark .parametrize (
3028
- "shape" ,
3029
- [(2 , 2 ), (16 , 16 )],
3030
- ids = ["(2, 2)" , "(16, 16)" ],
2958
+ "shape" , [(2 , 2 ), (16 , 16 )], ids = ["(2, 2)" , "(16, 16)" ]
3031
2959
)
3032
2960
def test_pinv_hermitian (self , dtype , shape ):
3033
2961
# Set seed_value=70 to prevent
3034
2962
# random generation of the input singular matrix
3035
2963
a = generate_random_numpy_array (
3036
- shape , dtype , hermitian = True , seed_value = 70
2964
+ shape , dtype , hermitian = True , seed_value = 70 , low = - 2 , high = 2
3037
2965
)
3038
2966
a_dp = dpnp .array (a )
3039
2967
@@ -3133,14 +3061,8 @@ class TestTensorinv:
3133
3061
@pytest .mark .parametrize ("dtype" , get_all_dtypes ())
3134
3062
@pytest .mark .parametrize (
3135
3063
"shape, ind" ,
3136
- [
3137
- ((4 , 6 , 8 , 3 ), 2 ),
3138
- ((24 , 8 , 3 ), 1 ),
3139
- ],
3140
- ids = [
3141
- "(4, 6, 8, 3)" ,
3142
- "(24, 8, 3)" ,
3143
- ],
3064
+ [((4 , 6 , 8 , 3 ), 2 ), ((24 , 8 , 3 ), 1 )],
3065
+ ids = ["(4, 6, 8, 3)" , "(24, 8, 3)" ],
3144
3066
)
3145
3067
def test_tensorinv (self , dtype , shape , ind ):
3146
3068
a = numpy .eye (24 , dtype = dtype ).reshape (shape )
@@ -3173,11 +3095,7 @@ class TestTensorsolve:
3173
3095
@pytest .mark .parametrize (
3174
3096
"axes" ,
3175
3097
[None , (1 ,), (2 ,)],
3176
- ids = [
3177
- "None" ,
3178
- "(1,)" ,
3179
- "(2,)" ,
3180
- ],
3098
+ ids = ["None" , "(1,)" , "(2,)" ],
3181
3099
)
3182
3100
def test_tensorsolve_axes (self , dtype , axes ):
3183
3101
a = numpy .eye (12 ).reshape (12 , 3 , 4 ).astype (dtype )
0 commit comments