Skip to content

CLN: unnecessary warning-catching #43919

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 3 commits into from
Oct 8, 2021
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
18 changes: 7 additions & 11 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,17 +621,13 @@ def __iter__(self):
chunksize = 10000
chunks = (length // chunksize) + 1

with warnings.catch_warnings():
# filter out warnings about Timestamp.freq
warnings.filterwarnings("ignore", category=FutureWarning)

for i in range(chunks):
start_i = i * chunksize
end_i = min((i + 1) * chunksize, length)
converted = ints_to_pydatetime(
data[start_i:end_i], tz=self.tz, freq=self.freq, box="timestamp"
)
yield from converted
for i in range(chunks):
start_i = i * chunksize
end_i = min((i + 1) * chunksize, length)
converted = ints_to_pydatetime(
data[start_i:end_i], tz=self.tz, freq=self.freq, box="timestamp"
)
yield from converted

def astype(self, dtype, copy: bool = True):
# We handle
Expand Down
10 changes: 5 additions & 5 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -9360,17 +9360,17 @@ def round(
"""
from pandas.core.reshape.concat import concat

def _dict_round(df, decimals):
def _dict_round(df: DataFrame, decimals):
for col, vals in df.items():
try:
yield _series_round(vals, decimals[col])
except KeyError:
yield vals

def _series_round(s, decimals):
if is_integer_dtype(s) or is_float_dtype(s):
return s.round(decimals)
return s
def _series_round(ser: Series, decimals: int):
if is_integer_dtype(ser.dtype) or is_float_dtype(ser.dtype):
return ser.round(decimals)
return ser

nv.validate_round(args, kwargs)

Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/indexes/numeric/test_astype.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

from pandas.core.dtypes.common import pandas_dtype

from pandas import (
from pandas import Index
import pandas._testing as tm
from pandas.core.indexes.api import (
Float64Index,
Index,
Int64Index,
)
import pandas._testing as tm


class TestAstype:
Expand Down
8 changes: 5 additions & 3 deletions pandas/tests/indexes/numeric/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
import pytest

from pandas import (
Float64Index,
Index,
Int64Index,
RangeIndex,
Series,
Timestamp,
UInt64Index,
)
import pandas._testing as tm
from pandas.core.indexes.api import (
Float64Index,
Int64Index,
UInt64Index,
)


@pytest.fixture
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/numeric/test_join.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import numpy as np
import pytest

from pandas import (
import pandas._testing as tm
from pandas.core.indexes.api import (
Index,
Int64Index,
UInt64Index,
)
import pandas._testing as tm


class TestJoinInt64Index:
Expand Down
8 changes: 5 additions & 3 deletions pandas/tests/indexes/numeric/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@

import pandas as pd
from pandas import (
Float64Index,
Index,
Int64Index,
NumericIndex,
Series,
UInt64Index,
)
import pandas._testing as tm
from pandas.core.indexes.api import (
Float64Index,
Int64Index,
UInt64Index,
)
from pandas.tests.indexes.common import NumericBase


Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/numeric/test_setops.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import numpy as np
import pytest

from pandas import (
import pandas._testing as tm
from pandas.core.indexes.api import (
Float64Index,
Index,
Int64Index,
RangeIndex,
UInt64Index,
)
import pandas._testing as tm


@pytest.fixture
Expand Down
6 changes: 4 additions & 2 deletions pandas/tests/indexes/period/methods/test_astype.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
CategoricalIndex,
DatetimeIndex,
Index,
Int64Index,
NaT,
Period,
PeriodIndex,
Timedelta,
UInt64Index,
period_range,
)
import pandas._testing as tm
from pandas.core.indexes.api import (
Int64Index,
UInt64Index,
)


class TestPeriodIndexAsType:
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/ranges/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from pandas import (
Index,
Int64Index,
RangeIndex,
)
import pandas._testing as tm
from pandas.core.indexes.api import Int64Index


class TestJoin:
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/ranges/test_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from pandas.core.dtypes.common import ensure_platform_int

import pandas as pd
from pandas import (
import pandas._testing as tm
from pandas.core.indexes.api import (
Float64Index,
Index,
Int64Index,
RangeIndex,
)
import pandas._testing as tm
from pandas.tests.indexes.common import NumericBase

# aliases to make some tests easier to read
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/ranges/test_setops.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import numpy as np
import pytest

from pandas import (
import pandas._testing as tm
from pandas.core.indexes.api import (
Index,
Int64Index,
RangeIndex,
UInt64Index,
)
import pandas._testing as tm


class TestRangeIndexSetOps:
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/timedeltas/test_timedelta.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import pandas as pd
from pandas import (
Index,
Int64Index,
NaT,
Series,
Timedelta,
TimedeltaIndex,
timedelta_range,
)
import pandas._testing as tm
from pandas.core.indexes.api import Int64Index
from pandas.tests.indexes.datetimelike import DatetimeLike

randn = np.random.randn
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/indexing/test_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,9 @@ def test_partial_set_empty_frame_empty_consistencies(self):
date_range(start="2000", periods=20, freq="D"),
["2000-01-04", "2000-01-08", "2000-01-12"],
[
Timestamp("2000-01-04", freq="D"),
Timestamp("2000-01-08", freq="D"),
Timestamp("2000-01-12", freq="D"),
Timestamp("2000-01-04"),
Timestamp("2000-01-08"),
Timestamp("2000-01-12"),
],
),
(
Expand Down