@@ -1203,11 +1203,21 @@ def test_initialization(ndim, rng):
1203
1203
@pytest .mark .parametrize ("N, M" , [(4 , None ), (4 , 10 ), (10 , 4 ), (0 , 10 )])
1204
1204
def test_eye (N , M ):
1205
1205
m = M or N
1206
- for k in [0 , N - 2 , N + 2 , m - 2 , m + 2 ]:
1206
+ for k in [0 , N - 2 , N + 2 , m - 2 , m + 2 , np . iinfo ( np . intp ). min ]:
1207
1207
assert_eq (sparse .eye (N , M = M , k = k ), np .eye (N , M = M , k = k ))
1208
1208
assert_eq (sparse .eye (N , M = M , k = k , dtype = "i4" ), np .eye (N , M = M , k = k , dtype = "i4" ))
1209
1209
1210
1210
1211
+ @pytest .mark .parametrize ("from_" , [np .int8 , np .int64 , np .float32 , np .float64 , np .complex64 , np .complex128 ])
1212
+ @pytest .mark .parametrize ("to" , [np .int8 , np .int64 , np .float32 , np .float64 , np .complex64 , np .complex128 ])
1213
+ @pytest .mark .parametrize ("casting" , ["no" , "safe" , "same_kind" ])
1214
+ def test_can_cast (from_ , to , casting ):
1215
+ assert sparse .can_cast (sparse .zeros ((2 , 2 ), dtype = from_ ), to , casting = casting ) == np .can_cast (
1216
+ np .zeros ((2 , 2 ), dtype = from_ ), to , casting = casting
1217
+ )
1218
+ assert sparse .can_cast (from_ , to , casting = casting ) == np .can_cast (from_ , to , casting = casting )
1219
+
1220
+
1211
1221
@pytest .mark .parametrize ("funcname" , ["ones" , "zeros" ])
1212
1222
def test_ones_zeros (funcname ):
1213
1223
sp_func = getattr (sparse , funcname )
0 commit comments