Skip to content

Commit

Permalink
Backport PR pandas-dev#60553: TST: filter possible RuntimeWarning in …
Browse files Browse the repository at this point in the history
…tests
  • Loading branch information
mroeschke committed Dec 13, 2024
1 parent 9052c9e commit 9a17d31
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pandas/tests/extension/test_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,31 @@ def _supports_reduction(self, ser: pd.Series, op_name: str) -> bool:
def test_fillna_length_mismatch(self, data_missing):
super().test_fillna_length_mismatch(data_missing)

@pytest.mark.filterwarnings(
"ignore:invalid value encountered in cast:RuntimeWarning"
)
def test_hash_pandas_object(self, data):
super().test_hash_pandas_object(data)

@pytest.mark.filterwarnings(
"ignore:invalid value encountered in cast:RuntimeWarning"
)
def test_hash_pandas_object_works(self, data, as_frame):
super().test_hash_pandas_object_works(data, as_frame)

@pytest.mark.filterwarnings(
"ignore:invalid value encountered in cast:RuntimeWarning"
)
@pytest.mark.parametrize("engine", ["c", "python"])
def test_EA_types(self, engine, data, request):
super().test_EA_types(engine, data, request)

@pytest.mark.filterwarnings(
"ignore:invalid value encountered in cast:RuntimeWarning"
)
def test_astype_str(self, data):
super().test_astype_str(data)


# TODO: either belongs in tests.arrays.interval or move into base tests.
def test_fillna_non_scalar_raises(data_missing):
Expand Down
4 changes: 4 additions & 0 deletions pandas/tests/frame/methods/test_to_numpy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
import pytest

import pandas.util._test_decorators as td

Expand Down Expand Up @@ -41,6 +42,9 @@ def test_to_numpy_copy(self, using_copy_on_write):
else:
assert df.to_numpy(copy=False, na_value=np.nan).base is arr

@pytest.mark.filterwarnings(
"ignore:invalid value encountered in cast:RuntimeWarning"
)
def test_to_numpy_mixed_dtype_to_str(self):
# https://github.com/pandas-dev/pandas/issues/35455
df = DataFrame([[Timestamp("2020-01-01 00:00:00"), 100.0]])
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2450,6 +2450,9 @@ def test_construct_with_two_categoricalindex_series(self):
)
tm.assert_frame_equal(result, expected)

@pytest.mark.filterwarnings(
"ignore:invalid value encountered in cast:RuntimeWarning"
)
def test_constructor_series_nonexact_categoricalindex(self):
# GH 42424
ser = Series(range(100))
Expand Down
6 changes: 6 additions & 0 deletions pandas/tests/indexes/interval/test_astype.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ def test_subtype_datetimelike(self, index, subtype):
with pytest.raises(TypeError, match=msg):
index.astype(dtype)

@pytest.mark.filterwarnings(
"ignore:invalid value encountered in cast:RuntimeWarning"
)
def test_astype_category(self, index):
super().test_astype_category(index)


class TestDatetimelikeSubtype(AstypeTests):
"""Tests specific to IntervalIndex with datetime-like subtype"""
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/indexes/interval/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def test_repr_floats(self):
expected = "(329.973, 345.137] 1\n(345.137, 360.191] 2\ndtype: int64"
assert result == expected

@pytest.mark.filterwarnings(
"ignore:invalid value encountered in cast:RuntimeWarning"
)
@pytest.mark.parametrize(
"tuples, closed, expected_data",
[
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/indexes/interval/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ def test_get_indexer_categorical(self, target, ordered):
expected = index.get_indexer(target)
tm.assert_numpy_array_equal(result, expected)

@pytest.mark.filterwarnings(
"ignore:invalid value encountered in cast:RuntimeWarning"
)
def test_get_indexer_categorical_with_nans(self):
# GH#41934 nans in both index and in target
ii = IntervalIndex.from_breaks(range(5))
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/indexes/test_setops.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ def test_intersection_difference_match_empty(self, index, sort):
tm.assert_index_equal(inter, diff, exact=True)


@pytest.mark.filterwarnings("ignore:invalid value encountered in cast:RuntimeWarning")
@pytest.mark.filterwarnings(r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning")
@pytest.mark.parametrize(
"method", ["intersection", "union", "difference", "symmetric_difference"]
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/io/excel/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,9 @@ def test_excel_date_datetime_format(self, ext, path):
# we need to use df_expected to check the result.
tm.assert_frame_equal(rs2, df_expected)

@pytest.mark.filterwarnings(
"ignore:invalid value encountered in cast:RuntimeWarning"
)
def test_to_excel_interval_no_labels(self, path, using_infer_string):
# see gh-19242
#
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/reshape/test_cut.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ def test_cut_with_duplicated_index_lowest_included():
tm.assert_series_equal(result, expected)


@pytest.mark.filterwarnings("ignore:invalid value encountered in cast:RuntimeWarning")
def test_cut_with_nonexact_categorical_indices():
# GH 42424

Expand Down

0 comments on commit 9a17d31

Please sign in to comment.