@@ -307,11 +307,12 @@ def test_take_filling(self):
307
307
with pytest .raises (ValueError , match = msg ):
308
308
sparse .take (np .array ([1 , 0 , - 5 ]), allow_fill = True )
309
309
310
- with pytest .raises (IndexError ):
310
+ msg = "out of bounds value in 'indices'"
311
+ with pytest .raises (IndexError , match = msg ):
311
312
sparse .take (np .array ([1 , - 6 ]))
312
- with pytest .raises (IndexError ):
313
+ with pytest .raises (IndexError , match = msg ):
313
314
sparse .take (np .array ([1 , 5 ]))
314
- with pytest .raises (IndexError ):
315
+ with pytest .raises (IndexError , match = msg ):
315
316
sparse .take (np .array ([1 , 5 ]), allow_fill = True )
316
317
317
318
def test_take_filling_fill_value (self ):
@@ -340,11 +341,12 @@ def test_take_filling_fill_value(self):
340
341
with pytest .raises (ValueError , match = msg ):
341
342
sparse .take (np .array ([1 , 0 , - 5 ]), allow_fill = True )
342
343
343
- with pytest .raises (IndexError ):
344
+ msg = "out of bounds value in 'indices'"
345
+ with pytest .raises (IndexError , match = msg ):
344
346
sparse .take (np .array ([1 , - 6 ]))
345
- with pytest .raises (IndexError ):
347
+ with pytest .raises (IndexError , match = msg ):
346
348
sparse .take (np .array ([1 , 5 ]))
347
- with pytest .raises (IndexError ):
349
+ with pytest .raises (IndexError , match = msg ):
348
350
sparse .take (np .array ([1 , 5 ]), fill_value = True )
349
351
350
352
def test_take_filling_all_nan (self ):
@@ -358,11 +360,12 @@ def test_take_filling_all_nan(self):
358
360
expected = SparseArray ([np .nan , np .nan , np .nan ], kind = "block" )
359
361
tm .assert_sp_array_equal (result , expected )
360
362
361
- with pytest .raises (IndexError ):
363
+ msg = "out of bounds value in 'indices'"
364
+ with pytest .raises (IndexError , match = msg ):
362
365
sparse .take (np .array ([1 , - 6 ]))
363
- with pytest .raises (IndexError ):
366
+ with pytest .raises (IndexError , match = msg ):
364
367
sparse .take (np .array ([1 , 5 ]))
365
- with pytest .raises (IndexError ):
368
+ with pytest .raises (IndexError , match = msg ):
366
369
sparse .take (np .array ([1 , 5 ]), fill_value = True )
367
370
368
371
def test_set_item (self ):
@@ -670,10 +673,11 @@ def test_getslice_tuple(self):
670
673
exp = SparseArray (dense [4 :,], fill_value = 0 ) # noqa: E231
671
674
tm .assert_sp_array_equal (res , exp )
672
675
673
- with pytest .raises (IndexError ):
676
+ msg = "too many indices for array"
677
+ with pytest .raises (IndexError , match = msg ):
674
678
sparse [4 :, :]
675
679
676
- with pytest .raises (IndexError ):
680
+ with pytest .raises (IndexError , match = msg ):
677
681
# check numpy compat
678
682
dense [4 :, :]
679
683
0 commit comments