@@ -54,7 +54,7 @@ def test_scalar_error(self, index_func):
5454
5555 msg = (
5656 "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__ )
5858 )
5959 with pytest .raises (TypeError , match = msg ):
6060 s .iloc [3.0 ] = 0
@@ -92,11 +92,11 @@ def test_scalar_non_numeric(self):
9292 else :
9393 error = TypeError
9494 msg = (
95- r"cannot do (label|index| positional) indexing "
95+ r"cannot do (label|positional) indexing "
9696 r"on {klass} with these indexers \[3\.0\] of "
97- r"{kind} |"
97+ r"type float |"
9898 "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__ )
100100 )
101101 with pytest .raises (error , match = msg ):
102102 idxr (s )[3.0 ]
@@ -113,9 +113,9 @@ def test_scalar_non_numeric(self):
113113 else :
114114 error = TypeError
115115 msg = (
116- r"cannot do ( label|index) indexing "
116+ r"cannot do label indexing "
117117 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__ )
119119 )
120120 with pytest .raises (error , match = msg ):
121121 s .loc [3.0 ]
@@ -125,9 +125,9 @@ def test_scalar_non_numeric(self):
125125
126126 # setting with a float fails with iloc
127127 msg = (
128- r"cannot do (label|index| positional) indexing "
128+ r"cannot do (label|positional) indexing "
129129 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__ )
131131 )
132132 with pytest .raises (TypeError , match = msg ):
133133 s .iloc [3.0 ] = 0
@@ -162,9 +162,9 @@ def test_scalar_non_numeric(self):
162162 s = Series (np .arange (len (i )), index = i )
163163 s [3 ]
164164 msg = (
165- r"cannot do ( label|index) indexing "
165+ r"cannot do label indexing "
166166 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__ )
168168 )
169169 with pytest .raises (TypeError , match = msg ):
170170 s [3.0 ]
@@ -181,9 +181,9 @@ def test_scalar_with_mixed(self):
181181 msg = (
182182 r"cannot do label indexing "
183183 r"on {klass} with these indexers \[1\.0\] of "
184- r"{kind} |"
184+ r"type float |"
185185 "Cannot index by location index with a non-integer key" .format (
186- klass = str ( Index ), kind = str ( float )
186+ klass = Index . __name__
187187 )
188188 )
189189 with pytest .raises (TypeError , match = msg ):
@@ -203,7 +203,7 @@ def test_scalar_with_mixed(self):
203203 msg = (
204204 r"cannot do label indexing "
205205 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__ )
207207 )
208208 with pytest .raises (TypeError , match = msg ):
209209 idxr (s3 )[1.0 ]
@@ -317,7 +317,7 @@ def test_scalar_float(self):
317317 msg = (
318318 r"cannot do positional indexing "
319319 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__ )
321321 )
322322 with pytest .raises (TypeError , match = msg ):
323323 s2 .iloc [3.0 ] = 0
@@ -346,24 +346,20 @@ def test_slice_non_numeric(self):
346346 for l in [slice (3.0 , 4 ), slice (3 , 4.0 ), slice (3.0 , 4.0 )]:
347347
348348 msg = (
349- "cannot do slice indexing "
349+ "cannot do positional indexing "
350350 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__ )
352352 )
353353 with pytest .raises (TypeError , match = msg ):
354354 s .iloc [l ]
355355
356356 for idxr in [lambda x : x .loc , lambda x : x .iloc , lambda x : x ]:
357357
358358 msg = (
359- "cannot do slice indexing "
359+ "cannot do ( slice|positional) indexing "
360360 r"on {klass} with these indexers "
361361 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__ )
367363 )
368364 with pytest .raises (TypeError , match = msg ):
369365 idxr (s )[l ]
@@ -372,23 +368,19 @@ def test_slice_non_numeric(self):
372368 for l in [slice (3.0 , 4 ), slice (3 , 4.0 ), slice (3.0 , 4.0 )]:
373369
374370 msg = (
375- "cannot do slice indexing "
371+ "cannot do positional indexing "
376372 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__ )
378374 )
379375 with pytest .raises (TypeError , match = msg ):
380376 s .iloc [l ] = 0
381377
382378 for idxr in [lambda x : x .loc , lambda x : x .iloc , lambda x : x ]:
383379 msg = (
384- "cannot do slice indexing "
380+ "cannot do ( slice|positional) indexing "
385381 r"on {klass} with these indexers "
386382 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__ )
392384 )
393385 with pytest .raises (TypeError , match = msg ):
394386 idxr (s )[l ] = 0
@@ -428,7 +420,7 @@ def test_slice_integer(self):
428420 msg = (
429421 "cannot do slice indexing "
430422 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__ )
432424 )
433425 with pytest .raises (TypeError , match = msg ):
434426 s [l ]
@@ -452,7 +444,7 @@ def test_slice_integer(self):
452444 msg = (
453445 "cannot do slice indexing "
454446 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__ )
456448 )
457449 with pytest .raises (TypeError , match = msg ):
458450 s [slice (- 6.0 , 6.0 )]
@@ -478,7 +470,7 @@ def test_slice_integer(self):
478470 msg = (
479471 "cannot do slice indexing "
480472 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__ )
482474 )
483475 with pytest .raises (TypeError , match = msg ):
484476 s [l ]
@@ -496,7 +488,7 @@ def test_slice_integer(self):
496488 msg = (
497489 "cannot do slice indexing "
498490 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__ )
500492 )
501493 with pytest .raises (TypeError , match = msg ):
502494 s [l ] = 0
@@ -517,9 +509,9 @@ def test_integer_positional_indexing(self):
517509
518510 klass = RangeIndex
519511 msg = (
520- "cannot do slice indexing "
512+ "cannot do ( slice|positional) indexing "
521513 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__ )
523515 )
524516 with pytest .raises (TypeError , match = msg ):
525517 idxr (s )[l ]
@@ -544,7 +536,7 @@ def f(idxr):
544536 msg = (
545537 "cannot do slice indexing "
546538 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__ )
548540 )
549541 with pytest .raises (TypeError , match = msg ):
550542 s [l ]
@@ -559,7 +551,7 @@ def f(idxr):
559551 msg = (
560552 "cannot do slice indexing "
561553 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__ )
563555 )
564556 with pytest .raises (TypeError , match = msg ):
565557 s [slice (- 10.0 , 10.0 )]
@@ -578,7 +570,7 @@ def f(idxr):
578570 msg = (
579571 "cannot do slice indexing "
580572 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__ )
582574 )
583575 with pytest .raises (TypeError , match = msg ):
584576 s [l ]
@@ -595,7 +587,7 @@ def f(idxr):
595587 msg = (
596588 "cannot do slice indexing "
597589 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__ )
599591 )
600592 with pytest .raises (TypeError , match = msg ):
601593 s [l ] = 0
0 commit comments