@@ -54,7 +54,7 @@ def test_scalar_error(self, index_func):
54
54
55
55
msg = (
56
56
"cannot do positional indexing on {klass} with these "
57
- r"indexers \[3\.0\] of {kind} " .format (klass = type (i ), kind = str ( float ) )
57
+ r"indexers \[3\.0\] of type float " .format (klass = type (i ). __name__ )
58
58
)
59
59
with pytest .raises (TypeError , match = msg ):
60
60
s .iloc [3.0 ] = 0
@@ -92,11 +92,11 @@ def test_scalar_non_numeric(self):
92
92
else :
93
93
error = TypeError
94
94
msg = (
95
- r"cannot do (label|index| positional) indexing "
95
+ r"cannot do (label|positional) indexing "
96
96
r"on {klass} with these indexers \[3\.0\] of "
97
- r"{kind} |"
97
+ r"type float |"
98
98
"Cannot index by location index with a "
99
- "non-integer key" .format (klass = type (i ), kind = str ( float ) )
99
+ "non-integer key" .format (klass = type (i ). __name__ )
100
100
)
101
101
with pytest .raises (error , match = msg ):
102
102
idxr (s )[3.0 ]
@@ -113,9 +113,9 @@ def test_scalar_non_numeric(self):
113
113
else :
114
114
error = TypeError
115
115
msg = (
116
- r"cannot do ( label|index) indexing "
116
+ r"cannot do label indexing "
117
117
r"on {klass} with these indexers \[3\.0\] of "
118
- r"{kind} " .format (klass = type (i ), kind = str ( float ) )
118
+ r"type float " .format (klass = type (i ). __name__ )
119
119
)
120
120
with pytest .raises (error , match = msg ):
121
121
s .loc [3.0 ]
@@ -125,9 +125,9 @@ def test_scalar_non_numeric(self):
125
125
126
126
# setting with a float fails with iloc
127
127
msg = (
128
- r"cannot do (label|index| positional) indexing "
128
+ r"cannot do (label|positional) indexing "
129
129
r"on {klass} with these indexers \[3\.0\] of "
130
- r"{kind} " .format (klass = type (i ), kind = str ( float ) )
130
+ r"type float " .format (klass = type (i ). __name__ )
131
131
)
132
132
with pytest .raises (TypeError , match = msg ):
133
133
s .iloc [3.0 ] = 0
@@ -162,9 +162,9 @@ def test_scalar_non_numeric(self):
162
162
s = Series (np .arange (len (i )), index = i )
163
163
s [3 ]
164
164
msg = (
165
- r"cannot do ( label|index) indexing "
165
+ r"cannot do label indexing "
166
166
r"on {klass} with these indexers \[3\.0\] of "
167
- r"{kind} " .format (klass = type (i ), kind = str ( float ) )
167
+ r"type float " .format (klass = type (i ). __name__ )
168
168
)
169
169
with pytest .raises (TypeError , match = msg ):
170
170
s [3.0 ]
@@ -181,9 +181,9 @@ def test_scalar_with_mixed(self):
181
181
msg = (
182
182
r"cannot do label indexing "
183
183
r"on {klass} with these indexers \[1\.0\] of "
184
- r"{kind} |"
184
+ r"type float |"
185
185
"Cannot index by location index with a non-integer key" .format (
186
- klass = str ( Index ), kind = str ( float )
186
+ klass = Index . __name__
187
187
)
188
188
)
189
189
with pytest .raises (TypeError , match = msg ):
@@ -203,7 +203,7 @@ def test_scalar_with_mixed(self):
203
203
msg = (
204
204
r"cannot do label indexing "
205
205
r"on {klass} with these indexers \[1\.0\] of "
206
- r"{kind} " .format (klass = str ( Index ), kind = str ( float ) )
206
+ r"type float " .format (klass = Index . __name__ )
207
207
)
208
208
with pytest .raises (TypeError , match = msg ):
209
209
idxr (s3 )[1.0 ]
@@ -317,7 +317,7 @@ def test_scalar_float(self):
317
317
msg = (
318
318
r"cannot do positional indexing "
319
319
r"on {klass} with these indexers \[3\.0\] of "
320
- r"{kind} " .format (klass = str ( Float64Index ), kind = str ( float ) )
320
+ r"type float " .format (klass = Float64Index . __name__ )
321
321
)
322
322
with pytest .raises (TypeError , match = msg ):
323
323
s2 .iloc [3.0 ] = 0
@@ -346,24 +346,20 @@ def test_slice_non_numeric(self):
346
346
for l in [slice (3.0 , 4 ), slice (3 , 4.0 ), slice (3.0 , 4.0 )]:
347
347
348
348
msg = (
349
- "cannot do slice indexing "
349
+ "cannot do positional indexing "
350
350
r"on {klass} with these indexers \[(3|4)\.0\] of "
351
- "{kind} " .format (klass = type (index ), kind = str ( float ) )
351
+ "type float " .format (klass = type (index ). __name__ )
352
352
)
353
353
with pytest .raises (TypeError , match = msg ):
354
354
s .iloc [l ]
355
355
356
356
for idxr in [lambda x : x .loc , lambda x : x .iloc , lambda x : x ]:
357
357
358
358
msg = (
359
- "cannot do slice indexing "
359
+ "cannot do ( slice|positional) indexing "
360
360
r"on {klass} with these indexers "
361
361
r"\[(3|4)(\.0)?\] "
362
- r"of ({kind_float}|{kind_int})" .format (
363
- klass = type (index ),
364
- kind_float = str (float ),
365
- kind_int = str (int ),
366
- )
362
+ r"of type (float|int)" .format (klass = type (index ).__name__ )
367
363
)
368
364
with pytest .raises (TypeError , match = msg ):
369
365
idxr (s )[l ]
@@ -372,23 +368,19 @@ def test_slice_non_numeric(self):
372
368
for l in [slice (3.0 , 4 ), slice (3 , 4.0 ), slice (3.0 , 4.0 )]:
373
369
374
370
msg = (
375
- "cannot do slice indexing "
371
+ "cannot do positional indexing "
376
372
r"on {klass} with these indexers \[(3|4)\.0\] of "
377
- "{kind} " .format (klass = type (index ), kind = str ( float ) )
373
+ "type float " .format (klass = type (index ). __name__ )
378
374
)
379
375
with pytest .raises (TypeError , match = msg ):
380
376
s .iloc [l ] = 0
381
377
382
378
for idxr in [lambda x : x .loc , lambda x : x .iloc , lambda x : x ]:
383
379
msg = (
384
- "cannot do slice indexing "
380
+ "cannot do ( slice|positional) indexing "
385
381
r"on {klass} with these indexers "
386
382
r"\[(3|4)(\.0)?\] "
387
- r"of ({kind_float}|{kind_int})" .format (
388
- klass = type (index ),
389
- kind_float = str (float ),
390
- kind_int = str (int ),
391
- )
383
+ r"of type (float|int)" .format (klass = type (index ).__name__ )
392
384
)
393
385
with pytest .raises (TypeError , match = msg ):
394
386
idxr (s )[l ] = 0
@@ -428,7 +420,7 @@ def test_slice_integer(self):
428
420
msg = (
429
421
"cannot do slice indexing "
430
422
r"on {klass} with these indexers \[(3|4)\.0\] of "
431
- "{kind} " .format (klass = type (index ), kind = str ( float ) )
423
+ "type float " .format (klass = type (index ). __name__ )
432
424
)
433
425
with pytest .raises (TypeError , match = msg ):
434
426
s [l ]
@@ -452,7 +444,7 @@ def test_slice_integer(self):
452
444
msg = (
453
445
"cannot do slice indexing "
454
446
r"on {klass} with these indexers \[-6\.0\] of "
455
- "{kind} " .format (klass = type (index ), kind = str ( float ) )
447
+ "type float " .format (klass = type (index ). __name__ )
456
448
)
457
449
with pytest .raises (TypeError , match = msg ):
458
450
s [slice (- 6.0 , 6.0 )]
@@ -478,7 +470,7 @@ def test_slice_integer(self):
478
470
msg = (
479
471
"cannot do slice indexing "
480
472
r"on {klass} with these indexers \[(2|3)\.5\] of "
481
- "{kind} " .format (klass = type (index ), kind = str ( float ) )
473
+ "type float " .format (klass = type (index ). __name__ )
482
474
)
483
475
with pytest .raises (TypeError , match = msg ):
484
476
s [l ]
@@ -496,7 +488,7 @@ def test_slice_integer(self):
496
488
msg = (
497
489
"cannot do slice indexing "
498
490
r"on {klass} with these indexers \[(3|4)\.0\] of "
499
- "{kind} " .format (klass = type (index ), kind = str ( float ) )
491
+ "type float " .format (klass = type (index ). __name__ )
500
492
)
501
493
with pytest .raises (TypeError , match = msg ):
502
494
s [l ] = 0
@@ -517,9 +509,9 @@ def test_integer_positional_indexing(self):
517
509
518
510
klass = RangeIndex
519
511
msg = (
520
- "cannot do slice indexing "
512
+ "cannot do ( slice|positional) indexing "
521
513
r"on {klass} with these indexers \[(2|4)\.0\] of "
522
- "{kind} " .format (klass = str ( klass ), kind = str ( float ) )
514
+ "type float " .format (klass = klass . __name__ )
523
515
)
524
516
with pytest .raises (TypeError , match = msg ):
525
517
idxr (s )[l ]
@@ -544,7 +536,7 @@ def f(idxr):
544
536
msg = (
545
537
"cannot do slice indexing "
546
538
r"on {klass} with these indexers \[(0|1)\.0\] of "
547
- "{kind} " .format (klass = type (index ), kind = str ( float ) )
539
+ "type float " .format (klass = type (index ). __name__ )
548
540
)
549
541
with pytest .raises (TypeError , match = msg ):
550
542
s [l ]
@@ -559,7 +551,7 @@ def f(idxr):
559
551
msg = (
560
552
"cannot do slice indexing "
561
553
r"on {klass} with these indexers \[-10\.0\] of "
562
- "{kind} " .format (klass = type (index ), kind = str ( float ) )
554
+ "type float " .format (klass = type (index ). __name__ )
563
555
)
564
556
with pytest .raises (TypeError , match = msg ):
565
557
s [slice (- 10.0 , 10.0 )]
@@ -578,7 +570,7 @@ def f(idxr):
578
570
msg = (
579
571
"cannot do slice indexing "
580
572
r"on {klass} with these indexers \[0\.5\] of "
581
- "{kind} " .format (klass = type (index ), kind = str ( float ) )
573
+ "type float " .format (klass = type (index ). __name__ )
582
574
)
583
575
with pytest .raises (TypeError , match = msg ):
584
576
s [l ]
@@ -595,7 +587,7 @@ def f(idxr):
595
587
msg = (
596
588
"cannot do slice indexing "
597
589
r"on {klass} with these indexers \[(3|4)\.0\] of "
598
- "{kind} " .format (klass = type (index ), kind = str ( float ) )
590
+ "type float " .format (klass = type (index ). __name__ )
599
591
)
600
592
with pytest .raises (TypeError , match = msg ):
601
593
s [l ] = 0
0 commit comments