Skip to content

Commit 3e8b7a4

Browse files
authored
CLN: unnecessary warning-catching (#43919)
1 parent 8765ac7 commit 3e8b7a4

File tree

13 files changed

+42
-40
lines changed

13 files changed

+42
-40
lines changed

pandas/core/arrays/datetimes.py

+7-11
Original file line numberDiff line numberDiff line change
@@ -621,17 +621,13 @@ def __iter__(self):
621621
chunksize = 10000
622622
chunks = (length // chunksize) + 1
623623

624-
with warnings.catch_warnings():
625-
# filter out warnings about Timestamp.freq
626-
warnings.filterwarnings("ignore", category=FutureWarning)
627-
628-
for i in range(chunks):
629-
start_i = i * chunksize
630-
end_i = min((i + 1) * chunksize, length)
631-
converted = ints_to_pydatetime(
632-
data[start_i:end_i], tz=self.tz, freq=self.freq, box="timestamp"
633-
)
634-
yield from converted
624+
for i in range(chunks):
625+
start_i = i * chunksize
626+
end_i = min((i + 1) * chunksize, length)
627+
converted = ints_to_pydatetime(
628+
data[start_i:end_i], tz=self.tz, freq=self.freq, box="timestamp"
629+
)
630+
yield from converted
635631

636632
def astype(self, dtype, copy: bool = True):
637633
# We handle

pandas/core/frame.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -9360,17 +9360,17 @@ def round(
93609360
"""
93619361
from pandas.core.reshape.concat import concat
93629362

9363-
def _dict_round(df, decimals):
9363+
def _dict_round(df: DataFrame, decimals):
93649364
for col, vals in df.items():
93659365
try:
93669366
yield _series_round(vals, decimals[col])
93679367
except KeyError:
93689368
yield vals
93699369

9370-
def _series_round(s, decimals):
9371-
if is_integer_dtype(s) or is_float_dtype(s):
9372-
return s.round(decimals)
9373-
return s
9370+
def _series_round(ser: Series, decimals: int):
9371+
if is_integer_dtype(ser.dtype) or is_float_dtype(ser.dtype):
9372+
return ser.round(decimals)
9373+
return ser
93749374

93759375
nv.validate_round(args, kwargs)
93769376

pandas/tests/indexes/numeric/test_astype.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
from pandas.core.dtypes.common import pandas_dtype
77

8-
from pandas import (
8+
from pandas import Index
9+
import pandas._testing as tm
10+
from pandas.core.indexes.api import (
911
Float64Index,
10-
Index,
1112
Int64Index,
1213
)
13-
import pandas._testing as tm
1414

1515

1616
class TestAstype:

pandas/tests/indexes/numeric/test_indexing.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
import pytest
33

44
from pandas import (
5-
Float64Index,
65
Index,
7-
Int64Index,
86
RangeIndex,
97
Series,
108
Timestamp,
11-
UInt64Index,
129
)
1310
import pandas._testing as tm
11+
from pandas.core.indexes.api import (
12+
Float64Index,
13+
Int64Index,
14+
UInt64Index,
15+
)
1416

1517

1618
@pytest.fixture

pandas/tests/indexes/numeric/test_join.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import numpy as np
22
import pytest
33

4-
from pandas import (
4+
import pandas._testing as tm
5+
from pandas.core.indexes.api import (
56
Index,
67
Int64Index,
78
UInt64Index,
89
)
9-
import pandas._testing as tm
1010

1111

1212
class TestJoinInt64Index:

pandas/tests/indexes/numeric/test_numeric.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55

66
import pandas as pd
77
from pandas import (
8-
Float64Index,
98
Index,
10-
Int64Index,
119
NumericIndex,
1210
Series,
13-
UInt64Index,
1411
)
1512
import pandas._testing as tm
13+
from pandas.core.indexes.api import (
14+
Float64Index,
15+
Int64Index,
16+
UInt64Index,
17+
)
1618
from pandas.tests.indexes.common import NumericBase
1719

1820

pandas/tests/indexes/numeric/test_setops.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
import numpy as np
77
import pytest
88

9-
from pandas import (
9+
import pandas._testing as tm
10+
from pandas.core.indexes.api import (
1011
Float64Index,
1112
Index,
1213
Int64Index,
1314
RangeIndex,
1415
UInt64Index,
1516
)
16-
import pandas._testing as tm
1717

1818

1919
@pytest.fixture

pandas/tests/indexes/period/methods/test_astype.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
CategoricalIndex,
66
DatetimeIndex,
77
Index,
8-
Int64Index,
98
NaT,
109
Period,
1110
PeriodIndex,
1211
Timedelta,
13-
UInt64Index,
1412
period_range,
1513
)
1614
import pandas._testing as tm
15+
from pandas.core.indexes.api import (
16+
Int64Index,
17+
UInt64Index,
18+
)
1719

1820

1921
class TestPeriodIndexAsType:

pandas/tests/indexes/ranges/test_join.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
from pandas import (
44
Index,
5-
Int64Index,
65
RangeIndex,
76
)
87
import pandas._testing as tm
8+
from pandas.core.indexes.api import Int64Index
99

1010

1111
class TestJoin:

pandas/tests/indexes/ranges/test_range.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
from pandas.core.dtypes.common import ensure_platform_int
55

66
import pandas as pd
7-
from pandas import (
7+
import pandas._testing as tm
8+
from pandas.core.indexes.api import (
89
Float64Index,
910
Index,
1011
Int64Index,
1112
RangeIndex,
1213
)
13-
import pandas._testing as tm
1414
from pandas.tests.indexes.common import NumericBase
1515

1616
# aliases to make some tests easier to read

pandas/tests/indexes/ranges/test_setops.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
import numpy as np
77
import pytest
88

9-
from pandas import (
9+
import pandas._testing as tm
10+
from pandas.core.indexes.api import (
1011
Index,
1112
Int64Index,
1213
RangeIndex,
1314
UInt64Index,
1415
)
15-
import pandas._testing as tm
1616

1717

1818
class TestRangeIndexSetOps:

pandas/tests/indexes/timedeltas/test_timedelta.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
import pandas as pd
77
from pandas import (
88
Index,
9-
Int64Index,
109
NaT,
1110
Series,
1211
Timedelta,
1312
TimedeltaIndex,
1413
timedelta_range,
1514
)
1615
import pandas._testing as tm
16+
from pandas.core.indexes.api import Int64Index
1717
from pandas.tests.indexes.datetimelike import DatetimeLike
1818

1919
randn = np.random.randn

pandas/tests/indexing/test_partial.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,9 @@ def test_partial_set_empty_frame_empty_consistencies(self):
540540
date_range(start="2000", periods=20, freq="D"),
541541
["2000-01-04", "2000-01-08", "2000-01-12"],
542542
[
543-
Timestamp("2000-01-04", freq="D"),
544-
Timestamp("2000-01-08", freq="D"),
545-
Timestamp("2000-01-12", freq="D"),
543+
Timestamp("2000-01-04"),
544+
Timestamp("2000-01-08"),
545+
Timestamp("2000-01-12"),
546546
],
547547
),
548548
(

0 commit comments

Comments
 (0)