@@ -250,15 +250,9 @@ def test_really_large_scalar(large_val, signed, transform, errors):
250250 val = - large_val if signed else large_val
251251
252252 val = transform (val )
253- val_is_string = isinstance (val , str )
254253
255- if val_is_string and errors in (None , "raise" ):
256- msg = "Integer out of range. at position 0"
257- with pytest .raises (ValueError , match = msg ):
258- to_numeric (val , ** kwargs )
259- else :
260- expected = float (val ) if (errors == "coerce" and val_is_string ) else val
261- tm .assert_almost_equal (to_numeric (val , ** kwargs ), expected )
254+ expected = float (val ) if errors == "coerce" else int (val )
255+ tm .assert_almost_equal (to_numeric (val , ** kwargs ), expected )
262256
263257
264258def test_really_large_in_arr (large_val , signed , transform , multiple_elts , errors ):
@@ -270,21 +264,17 @@ def test_really_large_in_arr(large_val, signed, transform, multiple_elts, errors
270264 extra_elt = "string"
271265 arr = [val ] + multiple_elts * [extra_elt ]
272266
273- val_is_string = isinstance (val , str )
274267 coercing = errors == "coerce"
275268
276- if errors in (None , "raise" ) and (val_is_string or multiple_elts ):
277- if val_is_string :
278- msg = "Integer out of range. at position 0"
279- else :
280- msg = 'Unable to parse string "string" at position 1'
269+ if errors in (None , "raise" ) and multiple_elts :
270+ msg = 'Unable to parse string "string" at position 1'
281271
282272 with pytest .raises (ValueError , match = msg ):
283273 to_numeric (arr , ** kwargs )
284274 else :
285275 result = to_numeric (arr , ** kwargs )
286276
287- exp_val = float (val ) if (coercing and val_is_string ) else val
277+ exp_val = float (val ) if (coercing ) else int ( val )
288278 expected = [exp_val ]
289279
290280 if multiple_elts :
@@ -295,7 +285,7 @@ def test_really_large_in_arr(large_val, signed, transform, multiple_elts, errors
295285 expected .append (extra_elt )
296286 exp_dtype = object
297287 else :
298- exp_dtype = float if isinstance (exp_val , ( int , float ) ) else object
288+ exp_dtype = float if isinstance (exp_val , float ) else object
299289
300290 tm .assert_almost_equal (result , np .array (expected , dtype = exp_dtype ))
301291
@@ -311,18 +301,11 @@ def test_really_large_in_arr_consistent(large_val, signed, multiple_elts, errors
311301 if multiple_elts :
312302 arr .insert (0 , large_val )
313303
314- if errors in ( None , "raise" ):
315- index = int (multiple_elts )
316- msg = f"Integer out of range. at position { index } "
304+ result = to_numeric ( arr , ** kwargs )
305+ expected = [ float ( i ) if errors == "coerce" else int (i ) for i in arr ]
306+ exp_dtype = float if errors == "coerce" else object
317307
318- with pytest .raises (ValueError , match = msg ):
319- to_numeric (arr , ** kwargs )
320- else :
321- result = to_numeric (arr , ** kwargs )
322- expected = [float (i ) for i in arr ]
323- exp_dtype = float
324-
325- tm .assert_almost_equal (result , np .array (expected , dtype = exp_dtype ))
308+ tm .assert_almost_equal (result , np .array (expected , dtype = exp_dtype ))
326309
327310
328311@pytest .mark .parametrize (
0 commit comments