Skip to content

Commit 1579b3f

Browse files
committed
MAINT: Address comments
1 parent ef29aab commit 1579b3f

File tree

2 files changed

+42
-42
lines changed

2 files changed

+42
-42
lines changed

pandas/core/tools/numeric.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ def to_numeric(arg, errors='raise', downcast=None):
2121
2222
Please note that precision loss may occur if really large numbers
2323
are passed in. Due to the internal limitations of `ndarray`, if
24-
numbers smaller than `-9223372036854775808` or larger than
25-
`18446744073709551615` are passed in, it is very likely they
26-
will be converted to float so that they can stored in an `ndarray`.
27-
These warnings apply similarly to `Series` since it internally
28-
leverages `ndarray`.
24+
numbers smaller than `-9223372036854775808` (np.iinfo(np.int64).min)
25+
or larger than `18446744073709551615` (np.iinfo(np.uint64).max) are
26+
passed in, it is very likely they will be converted to float so that
27+
they can stored in an `ndarray`. These warnings apply similarly to
28+
`Series` since it internally leverages `ndarray`.
2929
3030
Parameters
3131
----------

pandas/tests/tools/test_numeric.py

+37-37
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,43 @@
1111
from pandas.util import testing as tm
1212

1313

14+
@pytest.fixture(params=[None, "ignore", "raise", "coerce"])
15+
def errors(request):
16+
return request.param
17+
18+
19+
@pytest.fixture(params=[True, False])
20+
def signed(request):
21+
return request.param
22+
23+
24+
@pytest.fixture(params=[lambda x: x, str], ids=["identity", "str"])
25+
def transform(request):
26+
return request.param
27+
28+
29+
@pytest.fixture(params=[
30+
47393996303418497800,
31+
100000000000000000000
32+
])
33+
def large_val(request):
34+
return request.param
35+
36+
37+
@pytest.fixture(params=[True, False])
38+
def multiple_elts(request):
39+
return request.param
40+
41+
42+
@pytest.fixture(params=[
43+
(lambda x: Index(x, name="idx"), tm.assert_index_equal),
44+
(lambda x: Series(x, name="ser"), tm.assert_series_equal),
45+
(lambda x: np.array(Index(x).values), tm.assert_numpy_array_equal)
46+
])
47+
def transform_assert_equal(request):
48+
return request.param
49+
50+
1451
@pytest.mark.parametrize("input_kwargs,result_kwargs", [
1552
(dict(), dict(dtype=np.int64)),
1653
(dict(errors="coerce", downcast="integer"), dict(dtype=np.int8))
@@ -174,11 +211,6 @@ def test_all_nan():
174211
tm.assert_series_equal(result, expected)
175212

176213

177-
@pytest.fixture(params=[None, "ignore", "raise", "coerce"])
178-
def errors(request):
179-
return request.param
180-
181-
182214
def test_type_check(errors):
183215
# see gh-11776
184216
df = DataFrame({"a": [1, -3.14, 7], "b": ["4", "5", "6"]})
@@ -189,30 +221,12 @@ def test_type_check(errors):
189221
to_numeric(df, **kwargs)
190222

191223

192-
@pytest.fixture(params=[True, False])
193-
def signed(request):
194-
return request.param
195-
196-
197-
@pytest.fixture(params=[lambda x: x, str], ids=["identity", "str"])
198-
def transform(request):
199-
return request.param
200-
201-
202224
@pytest.mark.parametrize("val", [1, 1.1, 20001])
203225
def test_scalar(val, signed, transform):
204226
val = -val if signed else val
205227
assert to_numeric(transform(val)) == float(val)
206228

207229

208-
@pytest.fixture(params=[
209-
47393996303418497800,
210-
100000000000000000000
211-
])
212-
def large_val(request):
213-
return request.param
214-
215-
216230
def test_really_large_scalar(large_val, signed, transform, errors):
217231
# see gh-24910
218232
kwargs = dict(errors=errors) if errors is not None else dict()
@@ -231,11 +245,6 @@ def test_really_large_scalar(large_val, signed, transform, errors):
231245
assert tm.assert_almost_equal(to_numeric(val, **kwargs), expected)
232246

233247

234-
@pytest.fixture(params=[True, False])
235-
def multiple_elts(request):
236-
return request.param
237-
238-
239248
def test_really_large_in_arr(large_val, signed, transform,
240249
multiple_elts, errors):
241250
# see gh-24910
@@ -323,15 +332,6 @@ def test_scalar_fail(errors, checker):
323332
assert checker(to_numeric(scalar, errors=errors))
324333

325334

326-
@pytest.fixture(params=[
327-
(lambda x: Index(x, name="idx"), tm.assert_index_equal),
328-
(lambda x: Series(x, name="ser"), tm.assert_series_equal),
329-
(lambda x: np.array(Index(x).values), tm.assert_numpy_array_equal)
330-
])
331-
def transform_assert_equal(request):
332-
return request.param
333-
334-
335335
@pytest.mark.parametrize("data", [
336336
[1, 2, 3],
337337
[1., np.nan, 3, np.nan]

0 commit comments

Comments
 (0)