Skip to content

CLN More float warnings #50605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pandas/tests/series/methods/test_asof.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def test_scalar(self):

N = 30
rng = date_range("1/1/1990", periods=N, freq="53s")
ts = Series(np.arange(N), index=rng)
# Explicit cast to float avoid implicit cast when setting nan
ts = Series(np.arange(N), index=rng, dtype="float")
ts.iloc[5:10] = np.NaN
ts.iloc[15:20] = np.NaN

Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/series/methods/test_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,8 @@ def test_spline_smooth(self):

@td.skip_if_no_scipy
def test_spline_interpolation(self):
s = Series(np.arange(10) ** 2)
# Explicit cast to float to avoid implicit cast when setting np.nan
s = Series(np.arange(10) ** 2, dtype="float")
s[np.random.randint(0, 9, 3)] = np.nan
result1 = s.interpolate(method="spline", order=1)
expected1 = s.interpolate(method="spline", order=1)
Expand Down
8 changes: 6 additions & 2 deletions pandas/tests/series/methods/test_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def test_rank(self, datetime_series):
iranks = iseries.rank(pct=True)
tm.assert_series_equal(iranks, exp)

# Explicit cast to float to avoid implicit cast when setting nan
iseries = iseries.astype("float")
iseries[1] = np.nan
exp = Series(np.repeat(50.0 / 99.0, 100))
exp[1] = np.nan
Expand All @@ -109,14 +111,16 @@ def test_rank(self, datetime_series):
iranks = iseries.rank(pct=True)
tm.assert_series_equal(iranks, exp)

iseries = Series(np.arange(5)) + 1
# Explicit cast to float to avoid implicit cast when setting nan
iseries = Series(np.arange(5), dtype="float") + 1
iseries[4] = np.nan
exp = iseries / 4.0
iranks = iseries.rank(pct=True)
tm.assert_series_equal(iranks, exp)

rng = date_range("1/1/1990", periods=5)
iseries = Series(np.arange(5), rng) + 1
# Explicit cast to float to avoid implicit cast when setting nan
iseries = Series(np.arange(5), rng, dtype="float") + 1
iseries.iloc[4] = np.nan
exp = iseries / 4.0
iranks = iseries.rank(pct=True)
Expand Down
6 changes: 4 additions & 2 deletions pandas/tests/tools/test_to_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def test_to_datetime_format_YYYYMMDD(self, cache):
tm.assert_series_equal(result, expected)

def test_to_datetime_format_YYYYMMDD_with_nat(self, cache):
ser = Series([19801222, 19801222] + [19810105] * 5)
# Explicit cast to float to explicit cast when setting np.nan
ser = Series([19801222, 19801222] + [19810105] * 5, dtype="float")
# with NaT
expected = Series(
[Timestamp("19801222"), Timestamp("19801222")] + [Timestamp("19810105")] * 5
Expand All @@ -139,7 +140,8 @@ def test_to_datetime_format_YYYYMMDD_with_nat(self, cache):

def test_to_datetime_format_YYYYMM_with_nat(self, cache):
# https://github.com/pandas-dev/pandas/issues/50237
ser = Series([198012, 198012] + [198101] * 5)
# Explicit cast to float to explicit cast when setting np.nan
ser = Series([198012, 198012] + [198101] * 5, dtype="float")
expected = Series(
[Timestamp("19801201"), Timestamp("19801201")] + [Timestamp("19810101")] * 5
)
Expand Down