The following issues were found
pandas/tests/plotting/test_style.py
35 issues
Line: 1
Column: 1
import pytest
from pandas import Series
pytest.importorskip("matplotlib")
from pandas.plotting._matplotlib.style import get_standard_colors
pytestmark = pytest.mark.slow
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas import Series
pytest.importorskip("matplotlib")
from pandas.plotting._matplotlib.style import get_standard_colors
pytestmark = pytest.mark.slow
Reported by Pylint.
Line: 6
Column: 1
from pandas import Series
pytest.importorskip("matplotlib")
from pandas.plotting._matplotlib.style import get_standard_colors
pytestmark = pytest.mark.slow
class TestGetStandardColors:
Reported by Pylint.
Line: 11
Column: 1
pytestmark = pytest.mark.slow
class TestGetStandardColors:
@pytest.mark.parametrize(
"num_colors, expected",
[
(3, ["red", "green", "blue"]),
(5, ["red", "green", "blue", "red", "green"]),
Reported by Pylint.
Line: 20
Column: 5
(7, ["red", "green", "blue", "red", "green", "blue", "red"]),
(2, ["red", "green"]),
(1, ["red"]),
],
)
def test_default_colors_named_from_prop_cycle(self, num_colors, expected):
import matplotlib as mpl
from matplotlib.pyplot import cycler
Reported by Pylint.
Line: 20
Column: 5
(7, ["red", "green", "blue", "red", "green", "blue", "red"]),
(2, ["red", "green"]),
(1, ["red"]),
],
)
def test_default_colors_named_from_prop_cycle(self, num_colors, expected):
import matplotlib as mpl
from matplotlib.pyplot import cycler
Reported by Pylint.
Line: 23
Column: 9
],
)
def test_default_colors_named_from_prop_cycle(self, num_colors, expected):
import matplotlib as mpl
from matplotlib.pyplot import cycler
mpl_params = {
"axes.prop_cycle": cycler(color=["red", "green", "blue"]),
}
Reported by Pylint.
Line: 24
Column: 9
)
def test_default_colors_named_from_prop_cycle(self, num_colors, expected):
import matplotlib as mpl
from matplotlib.pyplot import cycler
mpl_params = {
"axes.prop_cycle": cycler(color=["red", "green", "blue"]),
}
with mpl.rc_context(rc=mpl_params):
Reported by Pylint.
Line: 31
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
}
with mpl.rc_context(rc=mpl_params):
result = get_standard_colors(num_colors=num_colors)
assert result == expected
@pytest.mark.parametrize(
"num_colors, expected",
[
(1, ["b"]),
Reported by Bandit.
Line: 41
Column: 5
(4, ["b", "g", "r", "y"]),
(5, ["b", "g", "r", "y", "b"]),
(7, ["b", "g", "r", "y", "b", "g", "r"]),
],
)
def test_default_colors_named_from_prop_cycle_string(self, num_colors, expected):
import matplotlib as mpl
from matplotlib.pyplot import cycler
Reported by Pylint.
pandas/tests/test_register_accessor.py
35 issues
Line: 3
Column: 1
import contextlib
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.core import accessor
Reported by Pylint.
Line: 37
Column: 9
delattr(obj, attr)
except AttributeError:
pass
obj._accessors.discard(attr)
class MyAccessor:
def __init__(self, obj):
self.obj = obj
Reported by Pylint.
Line: 69
Column: 26
assert o.mine.prop == "item"
after = set(dir(obj))
assert (before ^ after) == {"mine"}
assert "mine" in obj._accessors
def test_accessor_works():
with ensure_removed(pd.Series, "mine"):
pd.api.extensions.register_series_accessor("mine")(MyAccessor)
Reported by Pylint.
Line: 104
Column: 9
with ensure_removed(pd.Series, "bad"):
@pd.api.extensions.register_series_accessor("bad")
class Bad:
def __init__(self, data):
raise AttributeError("whoops")
with pytest.raises(AttributeError, match="whoops"):
pd.Series([], dtype=object).bad
Reported by Pylint.
Line: 109
Column: 13
raise AttributeError("whoops")
with pytest.raises(AttributeError, match="whoops"):
pd.Series([], dtype=object).bad
Reported by Pylint.
Line: 1
Column: 1
import contextlib
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.core import accessor
Reported by Pylint.
Line: 10
Column: 1
from pandas.core import accessor
def test_dirname_mixin():
# GH37173
class X(accessor.DirNamesMixin):
x = 1
y: int
Reported by Pylint.
Line: 13
Column: 5
def test_dirname_mixin():
# GH37173
class X(accessor.DirNamesMixin):
x = 1
y: int
def __init__(self):
self.z = 3
Reported by Pylint.
Line: 13
Column: 5
def test_dirname_mixin():
# GH37173
class X(accessor.DirNamesMixin):
x = 1
y: int
def __init__(self):
self.z = 3
Reported by Pylint.
Line: 13
Column: 5
def test_dirname_mixin():
# GH37173
class X(accessor.DirNamesMixin):
x = 1
y: int
def __init__(self):
self.z = 3
Reported by Pylint.
pandas/core/arrays/integer.py
35 issues
Line: 7
Column: 1
import numpy as np
from pandas._libs import (
iNaT,
lib,
missing as libmissing,
)
from pandas._typing import (
Reported by Pylint.
Line: 7
Column: 1
import numpy as np
from pandas._libs import (
iNaT,
lib,
missing as libmissing,
)
from pandas._typing import (
Reported by Pylint.
Line: 59
Column: 16
"""
def __repr__(self) -> str:
sign = "U" if self.is_unsigned_integer else ""
return f"{sign}Int{8 * self.itemsize}Dtype()"
@cache_readonly
def is_signed_integer(self) -> bool:
return self.kind == "i"
Reported by Pylint.
Line: 64
Column: 16
@cache_readonly
def is_signed_integer(self) -> bool:
return self.kind == "i"
@cache_readonly
def is_unsigned_integer(self) -> bool:
return self.kind == "u"
Reported by Pylint.
Line: 68
Column: 16
@cache_readonly
def is_unsigned_integer(self) -> bool:
return self.kind == "u"
@property
def _is_numeric(self) -> bool:
return True
Reported by Pylint.
Line: 176
Column: 24
raise ValueError(f"invalid dtype specified {dtype}") from err
if isinstance(values, IntegerArray):
values, mask = values._data, values._mask
if dtype is not None:
values = values.astype(dtype.numpy_dtype, copy=False)
if copy:
values = values.copy()
Reported by Pylint.
Line: 176
Column: 38
raise ValueError(f"invalid dtype specified {dtype}") from err
if isinstance(values, IntegerArray):
values, mask = values._data, values._mask
if dtype is not None:
values = values.astype(dtype.numpy_dtype, copy=False)
if copy:
values = values.copy()
Reported by Pylint.
Line: 308
Column: 5
_internal_fill_value = 1
@cache_readonly
def dtype(self) -> _IntegerDtype:
return INT_STR_TO_DTYPE[str(self._data.dtype)]
def __init__(self, values: np.ndarray, mask: np.ndarray, copy: bool = False):
if not (isinstance(values, np.ndarray) and values.dtype.kind in ["i", "u"]):
raise TypeError(
Reported by Pylint.
Line: 333
Column: 5
scalars = to_numeric(strings, errors="raise")
return cls._from_sequence(scalars, dtype=dtype, copy=copy)
def _coerce_to_array(self, value) -> tuple[np.ndarray, np.ndarray]:
return coerce_to_array(value, dtype=self.dtype)
def astype(self, dtype, copy: bool = True) -> ArrayLike:
"""
Cast to a NumPy array or ExtensionArray with 'dtype'.
Reported by Pylint.
Line: 403
Column: 40
mask = None
if isinstance(other, BaseMaskedArray):
other, mask = other._data, other._mask
elif is_list_like(other):
other = np.asarray(other)
if other.ndim > 1:
raise NotImplementedError("can only perform ops with 1-d structures")
Reported by Pylint.
pandas/tests/window/test_win_type.py
35 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas.errors import UnsupportedFunctionCall
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
Series,
Reported by Pylint.
Line: 155
Column: 9
@td.skip_if_no_scipy
def test_win_type_not_implemented():
class CustomIndexer(BaseIndexer):
def get_window_bounds(self, num_values, min_periods, center, closed):
return np.array([0, 1]), np.array([1, 2])
df = DataFrame({"values": range(2)})
indexer = CustomIndexer()
with pytest.raises(NotImplementedError, match="BaseIndexer subclasses not"):
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas.errors import UnsupportedFunctionCall
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
Series,
Reported by Pylint.
Line: 19
Column: 1
@td.skip_if_no_scipy
def test_constructor(frame_or_series):
# GH 12669
c = frame_or_series(range(5)).rolling
# valid
c(win_type="boxcar", window=2, min_periods=1)
Reported by Pylint.
Line: 21
Column: 5
@td.skip_if_no_scipy
def test_constructor(frame_or_series):
# GH 12669
c = frame_or_series(range(5)).rolling
# valid
c(win_type="boxcar", window=2, min_periods=1)
c(win_type="boxcar", window=2, min_periods=1, center=True)
c(win_type="boxcar", window=2, min_periods=1, center=False)
Reported by Pylint.
Line: 31
Column: 1
@pytest.mark.parametrize("w", [2.0, "foo", np.array([2])])
@td.skip_if_no_scipy
def test_invalid_constructor(frame_or_series, w):
# not valid
c = frame_or_series(range(5)).rolling
with pytest.raises(ValueError, match="min_periods must be an integer"):
c(win_type="boxcar", window=2, min_periods=w)
Reported by Pylint.
Line: 31
Column: 1
@pytest.mark.parametrize("w", [2.0, "foo", np.array([2])])
@td.skip_if_no_scipy
def test_invalid_constructor(frame_or_series, w):
# not valid
c = frame_or_series(range(5)).rolling
with pytest.raises(ValueError, match="min_periods must be an integer"):
c(win_type="boxcar", window=2, min_periods=w)
Reported by Pylint.
Line: 34
Column: 5
def test_invalid_constructor(frame_or_series, w):
# not valid
c = frame_or_series(range(5)).rolling
with pytest.raises(ValueError, match="min_periods must be an integer"):
c(win_type="boxcar", window=2, min_periods=w)
with pytest.raises(ValueError, match="center must be a boolean"):
c(win_type="boxcar", window=2, min_periods=1, center=w)
Reported by Pylint.
Line: 43
Column: 1
@pytest.mark.parametrize("wt", ["foobar", 1])
@td.skip_if_no_scipy
def test_invalid_constructor_wintype(frame_or_series, wt):
c = frame_or_series(range(5)).rolling
with pytest.raises(ValueError, match="Invalid win_type"):
c(win_type=wt, window=2)
Reported by Pylint.
Line: 43
Column: 1
@pytest.mark.parametrize("wt", ["foobar", 1])
@td.skip_if_no_scipy
def test_invalid_constructor_wintype(frame_or_series, wt):
c = frame_or_series(range(5)).rolling
with pytest.raises(ValueError, match="Invalid win_type"):
c(win_type=wt, window=2)
Reported by Pylint.
pandas/tests/indexes/interval/test_interval_range.py
35 issues
Line: 4
Column: 1
from datetime import timedelta
import numpy as np
import pytest
from pandas.core.dtypes.common import is_integer
from pandas import (
DateOffset,
Reported by Pylint.
Line: 87
Column: 16
tm.assert_index_equal(result, expected)
# GH 20976: linspace behavior defined from start/end/periods
if not breaks.freq.is_anchored() and tz is None:
# matches expected only for non-anchored offsets and tz naive
# (anchored/DST transitions cause unequal spacing in expected)
result = interval_range(
start=start, end=end, periods=periods, name=name, closed=closed
)
Reported by Pylint.
Line: 87
Column: 16
tm.assert_index_equal(result, expected)
# GH 20976: linspace behavior defined from start/end/periods
if not breaks.freq.is_anchored() and tz is None:
# matches expected only for non-anchored offsets and tz naive
# (anchored/DST transitions cause unequal spacing in expected)
result = interval_range(
start=start, end=end, periods=periods, name=name, closed=closed
)
Reported by Pylint.
Line: 30
Column: 48
class TestIntervalRange:
@pytest.mark.parametrize("freq, periods", [(1, 100), (2.5, 40), (5, 20), (25, 4)])
def test_constructor_numeric(self, closed, name, freq, periods):
start, end = 0, 100
breaks = np.arange(101, step=freq)
expected = IntervalIndex.from_breaks(breaks, name=name, closed=closed)
# defined from start/end/freq
Reported by Pylint.
Line: 63
Column: 50
@pytest.mark.parametrize(
"freq, periods", [("D", 364), ("2D", 182), ("22D18H", 16), ("M", 11)]
)
def test_constructor_timestamp(self, closed, name, freq, periods, tz):
start, end = Timestamp("20180101", tz=tz), Timestamp("20181231", tz=tz)
breaks = date_range(start=start, end=end, freq=freq)
expected = IntervalIndex.from_breaks(breaks, name=name, closed=closed)
# defined from start/end/freq
Reported by Pylint.
Line: 98
Column: 50
@pytest.mark.parametrize(
"freq, periods", [("D", 100), ("2D12H", 40), ("5D", 20), ("25D", 4)]
)
def test_constructor_timedelta(self, closed, name, freq, periods):
start, end = Timedelta("0 days"), Timedelta("100 days")
breaks = timedelta_range(start=start, end=end, freq=freq)
expected = IntervalIndex.from_breaks(breaks, name=name, closed=closed)
# defined from start/end/freq
Reported by Pylint.
Line: 1
Column: 1
from datetime import timedelta
import numpy as np
import pytest
from pandas.core.dtypes.common import is_integer
from pandas import (
DateOffset,
Reported by Pylint.
Line: 24
Column: 1
@pytest.fixture(scope="class", params=[None, "foo"])
def name(request):
return request.param
class TestIntervalRange:
@pytest.mark.parametrize("freq, periods", [(1, 100), (2.5, 40), (5, 20), (25, 4)])
Reported by Pylint.
Line: 28
Column: 1
return request.param
class TestIntervalRange:
@pytest.mark.parametrize("freq, periods", [(1, 100), (2.5, 40), (5, 20), (25, 4)])
def test_constructor_numeric(self, closed, name, freq, periods):
start, end = 0, 100
breaks = np.arange(101, step=freq)
expected = IntervalIndex.from_breaks(breaks, name=name, closed=closed)
Reported by Pylint.
Line: 30
Column: 5
class TestIntervalRange:
@pytest.mark.parametrize("freq, periods", [(1, 100), (2.5, 40), (5, 20), (25, 4)])
def test_constructor_numeric(self, closed, name, freq, periods):
start, end = 0, 100
breaks = np.arange(101, step=freq)
expected = IntervalIndex.from_breaks(breaks, name=name, closed=closed)
# defined from start/end/freq
Reported by Pylint.
pandas/tests/groupby/test_value_counts.py
35 issues
Line: 10
Column: 1
from itertools import product
import numpy as np
import pytest
from pandas import (
Categorical,
CategoricalIndex,
DataFrame,
Reported by Pylint.
Line: 26
Column: 24
# our starting frame
def seed_df(seed_nans, n, m):
np.random.seed(1234)
days = date_range("2015-08-24", periods=10)
frame = DataFrame(
{
Reported by Pylint.
Line: 26
Column: 27
# our starting frame
def seed_df(seed_nans, n, m):
np.random.seed(1234)
days = date_range("2015-08-24", periods=10)
frame = DataFrame(
{
Reported by Pylint.
Line: 26
Column: 13
# our starting frame
def seed_df(seed_nans, n, m):
np.random.seed(1234)
days = date_range("2015-08-24", periods=10)
frame = DataFrame(
{
Reported by Pylint.
Line: 70
Column: 21
@pytest.mark.parametrize("ascending", [True, False])
@pytest.mark.parametrize("dropna", [True, False])
def test_series_groupby_value_counts(
df, keys, bins, n, m, isort, normalize, sort, ascending, dropna
):
def rebuild_index(df):
arr = list(map(df.index.get_level_values, range(df.index.nlevels)))
df.index = MultiIndex.from_arrays(arr, names=df.index.names)
return df
Reported by Pylint.
Line: 70
Column: 24
@pytest.mark.parametrize("ascending", [True, False])
@pytest.mark.parametrize("dropna", [True, False])
def test_series_groupby_value_counts(
df, keys, bins, n, m, isort, normalize, sort, ascending, dropna
):
def rebuild_index(df):
arr = list(map(df.index.get_level_values, range(df.index.nlevels)))
df.index = MultiIndex.from_arrays(arr, names=df.index.names)
return df
Reported by Pylint.
Line: 70
Column: 5
@pytest.mark.parametrize("ascending", [True, False])
@pytest.mark.parametrize("dropna", [True, False])
def test_series_groupby_value_counts(
df, keys, bins, n, m, isort, normalize, sort, ascending, dropna
):
def rebuild_index(df):
arr = list(map(df.index.get_level_values, range(df.index.nlevels)))
df.index = MultiIndex.from_arrays(arr, names=df.index.names)
return df
Reported by Pylint.
Line: 70
Column: 9
@pytest.mark.parametrize("ascending", [True, False])
@pytest.mark.parametrize("dropna", [True, False])
def test_series_groupby_value_counts(
df, keys, bins, n, m, isort, normalize, sort, ascending, dropna
):
def rebuild_index(df):
arr = list(map(df.index.get_level_values, range(df.index.nlevels)))
df.index = MultiIndex.from_arrays(arr, names=df.index.names)
return df
Reported by Pylint.
Line: 70
Column: 15
@pytest.mark.parametrize("ascending", [True, False])
@pytest.mark.parametrize("dropna", [True, False])
def test_series_groupby_value_counts(
df, keys, bins, n, m, isort, normalize, sort, ascending, dropna
):
def rebuild_index(df):
arr = list(map(df.index.get_level_values, range(df.index.nlevels)))
df.index = MultiIndex.from_arrays(arr, names=df.index.names)
return df
Reported by Pylint.
Line: 70
Column: 21
@pytest.mark.parametrize("ascending", [True, False])
@pytest.mark.parametrize("dropna", [True, False])
def test_series_groupby_value_counts(
df, keys, bins, n, m, isort, normalize, sort, ascending, dropna
):
def rebuild_index(df):
arr = list(map(df.index.get_level_values, range(df.index.nlevels)))
df.index = MultiIndex.from_arrays(arr, names=df.index.names)
return df
Reported by Pylint.
pandas/tests/indexing/interval/test_interval.py
35 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
IntervalIndex,
Series,
)
Reported by Pylint.
Line: 51
Column: 21
assert indexer_sl(ser)[key] == expected
else:
with pytest.raises(KeyError, match=str(key)):
indexer_sl(ser)[key]
for key, expected in zip(idx.right, ser):
if idx.closed_right:
assert indexer_sl(ser)[key] == expected
else:
Reported by Pylint.
Line: 58
Column: 21
assert indexer_sl(ser)[key] == expected
else:
with pytest.raises(KeyError, match=str(key)):
indexer_sl(ser)[key]
for key, expected in zip(idx.mid, ser):
assert indexer_sl(ser)[key] == expected
def test_getitem_non_matching(self, series_with_interval_index, indexer_sl):
Reported by Pylint.
Line: 69
Column: 13
# this is a departure from our current
# indexing scheme, but simpler
with pytest.raises(KeyError, match=r"\[-1\] not in index"):
indexer_sl(ser)[[-1, 3, 4, 5]]
with pytest.raises(KeyError, match=r"\[-1\] not in index"):
indexer_sl(ser)[[-1, 3]]
@pytest.mark.slow
Reported by Pylint.
Line: 72
Column: 13
indexer_sl(ser)[[-1, 3, 4, 5]]
with pytest.raises(KeyError, match=r"\[-1\] not in index"):
indexer_sl(ser)[[-1, 3]]
@pytest.mark.slow
def test_loc_getitem_large_series(self):
ser = Series(
np.arange(1000000), index=IntervalIndex.from_breaks(np.arange(1000001))
Reported by Pylint.
Line: 98
Column: 13
tm.assert_frame_equal(result, expected)
with pytest.raises(KeyError, match="10"):
df.loc[10]
# single list-like
result = df.loc[[4]]
expected = df.iloc[4:6]
tm.assert_frame_equal(result, expected)
Reported by Pylint.
Line: 111
Column: 13
tm.assert_frame_equal(result, expected)
with pytest.raises(KeyError, match=r"None of \[\[10\]\] are"):
df.loc[[10]]
# partial missing
with pytest.raises(KeyError, match=r"\[10\] not in index"):
df.loc[[10, 4]]
Reported by Pylint.
Line: 115
Column: 13
# partial missing
with pytest.raises(KeyError, match=r"\[10\] not in index"):
df.loc[[10, 4]]
def test_getitem_interval_with_nans(self, frame_or_series, indexer_sl):
# GH#41831
index = IntervalIndex([np.nan, np.nan])
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
IntervalIndex,
Series,
)
Reported by Pylint.
Line: 13
Column: 1
import pandas._testing as tm
class TestIntervalIndex:
@pytest.fixture
def series_with_interval_index(self):
return Series(np.arange(5), IntervalIndex.from_breaks(np.arange(6)))
def test_getitem_with_scalar(self, series_with_interval_index, indexer_sl):
Reported by Pylint.
asv_bench/benchmarks/timedelta.py
35 issues
Line: 6
Column: 1
benchmarks.tslibs.timedelta for benchmarks that rely only on tslibs.
"""
from pandas import (
DataFrame,
Series,
timedelta_range,
)
Reported by Pylint.
Line: 20
Column: 9
return series
def time_dt_accessor(self, series):
series.dt
def time_timedelta_days(self, series):
series.dt.days
def time_timedelta_seconds(self, series):
Reported by Pylint.
Line: 23
Column: 9
series.dt
def time_timedelta_days(self, series):
series.dt.days
def time_timedelta_seconds(self, series):
series.dt.seconds
def time_timedelta_microseconds(self, series):
Reported by Pylint.
Line: 26
Column: 9
series.dt.days
def time_timedelta_seconds(self, series):
series.dt.seconds
def time_timedelta_microseconds(self, series):
series.dt.microseconds
def time_timedelta_nanoseconds(self, series):
Reported by Pylint.
Line: 29
Column: 9
series.dt.seconds
def time_timedelta_microseconds(self, series):
series.dt.microseconds
def time_timedelta_nanoseconds(self, series):
series.dt.nanoseconds
Reported by Pylint.
Line: 32
Column: 9
series.dt.microseconds
def time_timedelta_nanoseconds(self, series):
series.dt.nanoseconds
class TimedeltaIndexing:
def setup(self):
self.index = timedelta_range(start="1985", periods=1000, freq="D")
Reported by Pylint.
Line: 37
Column: 9
class TimedeltaIndexing:
def setup(self):
self.index = timedelta_range(start="1985", periods=1000, freq="D")
self.index2 = timedelta_range(start="1986", periods=1000, freq="D")
self.series = Series(range(1000), index=self.index)
self.timedelta = self.index[500]
def time_get_loc(self):
Reported by Pylint.
Line: 38
Column: 9
class TimedeltaIndexing:
def setup(self):
self.index = timedelta_range(start="1985", periods=1000, freq="D")
self.index2 = timedelta_range(start="1986", periods=1000, freq="D")
self.series = Series(range(1000), index=self.index)
self.timedelta = self.index[500]
def time_get_loc(self):
self.index.get_loc(self.timedelta)
Reported by Pylint.
Line: 39
Column: 9
def setup(self):
self.index = timedelta_range(start="1985", periods=1000, freq="D")
self.index2 = timedelta_range(start="1986", periods=1000, freq="D")
self.series = Series(range(1000), index=self.index)
self.timedelta = self.index[500]
def time_get_loc(self):
self.index.get_loc(self.timedelta)
Reported by Pylint.
Line: 40
Column: 9
self.index = timedelta_range(start="1985", periods=1000, freq="D")
self.index2 = timedelta_range(start="1986", periods=1000, freq="D")
self.series = Series(range(1000), index=self.index)
self.timedelta = self.index[500]
def time_get_loc(self):
self.index.get_loc(self.timedelta)
def time_shallow_copy(self):
Reported by Pylint.
pandas/core/indexes/period.py
35 issues
Line: 12
Column: 1
import numpy as np
from pandas._libs import (
index as libindex,
lib,
)
from pandas._libs.tslibs import (
BaseOffset,
Reported by Pylint.
Line: 12
Column: 1
import numpy as np
from pandas._libs import (
index as libindex,
lib,
)
from pandas._libs.tslibs import (
BaseOffset,
Reported by Pylint.
Line: 363
Column: 31
if not self.is_monotonic_increasing:
raise ValueError("Index is not monotonic")
values = self.asi8
return ((values[1:] - values[:-1]) < 2).all()
@property
def inferred_type(self) -> str:
# b/c data is represented as ints make sure we can't have ambiguous
# indexing
Reported by Pylint.
Line: 363
Column: 18
if not self.is_monotonic_increasing:
raise ValueError("Index is not monotonic")
values = self.asi8
return ((values[1:] - values[:-1]) < 2).all()
@property
def inferred_type(self) -> str:
# b/c data is represented as ints make sure we can't have ambiguous
# indexing
Reported by Pylint.
Line: 429
Column: 24
# TODO: pass if method is not None, like DTI does?
raise KeyError(key) from err
if reso == self.dtype.resolution:
# the reso < self.dtype.resolution case goes through _get_string_slice
key = Period(parsed, freq=self.freq)
loc = self.get_loc(key, method=method, tolerance=tolerance)
# Recursing instead of falling through matters for the exception
# message in test_get_loc3 (though not clear if that really matters)
Reported by Pylint.
Line: 482
Column: 23
def _can_partial_date_slice(self, reso: Resolution) -> bool:
assert isinstance(reso, Resolution), (type(reso), reso)
# e.g. test_getitem_setitem_periodindex
return reso > self.dtype.resolution
def period_range(
start=None, end=None, periods: int | None = None, freq=None, name=None
) -> PeriodIndex:
Reported by Pylint.
Line: 54
Column: 26
from pandas.core.indexes.extension import inherit_names
from pandas.core.indexes.numeric import Int64Index
_index_doc_kwargs = dict(ibase._index_doc_kwargs)
_index_doc_kwargs.update({"target_klass": "PeriodIndex or list of Periods"})
_shared_doc_kwargs = {
"klass": "PeriodArray",
}
Reported by Pylint.
Line: 69
Column: 16
if values.dtype == "int64":
freq = d.pop("freq", None)
values = PeriodArray(values, freq=freq)
return cls._simple_new(values, **d)
else:
return cls(values, **d)
@inherit_names(
Reported by Pylint.
Line: 75
Column: 46
@inherit_names(
["strftime", "start_time", "end_time"] + PeriodArray._field_ops,
PeriodArray,
wrap=True,
)
@inherit_names(["is_leap_year", "_format_native_types"], PeriodArray)
class PeriodIndex(DatetimeIndexOpsMixin):
Reported by Pylint.
Line: 177
Column: 16
@doc(PeriodArray.to_timestamp)
def to_timestamp(self, freq=None, how="start") -> DatetimeIndex:
arr = self._data.to_timestamp(freq, how)
return DatetimeIndex._simple_new(arr, name=self.name)
# https://github.com/python/mypy/issues/1362
# error: Decorated property not supported
@property # type:ignore[misc]
@doc(PeriodArray.hour.fget)
Reported by Pylint.
pandas/tests/arrays/floating/test_arithmetic.py
35 issues
Line: 4
Column: 1
import operator
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.core.arrays import FloatingArray
Reported by Pylint.
Line: 197
Column: 48
# GH38794
dtype = float_ea_dtype
arr = pd.array(source, dtype=dtype)
neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
neg_target = pd.array(neg_target, dtype=dtype)
abs_target = pd.array(abs_target, dtype=dtype)
tm.assert_extension_array_equal(neg_result, neg_target)
tm.assert_extension_array_equal(pos_result, arr)
Reported by Pylint.
Line: 197
Column: 42
# GH38794
dtype = float_ea_dtype
arr = pd.array(source, dtype=dtype)
neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
neg_target = pd.array(neg_target, dtype=dtype)
abs_target = pd.array(abs_target, dtype=dtype)
tm.assert_extension_array_equal(neg_result, neg_target)
tm.assert_extension_array_equal(pos_result, arr)
Reported by Pylint.
Line: 197
Column: 42
# GH38794
dtype = float_ea_dtype
arr = pd.array(source, dtype=dtype)
neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
neg_target = pd.array(neg_target, dtype=dtype)
abs_target = pd.array(abs_target, dtype=dtype)
tm.assert_extension_array_equal(neg_result, neg_target)
tm.assert_extension_array_equal(pos_result, arr)
Reported by Pylint.
Line: 197
Column: 42
# GH38794
dtype = float_ea_dtype
arr = pd.array(source, dtype=dtype)
neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
neg_target = pd.array(neg_target, dtype=dtype)
abs_target = pd.array(abs_target, dtype=dtype)
tm.assert_extension_array_equal(neg_result, neg_target)
tm.assert_extension_array_equal(pos_result, arr)
Reported by Pylint.
Line: 197
Column: 48
# GH38794
dtype = float_ea_dtype
arr = pd.array(source, dtype=dtype)
neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
neg_target = pd.array(neg_target, dtype=dtype)
abs_target = pd.array(abs_target, dtype=dtype)
tm.assert_extension_array_equal(neg_result, neg_target)
tm.assert_extension_array_equal(pos_result, arr)
Reported by Pylint.
Line: 197
Column: 48
# GH38794
dtype = float_ea_dtype
arr = pd.array(source, dtype=dtype)
neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
neg_target = pd.array(neg_target, dtype=dtype)
abs_target = pd.array(abs_target, dtype=dtype)
tm.assert_extension_array_equal(neg_result, neg_target)
tm.assert_extension_array_equal(pos_result, arr)
Reported by Pylint.
Line: 197
Column: 48
# GH38794
dtype = float_ea_dtype
arr = pd.array(source, dtype=dtype)
neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
neg_target = pd.array(neg_target, dtype=dtype)
abs_target = pd.array(abs_target, dtype=dtype)
tm.assert_extension_array_equal(neg_result, neg_target)
tm.assert_extension_array_equal(pos_result, arr)
Reported by Pylint.
Line: 197
Column: 42
# GH38794
dtype = float_ea_dtype
arr = pd.array(source, dtype=dtype)
neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
neg_target = pd.array(neg_target, dtype=dtype)
abs_target = pd.array(abs_target, dtype=dtype)
tm.assert_extension_array_equal(neg_result, neg_target)
tm.assert_extension_array_equal(pos_result, arr)
Reported by Pylint.
Line: 39
Column: 3
@pytest.mark.parametrize("zero, negative", [(0, False), (0.0, False), (-0.0, True)])
def test_divide_by_zero(dtype, zero, negative):
# TODO pending NA/NaN discussion
# https://github.com/pandas-dev/pandas/issues/32265/
a = pd.array([0, 1, -1, None], dtype=dtype)
result = a / zero
expected = FloatingArray(
np.array([np.nan, np.inf, -np.inf, np.nan], dtype=dtype.numpy_dtype),
Reported by Pylint.