The following issues were found
pandas/tests/util/test_assert_index_equal.py
16 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
Categorical,
CategoricalIndex,
Index,
MultiIndex,
NaT,
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
Categorical,
CategoricalIndex,
Index,
MultiIndex,
NaT,
Reported by Pylint.
Line: 15
Column: 1
import pandas._testing as tm
def test_index_equal_levels_mismatch():
msg = """Index are different
Index levels are different
\\[left\\]: 1, Int64Index\\(\\[1, 2, 3\\], dtype='int64'\\)
\\[right\\]: 2, MultiIndex\\(\\[\\('A', 1\\),
Reported by Pylint.
Line: 33
Column: 1
tm.assert_index_equal(idx1, idx2, exact=False)
def test_index_equal_values_mismatch(check_exact):
msg = """MultiIndex level \\[1\\] are different
MultiIndex level \\[1\\] values are different \\(25\\.0 %\\)
\\[left\\]: Int64Index\\(\\[2, 2, 3, 4\\], dtype='int64'\\)
\\[right\\]: Int64Index\\(\\[1, 2, 3, 4\\], dtype='int64'\\)"""
Reported by Pylint.
Line: 47
Column: 1
tm.assert_index_equal(idx1, idx2, check_exact=check_exact)
def test_index_equal_length_mismatch(check_exact):
msg = """Index are different
Index length are different
\\[left\\]: 3, Int64Index\\(\\[1, 2, 3\\], dtype='int64'\\)
\\[right\\]: 4, Int64Index\\(\\[1, 2, 3, 4\\], dtype='int64'\\)"""
Reported by Pylint.
Line: 62
Column: 1
@pytest.mark.parametrize("exact", [False, "equiv"])
def test_index_equal_class(exact):
idx1 = Index([0, 1, 2])
idx2 = RangeIndex(3)
tm.assert_index_equal(idx1, idx2, exact=exact)
Reported by Pylint.
Line: 74
Column: 1
[
[[1, 2, 3.0], "Float64Index\\(\\[1\\.0, 2\\.0, 3\\.0\\], dtype='float64'\\)"],
[range(3), "RangeIndex\\(start=0, stop=3, step=1\\)"],
],
)
def test_index_equal_class_mismatch(check_exact, idx_values, msg_str):
msg = f"""Index are different
Index classes are different
Reported by Pylint.
Line: 90
Column: 1
tm.assert_index_equal(idx1, idx2, exact=True, check_exact=check_exact)
def test_index_equal_values_close(check_exact):
idx1 = Index([1, 2, 3.0])
idx2 = Index([1, 2, 3.0000000001])
if check_exact:
msg = """Index are different
Reported by Pylint.
Line: 107
Column: 1
tm.assert_index_equal(idx1, idx2, check_exact=check_exact)
def test_index_equal_values_less_close(check_exact, rtol):
idx1 = Index([1, 2, 3.0])
idx2 = Index([1, 2, 3.0001])
kwargs = {"check_exact": check_exact, "rtol": rtol}
if check_exact or rtol < 0.5e-3:
Reported by Pylint.
Line: 125
Column: 1
tm.assert_index_equal(idx1, idx2, **kwargs)
def test_index_equal_values_too_far(check_exact, rtol):
idx1 = Index([1, 2, 3])
idx2 = Index([1, 2, 4])
kwargs = {"check_exact": check_exact, "rtol": rtol}
msg = """Index are different
Reported by Pylint.
pandas/tests/io/formats/test_to_excel.py
16 issues
Line: 7
Column: 1
"""
import string
import pytest
import pandas.util._test_decorators as td
import pandas._testing as tm
Reported by Pylint.
Line: 209
Column: 1
("white-space: normal", {"alignment": {"wrap_text": True}}),
# NUMBER FORMAT
("number-format: 0%", {"number_format": {"format_code": "0%"}}),
],
)
def test_css_to_excel(css, expected):
convert = CSSToExcelConverter()
assert expected == convert(css)
Reported by Pylint.
Line: 213
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
)
def test_css_to_excel(css, expected):
convert = CSSToExcelConverter()
assert expected == convert(css)
def test_css_to_excel_multiple():
convert = CSSToExcelConverter()
actual = convert(
Reported by Bandit.
Line: 216
Column: 1
assert expected == convert(css)
def test_css_to_excel_multiple():
convert = CSSToExcelConverter()
actual = convert(
"""
font-weight: bold;
text-decoration: underline;
Reported by Pylint.
Line: 229
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
unused: something;
"""
)
assert {
"font": {"bold": True, "underline": "single", "color": "FF0000"},
"border": {
"top": {"style": "thin"},
"right": {"style": "thin"},
"bottom": {"style": "thin"},
Reported by Bandit.
Line: 257
Column: 1
"font-style: normal; font-style: inherit",
"font-style: italic",
{"font": {"italic": True}},
),
],
)
def test_css_to_excel_inherited(css, inherited, expected):
convert = CSSToExcelConverter(inherited)
assert expected == convert(css)
Reported by Pylint.
Line: 262
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
)
def test_css_to_excel_inherited(css, inherited, expected):
convert = CSSToExcelConverter(inherited)
assert expected == convert(css)
@pytest.mark.parametrize(
"input_color,output_color",
(
Reported by Bandit.
Line: 271
Column: 1
list(CSSToExcelConverter.NAMED_COLORS.items())
+ [("#" + rgb, rgb) for rgb in CSSToExcelConverter.NAMED_COLORS.values()]
+ [("#F0F", "FF00FF"), ("#ABC", "AABBCC")]
),
)
def test_css_to_excel_good_colors(input_color, output_color):
# see gh-18392
css = (
f"border-top-color: {input_color}; "
Reported by Pylint.
Line: 296
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
with tm.assert_produces_warning(None):
convert = CSSToExcelConverter()
assert expected == convert(css)
@pytest.mark.parametrize("input_color", [None, "not-a-color"])
def test_css_to_excel_bad_colors(input_color):
# see gh-18392
Reported by Bandit.
Line: 300
Column: 1
@pytest.mark.parametrize("input_color", [None, "not-a-color"])
def test_css_to_excel_bad_colors(input_color):
# see gh-18392
css = (
f"border-top-color: {input_color}; "
f"border-right-color: {input_color}; "
f"border-bottom-color: {input_color}; "
Reported by Pylint.
pandas/tests/series/indexing/test_set_value.py
16 issues
Line: 19
Column: 5
index = DatetimeIndex(dates)
s = Series(dtype=object)
s._set_value(dates[0], 1.0)
s._set_value(dates[1], np.nan)
expected = Series([1.0, np.nan], index=index)
tm.assert_series_equal(s, expected)
Reported by Pylint.
Line: 20
Column: 5
s = Series(dtype=object)
s._set_value(dates[0], 1.0)
s._set_value(dates[1], np.nan)
expected = Series([1.0, np.nan], index=index)
tm.assert_series_equal(s, expected)
Reported by Pylint.
Line: 29
Column: 11
def test_set_value_dt64(datetime_series):
idx = datetime_series.index[10]
res = datetime_series._set_value(idx, 0)
assert res is None
assert datetime_series[idx] == 0
def test_set_value_str_index(string_series):
Reported by Pylint.
Line: 37
Column: 11
def test_set_value_str_index(string_series):
# equiv
ser = string_series.copy()
res = ser._set_value("foobar", 0)
assert res is None
assert ser.index[-1] == "foobar"
assert ser["foobar"] == 0
ser2 = string_series.copy()
Reported by Pylint.
Line: 1
Column: 1
from datetime import datetime
import numpy as np
from pandas import (
DatetimeIndex,
Series,
)
import pandas._testing as tm
Reported by Pylint.
Line: 12
Column: 1
import pandas._testing as tm
def test_series_set_value():
# GH#1561
dates = [datetime(2001, 1, 1), datetime(2001, 1, 2)]
index = DatetimeIndex(dates)
Reported by Pylint.
Line: 18
Column: 5
dates = [datetime(2001, 1, 1), datetime(2001, 1, 2)]
index = DatetimeIndex(dates)
s = Series(dtype=object)
s._set_value(dates[0], 1.0)
s._set_value(dates[1], np.nan)
expected = Series([1.0, np.nan], index=index)
Reported by Pylint.
Line: 27
Column: 1
tm.assert_series_equal(s, expected)
def test_set_value_dt64(datetime_series):
idx = datetime_series.index[10]
res = datetime_series._set_value(idx, 0)
assert res is None
assert datetime_series[idx] == 0
Reported by Pylint.
Line: 30
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_set_value_dt64(datetime_series):
idx = datetime_series.index[10]
res = datetime_series._set_value(idx, 0)
assert res is None
assert datetime_series[idx] == 0
def test_set_value_str_index(string_series):
# equiv
Reported by Bandit.
Line: 31
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
idx = datetime_series.index[10]
res = datetime_series._set_value(idx, 0)
assert res is None
assert datetime_series[idx] == 0
def test_set_value_str_index(string_series):
# equiv
ser = string_series.copy()
Reported by Bandit.
pandas/tests/series/methods/test_to_frame.py
16 issues
Line: 1
Column: 1
from pandas import (
DataFrame,
Series,
)
import pandas._testing as tm
class TestToFrame:
def test_to_frame(self, datetime_series):
Reported by Pylint.
Line: 8
Column: 1
import pandas._testing as tm
class TestToFrame:
def test_to_frame(self, datetime_series):
datetime_series.name = None
rs = datetime_series.to_frame()
xp = DataFrame(datetime_series.values, index=datetime_series.index)
tm.assert_frame_equal(rs, xp)
Reported by Pylint.
Line: 9
Column: 5
class TestToFrame:
def test_to_frame(self, datetime_series):
datetime_series.name = None
rs = datetime_series.to_frame()
xp = DataFrame(datetime_series.values, index=datetime_series.index)
tm.assert_frame_equal(rs, xp)
Reported by Pylint.
Line: 9
Column: 5
class TestToFrame:
def test_to_frame(self, datetime_series):
datetime_series.name = None
rs = datetime_series.to_frame()
xp = DataFrame(datetime_series.values, index=datetime_series.index)
tm.assert_frame_equal(rs, xp)
Reported by Pylint.
Line: 11
Column: 9
class TestToFrame:
def test_to_frame(self, datetime_series):
datetime_series.name = None
rs = datetime_series.to_frame()
xp = DataFrame(datetime_series.values, index=datetime_series.index)
tm.assert_frame_equal(rs, xp)
datetime_series.name = "testname"
rs = datetime_series.to_frame()
Reported by Pylint.
Line: 12
Column: 9
def test_to_frame(self, datetime_series):
datetime_series.name = None
rs = datetime_series.to_frame()
xp = DataFrame(datetime_series.values, index=datetime_series.index)
tm.assert_frame_equal(rs, xp)
datetime_series.name = "testname"
rs = datetime_series.to_frame()
xp = DataFrame(
Reported by Pylint.
Line: 16
Column: 9
tm.assert_frame_equal(rs, xp)
datetime_series.name = "testname"
rs = datetime_series.to_frame()
xp = DataFrame(
{"testname": datetime_series.values}, index=datetime_series.index
)
tm.assert_frame_equal(rs, xp)
Reported by Pylint.
Line: 17
Column: 9
datetime_series.name = "testname"
rs = datetime_series.to_frame()
xp = DataFrame(
{"testname": datetime_series.values}, index=datetime_series.index
)
tm.assert_frame_equal(rs, xp)
rs = datetime_series.to_frame(name="testdifferent")
Reported by Pylint.
Line: 22
Column: 9
)
tm.assert_frame_equal(rs, xp)
rs = datetime_series.to_frame(name="testdifferent")
xp = DataFrame(
{"testdifferent": datetime_series.values}, index=datetime_series.index
)
tm.assert_frame_equal(rs, xp)
Reported by Pylint.
Line: 23
Column: 9
tm.assert_frame_equal(rs, xp)
rs = datetime_series.to_frame(name="testdifferent")
xp = DataFrame(
{"testdifferent": datetime_series.values}, index=datetime_series.index
)
tm.assert_frame_equal(rs, xp)
def test_to_frame_expanddim(self):
Reported by Pylint.
pandas/tests/indexing/multiindex/test_chaining_and_caching.py
16 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
MultiIndex,
Series,
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
MultiIndex,
Series,
Reported by Pylint.
Line: 15
Column: 1
import pandas.core.common as com
def test_detect_chained_assignment():
# Inplace ops, originally from:
# https://stackoverflow.com/questions/20508968/series-fillna-in-a-multiindex-dataframe-does-not-fill-is-this-a-bug
a = [12, 23]
b = [123, None]
c = [1234, 2345]
Reported by Pylint.
Line: 18
Column: 5
def test_detect_chained_assignment():
# Inplace ops, originally from:
# https://stackoverflow.com/questions/20508968/series-fillna-in-a-multiindex-dataframe-does-not-fill-is-this-a-bug
a = [12, 23]
b = [123, None]
c = [1234, 2345]
d = [12345, 23456]
tuples = [("eyes", "left"), ("eyes", "right"), ("ears", "left"), ("ears", "right")]
events = {
Reported by Pylint.
Line: 19
Column: 5
# Inplace ops, originally from:
# https://stackoverflow.com/questions/20508968/series-fillna-in-a-multiindex-dataframe-does-not-fill-is-this-a-bug
a = [12, 23]
b = [123, None]
c = [1234, 2345]
d = [12345, 23456]
tuples = [("eyes", "left"), ("eyes", "right"), ("ears", "left"), ("ears", "right")]
events = {
("eyes", "left"): a,
Reported by Pylint.
Line: 20
Column: 5
# https://stackoverflow.com/questions/20508968/series-fillna-in-a-multiindex-dataframe-does-not-fill-is-this-a-bug
a = [12, 23]
b = [123, None]
c = [1234, 2345]
d = [12345, 23456]
tuples = [("eyes", "left"), ("eyes", "right"), ("ears", "left"), ("ears", "right")]
events = {
("eyes", "left"): a,
("eyes", "right"): b,
Reported by Pylint.
Line: 21
Column: 5
a = [12, 23]
b = [123, None]
c = [1234, 2345]
d = [12345, 23456]
tuples = [("eyes", "left"), ("eyes", "right"), ("ears", "left"), ("ears", "right")]
events = {
("eyes", "left"): a,
("eyes", "right"): b,
("ears", "left"): c,
Reported by Pylint.
Line: 38
Column: 1
@td.skip_array_manager_invalid_test # with ArrayManager df.loc[0] is not a view
def test_cache_updating():
# 5216
# make sure that we don't try to set a dead cache
a = np.random.rand(10, 3)
df = DataFrame(a, columns=["x", "y", "z"])
tuples = [(i, j) for i in range(5) for j in range(2)]
Reported by Pylint.
Line: 41
Column: 5
def test_cache_updating():
# 5216
# make sure that we don't try to set a dead cache
a = np.random.rand(10, 3)
df = DataFrame(a, columns=["x", "y", "z"])
tuples = [(i, j) for i in range(5) for j in range(2)]
index = MultiIndex.from_tuples(tuples)
df.index = index
Reported by Pylint.
Line: 42
Column: 5
# 5216
# make sure that we don't try to set a dead cache
a = np.random.rand(10, 3)
df = DataFrame(a, columns=["x", "y", "z"])
tuples = [(i, j) for i in range(5) for j in range(2)]
index = MultiIndex.from_tuples(tuples)
df.index = index
# setting via chained assignment
Reported by Pylint.
pandas/util/_decorators.py
16 issues
Line: 14
Column: 1
)
import warnings
from pandas._libs.properties import cache_readonly # noqa
from pandas._typing import F
def deprecate(
name: str,
Reported by Pylint.
Line: 14
Column: 1
)
import warnings
from pandas._libs.properties import cache_readonly # noqa
from pandas._typing import F
def deprecate(
name: str,
Reported by Pylint.
Line: 14
Column: 1
)
import warnings
from pandas._libs.properties import cache_readonly # noqa
from pandas._typing import F
def deprecate(
name: str,
Reported by Pylint.
Line: 76
Column: 34
if alternative.__doc__:
if alternative.__doc__.count("\n") < 3:
raise AssertionError(doc_error_msg)
empty1, summary, empty2, doc = alternative.__doc__.split("\n", 3)
if empty1 or empty2 and not summary:
raise AssertionError(doc_error_msg)
wrapper.__doc__ = dedent(
f"""
{summary.strip()}
Reported by Pylint.
Line: 381
Column: 21
# error: Item "function" of "Union[str, Callable[..., Any]]" has no
# attribute "_docstring_components"
docstring_components.extend(
docstring._docstring_components # type: ignore[union-attr]
)
elif isinstance(docstring, str) or docstring.__doc__:
docstring_components.append(docstring)
# formatting templates and concatenating docstring
Reported by Pylint.
Line: 397
Column: 9
)
# error: "F" has no attribute "_docstring_components"
decorated._docstring_components = ( # type: ignore[attr-defined]
docstring_components
)
return decorated
return decorator
Reported by Pylint.
Line: 1
Column: 1
from __future__ import annotations
from functools import wraps
import inspect
from textwrap import dedent
from typing import (
Any,
Callable,
Mapping,
Reported by Pylint.
Line: 18
Column: 1
from pandas._typing import F
def deprecate(
name: str,
alternative: Callable[..., Any],
version: str,
alt_name: str | None = None,
klass: type[Warning] | None = None,
Reported by Pylint.
Line: 171
Column: 17
old_arg_value = kwargs.pop(old_arg_name, None)
if old_arg_value is not None:
if new_arg_name is None:
msg = (
f"the {repr(old_arg_name)} keyword is deprecated and "
"will be removed in a future version. Please take "
f"steps to stop the use of {repr(old_arg_name)}"
)
Reported by Pylint.
Line: 199
Column: 17
)
warnings.warn(msg, FutureWarning, stacklevel=stacklevel)
if kwargs.get(new_arg_name) is not None:
msg = (
f"Can only specify {repr(old_arg_name)} "
f"or {repr(new_arg_name)}, not both"
)
raise TypeError(msg)
Reported by Pylint.
pandas/tests/io/parser/test_unsupported.py
16 issues
Line: 11
Column: 1
"""
from io import StringIO
import pytest
from pandas.errors import ParserError
import pandas._testing as tm
Reported by Pylint.
Line: 113
Column: 13
def __init__(self, csv_data):
self.data = csv_data
def __iter__(self):
return self
def read(self):
return self.data
Reported by Pylint.
Line: 88
Column: 34
with pytest.raises(ValueError, match=msg):
read_csv(StringIO(data), lineterminator="~~")
def test_python_engine(self, python_engine):
from pandas.io.parsers.readers import _python_unsupported as py_unsupported
data = """1,2,3,,
1,2,3,4,
1,2,3,4,5
Reported by Pylint.
Line: 107
Column: 47
with pytest.raises(ValueError, match=msg):
read_csv(StringIO(data), engine=python_engine, **kwargs)
def test_python_engine_file_no_next(self, python_engine):
# see gh-16530
class NoNextBuffer:
def __init__(self, csv_data):
self.data = csv_data
Reported by Pylint.
Line: 22
Column: 1
@pytest.fixture(params=["python", "python-fwf"], ids=lambda val: val)
def python_engine(request):
return request.param
class TestUnsupportedFeatures:
def test_mangle_dupe_cols_false(self):
Reported by Pylint.
Line: 26
Column: 1
return request.param
class TestUnsupportedFeatures:
def test_mangle_dupe_cols_false(self):
# see gh-12935
data = "a b c\n1 2 3"
msg = "is not supported"
Reported by Pylint.
Line: 27
Column: 5
class TestUnsupportedFeatures:
def test_mangle_dupe_cols_false(self):
# see gh-12935
data = "a b c\n1 2 3"
msg = "is not supported"
for engine in ("c", "python"):
Reported by Pylint.
Line: 27
Column: 5
class TestUnsupportedFeatures:
def test_mangle_dupe_cols_false(self):
# see gh-12935
data = "a b c\n1 2 3"
msg = "is not supported"
for engine in ("c", "python"):
Reported by Pylint.
Line: 36
Column: 5
with pytest.raises(ValueError, match=msg):
read_csv(StringIO(data), engine=engine, mangle_dupe_cols=False)
def test_c_engine(self):
# see gh-6607
data = "a b c\n1 2 3"
msg = "does not support"
# specify C engine with unsupported options (raise)
Reported by Pylint.
Line: 36
Column: 5
with pytest.raises(ValueError, match=msg):
read_csv(StringIO(data), engine=engine, mangle_dupe_cols=False)
def test_c_engine(self):
# see gh-6607
data = "a b c\n1 2 3"
msg = "does not support"
# specify C engine with unsupported options (raise)
Reported by Pylint.
pandas/tests/indexes/interval/test_equals.py
16 issues
Line: 1
Column: 1
import numpy as np
from pandas import (
IntervalIndex,
date_range,
)
class TestEquals:
Reported by Pylint.
Line: 9
Column: 1
)
class TestEquals:
def test_equals(self, closed):
expected = IntervalIndex.from_breaks(np.arange(5), closed=closed)
assert expected.equals(expected)
assert expected.equals(expected.copy())
Reported by Pylint.
Line: 9
Column: 1
)
class TestEquals:
def test_equals(self, closed):
expected = IntervalIndex.from_breaks(np.arange(5), closed=closed)
assert expected.equals(expected)
assert expected.equals(expected.copy())
Reported by Pylint.
Line: 10
Column: 5
class TestEquals:
def test_equals(self, closed):
expected = IntervalIndex.from_breaks(np.arange(5), closed=closed)
assert expected.equals(expected)
assert expected.equals(expected.copy())
assert not expected.equals(expected.astype(object))
Reported by Pylint.
Line: 10
Column: 5
class TestEquals:
def test_equals(self, closed):
expected = IntervalIndex.from_breaks(np.arange(5), closed=closed)
assert expected.equals(expected)
assert expected.equals(expected.copy())
assert not expected.equals(expected.astype(object))
Reported by Pylint.
Line: 12
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
class TestEquals:
def test_equals(self, closed):
expected = IntervalIndex.from_breaks(np.arange(5), closed=closed)
assert expected.equals(expected)
assert expected.equals(expected.copy())
assert not expected.equals(expected.astype(object))
assert not expected.equals(np.array(expected))
assert not expected.equals(list(expected))
Reported by Bandit.
Line: 13
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_equals(self, closed):
expected = IntervalIndex.from_breaks(np.arange(5), closed=closed)
assert expected.equals(expected)
assert expected.equals(expected.copy())
assert not expected.equals(expected.astype(object))
assert not expected.equals(np.array(expected))
assert not expected.equals(list(expected))
Reported by Bandit.
Line: 15
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert expected.equals(expected)
assert expected.equals(expected.copy())
assert not expected.equals(expected.astype(object))
assert not expected.equals(np.array(expected))
assert not expected.equals(list(expected))
assert not expected.equals([1, 2])
assert not expected.equals(np.array([1, 2]))
Reported by Bandit.
Line: 16
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert expected.equals(expected.copy())
assert not expected.equals(expected.astype(object))
assert not expected.equals(np.array(expected))
assert not expected.equals(list(expected))
assert not expected.equals([1, 2])
assert not expected.equals(np.array([1, 2]))
assert not expected.equals(date_range("20130101", periods=2))
Reported by Bandit.
Line: 17
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert not expected.equals(expected.astype(object))
assert not expected.equals(np.array(expected))
assert not expected.equals(list(expected))
assert not expected.equals([1, 2])
assert not expected.equals(np.array([1, 2]))
assert not expected.equals(date_range("20130101", periods=2))
Reported by Bandit.
pandas/tests/indexes/interval/test_formats.py
16 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
Float64Index,
Interval,
IntervalIndex,
Series,
Reported by Pylint.
Line: 103
Column: 18
def test_to_native_types(self, tuples, closed, expected_data):
# GH 28210
index = IntervalIndex.from_tuples(tuples, closed=closed)
result = index._format_native_types()
expected = np.array(expected_data)
tm.assert_numpy_array_equal(result, expected)
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
Float64Index,
Interval,
IntervalIndex,
Series,
Reported by Pylint.
Line: 16
Column: 1
import pandas._testing as tm
class TestIntervalIndexRendering:
def test_frame_repr(self):
# https://github.com/pandas-dev/pandas/pull/24134/files
df = DataFrame(
{"A": [1, 2, 3, 4]}, index=IntervalIndex.from_breaks([0, 1, 2, 3, 4])
)
Reported by Pylint.
Line: 17
Column: 5
class TestIntervalIndexRendering:
def test_frame_repr(self):
# https://github.com/pandas-dev/pandas/pull/24134/files
df = DataFrame(
{"A": [1, 2, 3, 4]}, index=IntervalIndex.from_breaks([0, 1, 2, 3, 4])
)
result = repr(df)
Reported by Pylint.
Line: 17
Column: 5
class TestIntervalIndexRendering:
def test_frame_repr(self):
# https://github.com/pandas-dev/pandas/pull/24134/files
df = DataFrame(
{"A": [1, 2, 3, 4]}, index=IntervalIndex.from_breaks([0, 1, 2, 3, 4])
)
result = repr(df)
Reported by Pylint.
Line: 19
Column: 9
class TestIntervalIndexRendering:
def test_frame_repr(self):
# https://github.com/pandas-dev/pandas/pull/24134/files
df = DataFrame(
{"A": [1, 2, 3, 4]}, index=IntervalIndex.from_breaks([0, 1, 2, 3, 4])
)
result = repr(df)
expected = " A\n(0, 1] 1\n(1, 2] 2\n(2, 3] 3\n(3, 4] 4"
assert result == expected
Reported by Pylint.
Line: 24
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
)
result = repr(df)
expected = " A\n(0, 1] 1\n(1, 2] 2\n(2, 3] 3\n(3, 4] 4"
assert result == expected
@pytest.mark.parametrize(
"constructor,expected",
[
(
Reported by Bandit.
Line: 39
Column: 5
),
),
(DataFrame, (" 0\n(0.0, 1.0] a\nNaN b\n(2.0, 3.0] c")),
],
)
def test_repr_missing(self, constructor, expected):
# GH 25984
index = IntervalIndex.from_tuples([(0, 1), np.nan, (2, 3)])
obj = constructor(list("abc"), index=index)
Reported by Pylint.
Line: 39
Column: 5
),
),
(DataFrame, (" 0\n(0.0, 1.0] a\nNaN b\n(2.0, 3.0] c")),
],
)
def test_repr_missing(self, constructor, expected):
# GH 25984
index = IntervalIndex.from_tuples([(0, 1), np.nan, (2, 3)])
obj = constructor(list("abc"), index=index)
Reported by Pylint.
pandas/tests/tools/test_to_time.py
16 issues
Line: 4
Column: 1
from datetime import time
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import Series
import pandas._testing as tm
Reported by Pylint.
Line: 1
Column: 1
from datetime import time
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import Series
import pandas._testing as tm
Reported by Pylint.
Line: 14
Column: 1
from pandas.core.tools.times import to_time
class TestToTime:
@td.skip_if_has_locale
def test_parsers_time(self):
# GH#11818
strings = [
"14:15",
Reported by Pylint.
Line: 14
Column: 1
from pandas.core.tools.times import to_time
class TestToTime:
@td.skip_if_has_locale
def test_parsers_time(self):
# GH#11818
strings = [
"14:15",
Reported by Pylint.
Line: 16
Column: 5
class TestToTime:
@td.skip_if_has_locale
def test_parsers_time(self):
# GH#11818
strings = [
"14:15",
"1415",
"2:15pm",
Reported by Pylint.
Line: 16
Column: 5
class TestToTime:
@td.skip_if_has_locale
def test_parsers_time(self):
# GH#11818
strings = [
"14:15",
"1415",
"2:15pm",
Reported by Pylint.
Line: 32
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
expected = time(14, 15)
for time_string in strings:
assert to_time(time_string) == expected
new_string = "14.15"
msg = r"Cannot convert arg \['14\.15'\] to a time"
with pytest.raises(ValueError, match=msg):
to_time(new_string)
Reported by Bandit.
Line: 38
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
msg = r"Cannot convert arg \['14\.15'\] to a time"
with pytest.raises(ValueError, match=msg):
to_time(new_string)
assert to_time(new_string, format="%H.%M") == expected
arg = ["14:15", "20:20"]
expected_arr = [time(14, 15), time(20, 20)]
assert to_time(arg) == expected_arr
assert to_time(arg, format="%H:%M") == expected_arr
Reported by Bandit.
Line: 42
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
arg = ["14:15", "20:20"]
expected_arr = [time(14, 15), time(20, 20)]
assert to_time(arg) == expected_arr
assert to_time(arg, format="%H:%M") == expected_arr
assert to_time(arg, infer_time_format=True) == expected_arr
assert to_time(arg, format="%I:%M%p", errors="coerce") == [None, None]
res = to_time(arg, format="%I:%M%p", errors="ignore")
Reported by Bandit.
Line: 43
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
arg = ["14:15", "20:20"]
expected_arr = [time(14, 15), time(20, 20)]
assert to_time(arg) == expected_arr
assert to_time(arg, format="%H:%M") == expected_arr
assert to_time(arg, infer_time_format=True) == expected_arr
assert to_time(arg, format="%I:%M%p", errors="coerce") == [None, None]
res = to_time(arg, format="%I:%M%p", errors="ignore")
tm.assert_numpy_array_equal(res, np.array(arg, dtype=np.object_))
Reported by Bandit.