The following issues were found
pandas/tests/tseries/offsets/test_offsets_properties.py
15 issues
Line: 12
Column: 1
"""
import warnings
from hypothesis import (
assume,
given,
strategies as st,
)
from hypothesis.errors import Flaky
Reported by Pylint.
Line: 17
Column: 1
given,
strategies as st,
)
from hypothesis.errors import Flaky
from hypothesis.extra.dateutil import timezones as dateutil_timezones
from hypothesis.extra.pytz import timezones as pytz_timezones
import pytest
import pytz
Reported by Pylint.
Line: 18
Column: 1
strategies as st,
)
from hypothesis.errors import Flaky
from hypothesis.extra.dateutil import timezones as dateutil_timezones
from hypothesis.extra.pytz import timezones as pytz_timezones
import pytest
import pytz
import pandas as pd
Reported by Pylint.
Line: 19
Column: 1
)
from hypothesis.errors import Flaky
from hypothesis.extra.dateutil import timezones as dateutil_timezones
from hypothesis.extra.pytz import timezones as pytz_timezones
import pytest
import pytz
import pandas as pd
from pandas import Timestamp
Reported by Pylint.
Line: 20
Column: 1
from hypothesis.errors import Flaky
from hypothesis.extra.dateutil import timezones as dateutil_timezones
from hypothesis.extra.pytz import timezones as pytz_timezones
import pytest
import pytz
import pandas as pd
from pandas import Timestamp
Reported by Pylint.
Line: 21
Column: 1
from hypothesis.extra.dateutil import timezones as dateutil_timezones
from hypothesis.extra.pytz import timezones as pytz_timezones
import pytest
import pytz
import pandas as pd
from pandas import Timestamp
from pandas.tseries.offsets import (
Reported by Pylint.
Line: 125
Column: 13
dti = pd.date_range(
start="2017-10-30 12:00:00", end="2017-11-06", freq="D", tz="US/Eastern"
)
assert (dti.hour == 12).all() # we haven't screwed up yet
res = dti + offset
assert (res.hour == 12).all()
Reported by Pylint.
Line: 125
Column: 13
dti = pd.date_range(
start="2017-10-30 12:00:00", end="2017-11-06", freq="D", tz="US/Eastern"
)
assert (dti.hour == 12).all() # we haven't screwed up yet
res = dti + offset
assert (res.hour == 12).all()
Reported by Pylint.
Line: 52
Column: 3
gen_date_range = st.builds(
pd.date_range,
start=st.datetimes(
# TODO: Choose the min/max values more systematically
min_value=Timestamp(1900, 1, 1).to_pydatetime(),
max_value=Timestamp(2100, 1, 1).to_pydatetime(),
),
periods=st.integers(min_value=2, max_value=100),
freq=st.sampled_from("Y Q M D H T s ms us ns".split()),
Reported by Pylint.
Line: 96
Column: 1
@pytest.mark.arm_slow
@given(gen_random_datetime, gen_yqm_offset)
def test_on_offset_implementations(dt, offset):
assume(not offset.normalize)
# check that the class-specific implementations of is_on_offset match
# the general case definition:
# (dt + offset) - offset == dt
try:
Reported by Pylint.
pandas/tests/tslibs/test_period_asfreq.py
15 issues
Line: 1
Column: 1
import pytest
from pandas._libs.tslibs import to_offset
from pandas._libs.tslibs.period import (
period_asfreq,
period_ordinal,
)
Reported by Pylint.
Line: 4
Column: 1
import pytest
from pandas._libs.tslibs import to_offset
from pandas._libs.tslibs.period import (
period_asfreq,
period_ordinal,
)
Reported by Pylint.
Line: 4
Column: 1
import pytest
from pandas._libs.tslibs import to_offset
from pandas._libs.tslibs.period import (
period_asfreq,
period_ordinal,
)
Reported by Pylint.
Line: 12
Column: 12
def get_freq_code(freqstr: str) -> int:
off = to_offset(freqstr)
code = off._period_dtype_code
return code
@pytest.mark.parametrize(
"freq1,freq2,expected",
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas._libs.tslibs import to_offset
from pandas._libs.tslibs.period import (
period_asfreq,
period_ordinal,
)
Reported by Pylint.
Line: 10
Column: 1
)
def get_freq_code(freqstr: str) -> int:
off = to_offset(freqstr)
code = off._period_dtype_code
return code
Reported by Pylint.
Line: 40
Column: 1
("L", "U", 1000),
("L", "N", 1000000),
("U", "N", 1000),
],
)
def test_intra_day_conversion_factors(freq1, freq2, expected):
assert (
period_asfreq(1, get_freq_code(freq1), get_freq_code(freq2), False) == expected
)
Reported by Pylint.
Line: 43
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
],
)
def test_intra_day_conversion_factors(freq1, freq2, expected):
assert (
period_asfreq(1, get_freq_code(freq1), get_freq_code(freq2), False) == expected
)
@pytest.mark.parametrize(
Reported by Bandit.
Line: 50
Column: 1
@pytest.mark.parametrize(
"freq,expected", [("A", 0), ("M", 0), ("W", 1), ("D", 0), ("B", 0)]
)
def test_period_ordinal_start_values(freq, expected):
# information for Jan. 1, 1970.
assert period_ordinal(1970, 1, 1, 0, 0, 0, 0, 0, get_freq_code(freq)) == expected
Reported by Pylint.
Line: 53
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
)
def test_period_ordinal_start_values(freq, expected):
# information for Jan. 1, 1970.
assert period_ordinal(1970, 1, 1, 0, 0, 0, 0, 0, get_freq_code(freq)) == expected
@pytest.mark.parametrize(
"dt,expected",
[
Reported by Bandit.
pandas/tests/io/parser/test_dialect.py
15 issues
Line: 9
Column: 1
import csv
from io import StringIO
import pytest
from pandas.errors import ParserWarning
from pandas import DataFrame
import pandas._testing as tm
Reported by Pylint.
Line: 85
Column: 57
[None, "doublequote", "escapechar", "skipinitialspace", "quotechar", "quoting"],
)
@pytest.mark.parametrize("value", ["dialect", "default", "other"])
def test_dialect_conflict_except_delimiter(all_parsers, custom_dialect, arg, value):
# see gh-23761.
dialect_name, dialect_kwargs = custom_dialect
parser = all_parsers
expected = DataFrame({"a": [1], "b": [2]})
Reported by Pylint.
Line: 85
Column: 78
[None, "doublequote", "escapechar", "skipinitialspace", "quotechar", "quoting"],
)
@pytest.mark.parametrize("value", ["dialect", "default", "other"])
def test_dialect_conflict_except_delimiter(all_parsers, custom_dialect, arg, value):
# see gh-23761.
dialect_name, dialect_kwargs = custom_dialect
parser = all_parsers
expected = DataFrame({"a": [1], "b": [2]})
Reported by Pylint.
Line: 133
Column: 50
"delimiter-conflict2",
],
)
def test_dialect_conflict_delimiter(all_parsers, custom_dialect, kwargs, warning_klass):
# see gh-23761.
dialect_name, dialect_kwargs = custom_dialect
parser = all_parsers
expected = DataFrame({"a": [1], "b": [2]})
Reported by Pylint.
Line: 18
Column: 1
@pytest.fixture
def custom_dialect():
dialect_name = "weird"
dialect_kwargs = {
"doublequote": False,
"escapechar": "~",
"delimiter": ":",
Reported by Pylint.
Line: 31
Column: 1
return dialect_name, dialect_kwargs
def test_dialect(all_parsers):
parser = all_parsers
data = """\
label1,label2,label3
index1,"a,c,e
index2,b,d,f
Reported by Pylint.
Line: 41
Column: 5
dia = csv.excel()
dia.quoting = csv.QUOTE_NONE
df = parser.read_csv(StringIO(data), dialect=dia)
data = """\
label1,label2,label3
index1,a,c,e
index2,b,d,f
Reported by Pylint.
Line: 53
Column: 1
tm.assert_frame_equal(df, exp)
def test_dialect_str(all_parsers):
dialect_name = "mydialect"
parser = all_parsers
data = """\
fruit:vegetable
apple:broccoli
Reported by Pylint.
Line: 64
Column: 9
exp = DataFrame({"fruit": ["apple", "pear"], "vegetable": ["broccoli", "tomato"]})
with tm.with_csv_dialect(dialect_name, delimiter=":"):
df = parser.read_csv(StringIO(data), dialect=dialect_name)
tm.assert_frame_equal(df, exp)
def test_invalid_dialect(all_parsers):
class InvalidDialect:
Reported by Pylint.
Line: 68
Column: 1
tm.assert_frame_equal(df, exp)
def test_invalid_dialect(all_parsers):
class InvalidDialect:
pass
data = "a\n1"
parser = all_parsers
Reported by Pylint.
pandas/tests/series/methods/test_unique.py
15 issues
Line: 1
Column: 1
import numpy as np
from pandas import (
Categorical,
Series,
)
import pandas._testing as tm
Reported by Pylint.
Line: 10
Column: 1
import pandas._testing as tm
class TestUnique:
def test_unique_data_ownership(self):
# it works! GH#1807
Series(Series(["a", "c", "b"]).unique()).sort_values()
def test_unique(self):
Reported by Pylint.
Line: 11
Column: 5
class TestUnique:
def test_unique_data_ownership(self):
# it works! GH#1807
Series(Series(["a", "c", "b"]).unique()).sort_values()
def test_unique(self):
# GH#714 also, dtype=float
Reported by Pylint.
Line: 11
Column: 5
class TestUnique:
def test_unique_data_ownership(self):
# it works! GH#1807
Series(Series(["a", "c", "b"]).unique()).sort_values()
def test_unique(self):
# GH#714 also, dtype=float
Reported by Pylint.
Line: 15
Column: 5
# it works! GH#1807
Series(Series(["a", "c", "b"]).unique()).sort_values()
def test_unique(self):
# GH#714 also, dtype=float
ser = Series([1.2345] * 100)
ser[::2] = np.nan
result = ser.unique()
assert len(result) == 2
Reported by Pylint.
Line: 15
Column: 5
# it works! GH#1807
Series(Series(["a", "c", "b"]).unique()).sort_values()
def test_unique(self):
# GH#714 also, dtype=float
ser = Series([1.2345] * 100)
ser[::2] = np.nan
result = ser.unique()
assert len(result) == 2
Reported by Pylint.
Line: 20
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
ser = Series([1.2345] * 100)
ser[::2] = np.nan
result = ser.unique()
assert len(result) == 2
# explicit f4 dtype
ser = Series([1.2345] * 100, dtype="f4")
ser[::2] = np.nan
result = ser.unique()
Reported by Bandit.
Line: 26
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
ser = Series([1.2345] * 100, dtype="f4")
ser[::2] = np.nan
result = ser.unique()
assert len(result) == 2
def test_unique_nan_object_dtype(self):
# NAs in object arrays GH#714
ser = Series(["foo"] * 100, dtype="O")
ser[::2] = np.nan
Reported by Bandit.
Line: 28
Column: 5
result = ser.unique()
assert len(result) == 2
def test_unique_nan_object_dtype(self):
# NAs in object arrays GH#714
ser = Series(["foo"] * 100, dtype="O")
ser[::2] = np.nan
result = ser.unique()
assert len(result) == 2
Reported by Pylint.
Line: 28
Column: 5
result = ser.unique()
assert len(result) == 2
def test_unique_nan_object_dtype(self):
# NAs in object arrays GH#714
ser = Series(["foo"] * 100, dtype="O")
ser[::2] = np.nan
result = ser.unique()
assert len(result) == 2
Reported by Pylint.
pandas/tests/test_errors.py
14 issues
Line: 1
Column: 1
import pytest
from pandas.errors import AbstractMethodError
import pandas as pd
@pytest.mark.parametrize(
"exc",
Reported by Pylint.
Line: 66
Column: 9
xpr = "This property must be defined in the concrete class Foo"
with pytest.raises(AbstractMethodError, match=xpr):
Foo().property
xpr = "This method must be defined in the concrete class Foo"
with pytest.raises(AbstractMethodError, match=xpr):
Foo().method()
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas.errors import AbstractMethodError
import pandas as pd
@pytest.mark.parametrize(
"exc",
Reported by Pylint.
Line: 22
Column: 1
"MergeError",
"OptionError",
"NumbaUtilError",
],
)
def test_exception_importable(exc):
from pandas import errors
err = getattr(errors, exc)
Reported by Pylint.
Line: 25
Column: 5
],
)
def test_exception_importable(exc):
from pandas import errors
err = getattr(errors, exc)
assert err is not None
# check that we can raise on them
Reported by Pylint.
Line: 28
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
from pandas import errors
err = getattr(errors, exc)
assert err is not None
# check that we can raise on them
msg = "^$"
Reported by Bandit.
Line: 38
Column: 1
raise err()
def test_catch_oob():
from pandas import errors
msg = "Out of bounds nanosecond timestamp: 1500-01-01 00:00:00"
with pytest.raises(errors.OutOfBoundsDatetime, match=msg):
pd.Timestamp("15000101")
Reported by Pylint.
Line: 39
Column: 5
def test_catch_oob():
from pandas import errors
msg = "Out of bounds nanosecond timestamp: 1500-01-01 00:00:00"
with pytest.raises(errors.OutOfBoundsDatetime, match=msg):
pd.Timestamp("15000101")
Reported by Pylint.
Line: 46
Column: 1
pd.Timestamp("15000101")
class Foo:
@classmethod
def classmethod(cls):
raise AbstractMethodError(cls, methodtype="classmethod")
@property
Reported by Pylint.
Line: 48
Column: 5
class Foo:
@classmethod
def classmethod(cls):
raise AbstractMethodError(cls, methodtype="classmethod")
@property
def property(self):
raise AbstractMethodError(self, methodtype="property")
Reported by Pylint.
pandas/tests/series/methods/test_is_monotonic.py
14 issues
Line: 1
Column: 1
import numpy as np
from pandas import (
Series,
date_range,
)
class TestIsMonotonic:
Reported by Pylint.
Line: 9
Column: 1
)
class TestIsMonotonic:
def test_is_monotonic_numeric(self):
ser = Series(np.random.randint(0, 10, size=1000))
assert not ser.is_monotonic
ser = Series(np.arange(1000))
Reported by Pylint.
Line: 10
Column: 5
class TestIsMonotonic:
def test_is_monotonic_numeric(self):
ser = Series(np.random.randint(0, 10, size=1000))
assert not ser.is_monotonic
ser = Series(np.arange(1000))
assert ser.is_monotonic is True
Reported by Pylint.
Line: 10
Column: 5
class TestIsMonotonic:
def test_is_monotonic_numeric(self):
ser = Series(np.random.randint(0, 10, size=1000))
assert not ser.is_monotonic
ser = Series(np.arange(1000))
assert ser.is_monotonic is True
Reported by Pylint.
Line: 13
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_is_monotonic_numeric(self):
ser = Series(np.random.randint(0, 10, size=1000))
assert not ser.is_monotonic
ser = Series(np.arange(1000))
assert ser.is_monotonic is True
assert ser.is_monotonic_increasing is True
ser = Series(np.arange(1000, 0, -1))
assert ser.is_monotonic_decreasing is True
Reported by Bandit.
Line: 15
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
ser = Series(np.random.randint(0, 10, size=1000))
assert not ser.is_monotonic
ser = Series(np.arange(1000))
assert ser.is_monotonic is True
assert ser.is_monotonic_increasing is True
ser = Series(np.arange(1000, 0, -1))
assert ser.is_monotonic_decreasing is True
def test_is_monotonic_dt64(self):
Reported by Bandit.
Line: 16
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert not ser.is_monotonic
ser = Series(np.arange(1000))
assert ser.is_monotonic is True
assert ser.is_monotonic_increasing is True
ser = Series(np.arange(1000, 0, -1))
assert ser.is_monotonic_decreasing is True
def test_is_monotonic_dt64(self):
Reported by Bandit.
Line: 18
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert ser.is_monotonic is True
assert ser.is_monotonic_increasing is True
ser = Series(np.arange(1000, 0, -1))
assert ser.is_monotonic_decreasing is True
def test_is_monotonic_dt64(self):
ser = Series(date_range("20130101", periods=10))
assert ser.is_monotonic is True
Reported by Bandit.
Line: 20
Column: 5
ser = Series(np.arange(1000, 0, -1))
assert ser.is_monotonic_decreasing is True
def test_is_monotonic_dt64(self):
ser = Series(date_range("20130101", periods=10))
assert ser.is_monotonic is True
assert ser.is_monotonic_increasing is True
Reported by Pylint.
Line: 20
Column: 5
ser = Series(np.arange(1000, 0, -1))
assert ser.is_monotonic_decreasing is True
def test_is_monotonic_dt64(self):
ser = Series(date_range("20130101", periods=10))
assert ser.is_monotonic is True
assert ser.is_monotonic_increasing is True
Reported by Pylint.
pandas/tests/series/methods/test_drop.py
14 issues
Line: 1
Column: 1
import pytest
from pandas import Series
import pandas._testing as tm
@pytest.mark.parametrize(
"data, index, drop_labels, axis, expected_data, expected_index",
[
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas import Series
import pandas._testing as tm
@pytest.mark.parametrize(
"data, index, drop_labels, axis, expected_data, expected_index",
[
Reported by Pylint.
Line: 18
Column: 1
([1, 1, 2], ["one", "two", "one"], "two", 0, [1, 2], ["one", "one"]),
([1, 1, 2], ["one", "two", "one"], ["one"], 0, [1], ["two"]),
([1, 1, 2], ["one", "two", "one"], "one", 0, [1], ["two"]),
],
)
def test_drop_unique_and_non_unique_index(
data, index, axis, drop_labels, expected_data, expected_index
):
Reported by Pylint.
Line: 18
Column: 1
([1, 1, 2], ["one", "two", "one"], "two", 0, [1, 2], ["one", "one"]),
([1, 1, 2], ["one", "two", "one"], ["one"], 0, [1], ["two"]),
([1, 1, 2], ["one", "two", "one"], "one", 0, [1], ["two"]),
],
)
def test_drop_unique_and_non_unique_index(
data, index, axis, drop_labels, expected_data, expected_index
):
Reported by Pylint.
Line: 24
Column: 5
data, index, axis, drop_labels, expected_data, expected_index
):
s = Series(data=data, index=index)
result = s.drop(drop_labels, axis=axis)
expected = Series(data=expected_data, index=expected_index)
tm.assert_series_equal(result, expected)
Reported by Pylint.
Line: 38
Column: 1
# bad axis
(range(3), list("abc"), ("a",), 0, KeyError, "not found in axis"),
(range(3), list("abc"), "one", "columns", ValueError, "No axis named columns"),
],
)
def test_drop_exception_raised(data, index, drop_labels, axis, error_type, error_desc):
ser = Series(data, index=index)
with pytest.raises(error_type, match=error_desc):
ser.drop(drop_labels, axis=axis)
Reported by Pylint.
Line: 38
Column: 1
# bad axis
(range(3), list("abc"), ("a",), 0, KeyError, "not found in axis"),
(range(3), list("abc"), "one", "columns", ValueError, "No axis named columns"),
],
)
def test_drop_exception_raised(data, index, drop_labels, axis, error_type, error_desc):
ser = Series(data, index=index)
with pytest.raises(error_type, match=error_desc):
ser.drop(drop_labels, axis=axis)
Reported by Pylint.
Line: 46
Column: 1
ser.drop(drop_labels, axis=axis)
def test_drop_with_ignore_errors():
# errors='ignore'
s = Series(range(3), index=list("abc"))
result = s.drop("bc", errors="ignore")
tm.assert_series_equal(result, s)
result = s.drop(["a", "d"], errors="ignore")
Reported by Pylint.
Line: 48
Column: 5
def test_drop_with_ignore_errors():
# errors='ignore'
s = Series(range(3), index=list("abc"))
result = s.drop("bc", errors="ignore")
tm.assert_series_equal(result, s)
result = s.drop(["a", "d"], errors="ignore")
expected = s.iloc[1:]
tm.assert_series_equal(result, expected)
Reported by Pylint.
Line: 56
Column: 5
tm.assert_series_equal(result, expected)
# GH 8522
s = Series([2, 3], index=[True, False])
assert s.index.is_object()
result = s.drop(True)
expected = Series([3], index=[False])
tm.assert_series_equal(result, expected)
Reported by Pylint.
pandas/tests/io/parser/test_converters.py
14 issues
Line: 9
Column: 1
from dateutil.parser import parse
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
Index,
Reported by Pylint.
Line: 19
Column: 1
import pandas._testing as tm
def test_converters_type_must_be_dict(all_parsers):
parser = all_parsers
data = """index,A,B,C,D
foo,2,3,4,5
"""
Reported by Pylint.
Line: 32
Column: 1
@pytest.mark.parametrize("column", [3, "D"])
@pytest.mark.parametrize(
"converter", [parse, lambda x: int(x.split("/")[2])] # Produce integer.
)
def test_converters(all_parsers, column, converter):
parser = all_parsers
data = """A,B,C,D
a,1,2,01/01/2009
b,3,4,01/02/2009
Reported by Pylint.
Line: 48
Column: 1
tm.assert_frame_equal(result, expected)
def test_converters_no_implicit_conv(all_parsers):
# see gh-2184
parser = all_parsers
data = """000102,1.2,A\n001245,2,B"""
converters = {0: lambda x: x.strip()}
Reported by Pylint.
Line: 61
Column: 1
tm.assert_frame_equal(result, expected)
def test_converters_euro_decimal_format(all_parsers):
# see gh-583
converters = {}
parser = all_parsers
data = """Id;Number1;Number2;Text1;Text2;Number3
Reported by Pylint.
Line: 86
Column: 1
tm.assert_frame_equal(result, expected)
def test_converters_corner_with_nans(all_parsers):
parser = all_parsers
data = """id,score,days
1,2,12
2,2-5,
3,,14+
Reported by Pylint.
Line: 95
Column: 5
4,6-12,2"""
# Example converters.
def convert_days(x):
x = x.strip()
if not x:
return np.nan
Reported by Pylint.
Line: 110
Column: 5
return x
def convert_days_sentinel(x):
x = x.strip()
if not x:
return np.nan
Reported by Pylint.
Line: 125
Column: 5
return x
def convert_score(x):
x = x.strip()
if not x:
return np.nan
Reported by Pylint.
Line: 147
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
converters={"score": convert_score, "days": day_converter},
na_values=["", None],
)
assert pd.isna(result["days"][1])
results.append(result)
tm.assert_frame_equal(results[0], results[1])
Reported by Bandit.
pandas/tests/series/methods/test_round.py
14 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import Series
import pandas._testing as tm
class TestSeriesRound:
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import Series
import pandas._testing as tm
class TestSeriesRound:
Reported by Pylint.
Line: 9
Column: 1
import pandas._testing as tm
class TestSeriesRound:
def test_round(self, datetime_series):
datetime_series.index.name = "index_name"
result = datetime_series.round(2)
expected = Series(
np.round(datetime_series.values, 2), index=datetime_series.index, name="ts"
Reported by Pylint.
Line: 10
Column: 5
class TestSeriesRound:
def test_round(self, datetime_series):
datetime_series.index.name = "index_name"
result = datetime_series.round(2)
expected = Series(
np.round(datetime_series.values, 2), index=datetime_series.index, name="ts"
)
Reported by Pylint.
Line: 10
Column: 5
class TestSeriesRound:
def test_round(self, datetime_series):
datetime_series.index.name = "index_name"
result = datetime_series.round(2)
expected = Series(
np.round(datetime_series.values, 2), index=datetime_series.index, name="ts"
)
Reported by Pylint.
Line: 17
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
np.round(datetime_series.values, 2), index=datetime_series.index, name="ts"
)
tm.assert_series_equal(result, expected)
assert result.name == datetime_series.name
def test_round_numpy(self, any_float_dtype):
# See GH#12600
ser = Series([1.53, 1.36, 0.06], dtype=any_float_dtype)
out = np.round(ser, decimals=0)
Reported by Bandit.
Line: 19
Column: 5
tm.assert_series_equal(result, expected)
assert result.name == datetime_series.name
def test_round_numpy(self, any_float_dtype):
# See GH#12600
ser = Series([1.53, 1.36, 0.06], dtype=any_float_dtype)
out = np.round(ser, decimals=0)
expected = Series([2.0, 1.0, 0.0], dtype=any_float_dtype)
tm.assert_series_equal(out, expected)
Reported by Pylint.
Line: 19
Column: 5
tm.assert_series_equal(result, expected)
assert result.name == datetime_series.name
def test_round_numpy(self, any_float_dtype):
# See GH#12600
ser = Series([1.53, 1.36, 0.06], dtype=any_float_dtype)
out = np.round(ser, decimals=0)
expected = Series([2.0, 1.0, 0.0], dtype=any_float_dtype)
tm.assert_series_equal(out, expected)
Reported by Pylint.
Line: 30
Column: 5
with pytest.raises(ValueError, match=msg):
np.round(ser, decimals=0, out=ser)
def test_round_numpy_with_nan(self, any_float_dtype):
# See GH#14197
ser = Series([1.53, np.nan, 0.06], dtype=any_float_dtype)
with tm.assert_produces_warning(None):
result = ser.round()
expected = Series([2.0, np.nan, 0.0], dtype=any_float_dtype)
Reported by Pylint.
Line: 30
Column: 5
with pytest.raises(ValueError, match=msg):
np.round(ser, decimals=0, out=ser)
def test_round_numpy_with_nan(self, any_float_dtype):
# See GH#14197
ser = Series([1.53, np.nan, 0.06], dtype=any_float_dtype)
with tm.assert_produces_warning(None):
result = ser.round()
expected = Series([2.0, np.nan, 0.0], dtype=any_float_dtype)
Reported by Pylint.
pandas/tests/util/test_show_versions.py
14 issues
Line: 5
Column: 1
import os
import re
import pytest
from pandas.util._print_versions import (
_get_dependency_info,
_get_sys_info,
)
Reported by Pylint.
Line: 1
Column: 1
import json
import os
import re
import pytest
from pandas.util._print_versions import (
_get_dependency_info,
_get_sys_info,
Reported by Pylint.
Line: 30
Column: 1
@pytest.mark.filterwarnings(
# pandas_datareader
"ignore:pandas.util.testing is deprecated:FutureWarning"
)
@pytest.mark.filterwarnings(
# https://github.com/pandas-dev/pandas/issues/35252
"ignore:Distutils:UserWarning"
)
def test_show_versions(tmpdir):
Reported by Pylint.
Line: 41
Column: 27
pd.show_versions(as_json=as_json)
with open(as_json) as fd:
# check if file output is valid JSON, will raise an exception if not
result = json.load(fd)
# Basic check that each version element is found in output
expected = {
Reported by Pylint.
Line: 51
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
"dependencies": _get_dependency_info(),
}
assert result == expected
def test_show_versions_console_json(capsys):
# GH39701
pd.show_versions(as_json=True)
Reported by Bandit.
Line: 54
Column: 1
assert result == expected
def test_show_versions_console_json(capsys):
# GH39701
pd.show_versions(as_json=True)
stdout = capsys.readouterr().out
# check valid json is printed to the console if as_json is True
Reported by Pylint.
Line: 68
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
"dependencies": _get_dependency_info(),
}
assert result == expected
def test_show_versions_console(capsys):
# gh-32041
# gh-32041
Reported by Bandit.
Line: 71
Column: 1
assert result == expected
def test_show_versions_console(capsys):
# gh-32041
# gh-32041
pd.show_versions(as_json=False)
result = capsys.readouterr().out
Reported by Pylint.
Line: 78
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
result = capsys.readouterr().out
# check header
assert "INSTALLED VERSIONS" in result
# check full commit hash
assert re.search(r"commit\s*:\s[0-9a-f]{40}\n", result)
# check required dependency
Reported by Bandit.
Line: 81
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert "INSTALLED VERSIONS" in result
# check full commit hash
assert re.search(r"commit\s*:\s[0-9a-f]{40}\n", result)
# check required dependency
# 2020-12-09 npdev has "dirty" in the tag
assert re.search(r"numpy\s*:\s([0-9\.\+a-g\_]|dev)+(dirty)?\n", result)
Reported by Bandit.