From 5118a6e9f84547a63884e331ed874e36baee7371 Mon Sep 17 00:00:00 2001 From: Stella Lin Date: Fri, 28 Oct 2022 11:20:04 -0500 Subject: [PATCH 01/11] remove from exclusions + cleanup --- asv_bench/benchmarks/attrs_caching.py | 2 +- pandas/io/formats/style.py | 4 ++-- pandas/plotting/_core.py | 2 +- pandas/tests/apply/test_frame_apply.py | 10 ++++---- pandas/tests/base/test_constructors.py | 18 +++++++------- pandas/tests/dtypes/test_inference.py | 6 ++--- pandas/tests/frame/test_subclass.py | 4 ++-- .../tests/groupby/aggregate/test_aggregate.py | 14 +++++------ pandas/tests/groupby/test_groupby.py | 4 ++-- pandas/tests/indexes/multi/test_integrity.py | 8 +++---- pandas/tests/io/formats/style/test_style.py | 6 ++--- pandas/tests/io/test_sql.py | 24 +++++++++---------- pandas/tests/resample/test_period_index.py | 8 ++++--- pandas/tests/reshape/concat/test_empty.py | 6 ++--- pandas/tests/reshape/concat/test_series.py | 14 ++++++----- pandas/tests/reshape/test_pivot.py | 4 ++-- .../test_deprecate_nonkeyword_arguments.py | 12 ++++++---- pandas/tests/window/test_apply.py | 6 ++--- pandas/tests/window/test_groupby.py | 4 ++-- pyproject.toml | 1 - scripts/tests/test_validate_docstrings.py | 2 +- 21 files changed, 82 insertions(+), 77 deletions(-) diff --git a/asv_bench/benchmarks/attrs_caching.py b/asv_bench/benchmarks/attrs_caching.py index d4366c42f96aa..ce9485d7dd492 100644 --- a/asv_bench/benchmarks/attrs_caching.py +++ b/asv_bench/benchmarks/attrs_caching.py @@ -15,7 +15,7 @@ def setup(self): self.cur_index = self.df.index def time_get_index(self): - self.foo = self.df.index + self.foo_index = self.df.index def time_set_index(self): self.df.index = self.cur_index diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index f3c58ac2ad18d..93b6cb3373dce 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -3209,7 +3209,7 @@ def set_properties(self, subset: Subset | None = None, **kwargs) -> Styler: return self.applymap(lambda x: values, subset=subset) @Substitution(subset=subset) - def bar( + def barchart( self, subset: Subset | None = None, axis: Axis | None = 0, @@ -4216,7 +4216,7 @@ def css_calc(x, left: float, right: float, align: str, color: str | list | tuple rgbas = None if cmap is not None: # use the matplotlib colormap input - with _mpl(Styler.bar) as (plt, mpl): + with _mpl(Styler.barchart) as (plt, mpl): from pandas.plotting._matplotlib.compat import mpl_ge_3_6_0 cmap = ( diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 036d2c84f006e..74ba672bf79c2 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -1131,7 +1131,7 @@ def line(self, x=None, y=None, **kwargs) -> PlotAccessor: ) @Substitution(kind="bar") @Appender(_bar_or_line_doc) - def bar(self, x=None, y=None, **kwargs) -> PlotAccessor: + def barplot(self, x=None, y=None, **kwargs) -> PlotAccessor: """ Vertical bar plot. diff --git a/pandas/tests/apply/test_frame_apply.py b/pandas/tests/apply/test_frame_apply.py index c6294cfc0c670..4728ac1fd2e29 100644 --- a/pandas/tests/apply/test_frame_apply.py +++ b/pandas/tests/apply/test_frame_apply.py @@ -1509,10 +1509,10 @@ def test_aggregation_func_column_order(): columns=("item", "att1", "att2", "att3"), ) - def foo(s): + def sum_div2(s): return s.sum() / 2 - aggs = ["sum", foo, "count", "min"] + aggs = ["sum", sum_div2, "count", "min"] with tm.assert_produces_warning( FutureWarning, match=r"\['item'\] did not aggregate successfully" ): @@ -1524,7 +1524,7 @@ def foo(s): "att2": [18.0, 9.0, 6.0, 0.0], "att3": [17.0, 8.5, 6.0, 0.0], }, - index=["sum", "foo", "count", "min"], + index=["sum", "sum_div2", "count", "min"], ) tm.assert_frame_equal(result, expected) @@ -1545,13 +1545,13 @@ def test_nuisance_depr_passes_through_warnings(): # sure if some other warnings were raised, they get passed through to # the user. - def foo(x): + def expected_warning(x): warnings.warn("Hello, World!") return x.sum() df = DataFrame({"a": [1, 2, 3]}) with tm.assert_produces_warning(UserWarning, match="Hello, World!"): - df.agg([foo]) + df.agg([expected_warning]) def test_apply_type(): diff --git a/pandas/tests/base/test_constructors.py b/pandas/tests/base/test_constructors.py index c8b923031b9e8..c4a0c61673e6d 100644 --- a/pandas/tests/base/test_constructors.py +++ b/pandas/tests/base/test_constructors.py @@ -46,15 +46,15 @@ class Delegator: _properties = ["foo"] _methods = ["bar"] - def _set_foo(self, value): - self.foo = value + def _set_value(self, value): + self.value = value - def _get_foo(self): - return self.foo + def _get_value(self): + return self.value - foo = property(_get_foo, _set_foo, doc="foo property") + value = property(_get_value, _set_value, doc="foo property") - def bar(self, *args, **kwargs): + def test_method(self, *args, **kwargs): """a test bar method""" pass @@ -80,15 +80,15 @@ def test_invalid_delegation(self): msg = "You cannot access the property foo" with pytest.raises(TypeError, match=msg): - delegate.foo + delegate.inaccesible msg = "The property foo cannot be set" with pytest.raises(TypeError, match=msg): - delegate.foo = 5 + delegate.inaccesible = 5 msg = "You cannot access the property foo" with pytest.raises(TypeError, match=msg): - delegate.foo() + delegate.inaccesible() @pytest.mark.skipif(PYPY, reason="not relevant for PyPy") def test_memory_usage(self): diff --git a/pandas/tests/dtypes/test_inference.py b/pandas/tests/dtypes/test_inference.py index e1d16fed73a88..835b0d761ca3e 100644 --- a/pandas/tests/dtypes/test_inference.py +++ b/pandas/tests/dtypes/test_inference.py @@ -203,16 +203,16 @@ def test_is_list_like_disallow_sets(maybe_list_like): def test_is_list_like_recursion(): # GH 33721 # interpreter would crash with SIGABRT - def foo(): + def list_like(): inference.is_list_like([]) - foo() + list_like() rec_limit = sys.getrecursionlimit() try: # Limit to avoid stack overflow on Windows CI sys.setrecursionlimit(100) with tm.external_error_raised(RecursionError): - foo() + list_like() finally: sys.setrecursionlimit(rec_limit) diff --git a/pandas/tests/frame/test_subclass.py b/pandas/tests/frame/test_subclass.py index d5331b1060b23..b385091c9ff51 100644 --- a/pandas/tests/frame/test_subclass.py +++ b/pandas/tests/frame/test_subclass.py @@ -138,11 +138,11 @@ def test_subclass_attr_err_propagation(self): # GH 11808 class A(DataFrame): @property - def bar(self): + def nonexistence(self): return self.i_dont_exist with pytest.raises(AttributeError, match=".*i_dont_exist.*"): - A().bar + A().nonexistence def test_subclass_align(self): # GH 12983 diff --git a/pandas/tests/groupby/aggregate/test_aggregate.py b/pandas/tests/groupby/aggregate/test_aggregate.py index ad7368a69c0f5..dd2789f5edf58 100644 --- a/pandas/tests/groupby/aggregate/test_aggregate.py +++ b/pandas/tests/groupby/aggregate/test_aggregate.py @@ -283,15 +283,15 @@ def test_aggregate_item_by_item(df): aggfun_0 = lambda ser: ser.size result = grouped.agg(aggfun_0) - foo = (df.A == "foo").sum() - bar = (df.A == "bar").sum() + foosum = (df.A == "foo").sum() + barsum = (df.A == "bar").sum() K = len(result.columns) # GH5782 - exp = Series(np.array([foo] * K), index=list("BCD"), name="foo") + exp = Series(np.array([foosum] * K), index=list("BCD"), name="foo") tm.assert_series_equal(result.xs("foo"), exp) - exp = Series(np.array([bar] * K), index=list("BCD"), name="bar") + exp = Series(np.array([barsum] * K), index=list("BCD"), name="bar") tm.assert_almost_equal(result.xs("bar"), exp) def aggfun_1(ser): @@ -420,10 +420,10 @@ def test_more_flexible_frame_multi_function(df): expected = grouped.aggregate({"C": np.mean, "D": [np.mean, np.std]}) tm.assert_frame_equal(result, expected) - def foo(x): + def numpymean(x): return np.mean(x) - def bar(x): + def numpystd(x): return np.std(x, ddof=1) # this uses column selection & renaming @@ -433,7 +433,7 @@ def bar(x): grouped.aggregate(d) # But without renaming, these functions are OK - d = {"C": [np.mean], "D": [foo, bar]} + d = {"C": [np.mean], "D": [numpymean, numpystd]} grouped.aggregate(d) diff --git a/pandas/tests/groupby/test_groupby.py b/pandas/tests/groupby/test_groupby.py index 26f269d3d4384..7cfe07851a71b 100644 --- a/pandas/tests/groupby/test_groupby.py +++ b/pandas/tests/groupby/test_groupby.py @@ -1579,7 +1579,7 @@ def freduce(group): assert group.name is not None return group.sum() - def foo(x): + def freducex(x): return freduce(x) grouped = df.groupby(grouper, group_keys=False) @@ -1592,7 +1592,7 @@ def foo(x): grouped["C"].apply(f) grouped["C"].aggregate(freduce) - grouped["C"].aggregate([freduce, foo]) + grouped["C"].aggregate([freduce, freducex]) grouped["C"].transform(f) diff --git a/pandas/tests/indexes/multi/test_integrity.py b/pandas/tests/indexes/multi/test_integrity.py index ef72f1f3ffde8..e2d59e5511a52 100644 --- a/pandas/tests/indexes/multi/test_integrity.py +++ b/pandas/tests/indexes/multi/test_integrity.py @@ -233,14 +233,14 @@ def test_level_setting_resets_attributes(): def test_rangeindex_fallback_coercion_bug(): # GH 12893 - foo = pd.DataFrame(np.arange(100).reshape((10, 10))) - bar = pd.DataFrame(np.arange(100).reshape((10, 10))) - df = pd.concat({"foo": foo.stack(), "bar": bar.stack()}, axis=1) + df1 = pd.DataFrame(np.arange(100).reshape((10, 10))) + df2 = pd.DataFrame(np.arange(100).reshape((10, 10))) + df = pd.concat({"df1": df1.stack(), "df2": df2.stack()}, axis=1) df.index.names = ["fizz", "buzz"] str(df) expected = pd.DataFrame( - {"bar": np.arange(100), "foo": np.arange(100)}, + {"df2": np.arange(100), "df1": np.arange(100)}, index=MultiIndex.from_product([range(10), range(10)], names=["fizz", "buzz"]), ) tm.assert_frame_equal(df, expected, check_like=True) diff --git a/pandas/tests/io/formats/style/test_style.py b/pandas/tests/io/formats/style/test_style.py index 77a996b1f92d6..0a79f17cf1035 100644 --- a/pandas/tests/io/formats/style/test_style.py +++ b/pandas/tests/io/formats/style/test_style.py @@ -657,10 +657,10 @@ def test_apply_dataframe_return(self, index, columns): ) @pytest.mark.parametrize("axis", [0, 1]) def test_apply_subset(self, slice_, axis, df): - def h(x, foo="bar"): - return Series(f"color: {foo}", index=x.index, name=x.name) + def h(x, color="bar"): + return Series(f"color: {color}", index=x.index, name=x.name) - result = df.style.apply(h, axis=axis, subset=slice_, foo="baz")._compute().ctx + result = df.style.apply(h, axis=axis, subset=slice_, color="baz")._compute().ctx expected = { (r, c): [("color", "baz")] for r, row in enumerate(df.index) diff --git a/pandas/tests/io/test_sql.py b/pandas/tests/io/test_sql.py index 9adada8afb2c2..51f7354d2dd4b 100644 --- a/pandas/tests/io/test_sql.py +++ b/pandas/tests/io/test_sql.py @@ -2181,26 +2181,26 @@ def test_connectable_issue_example(self): # https://github.com/pandas-dev/pandas/issues/10104 from sqlalchemy.engine import Engine - def foo(connection): + def test_select(connection): query = "SELECT test_foo_data FROM test_foo_data" return sql.read_sql_query(query, con=connection) - def bar(connection, data): + def test_append(connection, data): data.to_sql(name="test_foo_data", con=connection, if_exists="append") - def baz(conn): + def test_connectable(conn): # https://github.com/sqlalchemy/sqlalchemy/commit/ # 00b5c10846e800304caa86549ab9da373b42fa5d#r48323973 - foo_data = foo(conn) - bar(conn, foo_data) + foo_data = test_select(conn) + test_append(conn, foo_data) def main(connectable): if isinstance(connectable, Engine): with connectable.connect() as conn: with conn.begin(): - baz(conn) + test_connectable(conn) else: - baz(connectable) + test_connectable(connectable) assert ( DataFrame({"test_foo_data": [0, 1, 2]}).to_sql("test_foo_data", self.conn) @@ -2373,21 +2373,21 @@ def test_row_object_is_named_tuple(self): class Test(BaseModel): __tablename__ = "test_frame" id = Column(Integer, primary_key=True) - foo = Column(String(50)) + string_column = Column(String(50)) BaseModel.metadata.create_all(self.conn) Session = sessionmaker(bind=self.conn) with Session() as session: - df = DataFrame({"id": [0, 1], "foo": ["hello", "world"]}) + df = DataFrame({"id": [0, 1], "string_column": ["hello", "world"]}) assert ( df.to_sql("test_frame", con=self.conn, index=False, if_exists="replace") == 2 ) session.commit() - foo = session.query(Test.id, Test.foo) - df = DataFrame(foo) + test_query = session.query(Test.id, Test.string_column) + df = DataFrame(test_query) - assert list(df.columns) == ["id", "foo"] + assert list(df.columns) == ["id", "string_column"] class _TestMySQLAlchemy: diff --git a/pandas/tests/resample/test_period_index.py b/pandas/tests/resample/test_period_index.py index 4da1f4c589c56..39c45fc14a3c1 100644 --- a/pandas/tests/resample/test_period_index.py +++ b/pandas/tests/resample/test_period_index.py @@ -605,9 +605,11 @@ def test_resample_with_dst_time_change(self): def test_resample_bms_2752(self): # GH2753 - foo = Series(index=pd.bdate_range("20000101", "20000201"), dtype=np.float64) - res1 = foo.resample("BMS").mean() - res2 = foo.resample("BMS").mean().resample("B").mean() + timeseries = Series( + index=pd.bdate_range("20000101", "20000201"), dtype=np.float64 + ) + res1 = timeseries.resample("BMS").mean() + res2 = timeseries.resample("BMS").mean().resample("B").mean() assert res1.index[0] == Timestamp("20000103") assert res1.index[0] == res2.index[0] diff --git a/pandas/tests/reshape/concat/test_empty.py b/pandas/tests/reshape/concat/test_empty.py index 541a34bde8143..18c0645df1ceb 100644 --- a/pandas/tests/reshape/concat/test_empty.py +++ b/pandas/tests/reshape/concat/test_empty.py @@ -16,11 +16,11 @@ class TestEmptyConcat: def test_handle_empty_objects(self, sort): df = DataFrame(np.random.randn(10, 4), columns=list("abcd")) - baz = df[:5].copy() - baz["foo"] = "bar" + dfcopy = df[:5].copy() + dfcopy["foo"] = "bar" empty = df[5:5] - frames = [baz, empty, empty, df[5:]] + frames = [dfcopy, empty, empty, df[5:]] concatted = concat(frames, axis=0, sort=sort) expected = df.reindex(columns=["a", "b", "c", "d", "foo"]) diff --git a/pandas/tests/reshape/concat/test_series.py b/pandas/tests/reshape/concat/test_series.py index 8fa5988720c6b..cf59ec211ee4b 100644 --- a/pandas/tests/reshape/concat/test_series.py +++ b/pandas/tests/reshape/concat/test_series.py @@ -120,24 +120,26 @@ def test_concat_series_name_npscalar_tuple(self, s1name, s2name): def test_concat_series_partial_columns_names(self): # GH10698 - foo = Series([1, 2], name="foo") - bar = Series([1, 2]) - baz = Series([4, 5]) + foo_series = Series([1, 2], name="foo") + bar_series = Series([1, 2]) + baz_series = Series([4, 5]) - result = concat([foo, bar, baz], axis=1) + result = concat([foo_series, bar_series, baz_series], axis=1) expected = DataFrame( {"foo": [1, 2], 0: [1, 2], 1: [4, 5]}, columns=["foo", 0, 1] ) tm.assert_frame_equal(result, expected) - result = concat([foo, bar, baz], axis=1, keys=["red", "blue", "yellow"]) + result = concat( + [foo_series, bar_series, baz_series], axis=1, keys=["red", "blue", "yellow"] + ) expected = DataFrame( {"red": [1, 2], "blue": [1, 2], "yellow": [4, 5]}, columns=["red", "blue", "yellow"], ) tm.assert_frame_equal(result, expected) - result = concat([foo, bar, baz], axis=1, ignore_index=True) + result = concat([foo_series, bar_series, baz_series], axis=1, ignore_index=True) expected = DataFrame({0: [1, 2], 1: [1, 2], 2: [4, 5]}) tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/reshape/test_pivot.py b/pandas/tests/reshape/test_pivot.py index b021b1aa97a0e..4418fe483d83b 100644 --- a/pandas/tests/reshape/test_pivot.py +++ b/pandas/tests/reshape/test_pivot.py @@ -2106,9 +2106,9 @@ def test_pivot_table_no_column_raises(self): def agg(arr): return np.mean(arr) - foo = DataFrame({"X": [0, 0, 1, 1], "Y": [0, 1, 0, 1], "Z": [10, 20, 30, 40]}) + df = DataFrame({"X": [0, 0, 1, 1], "Y": [0, 1, 0, 1], "Z": [10, 20, 30, 40]}) with pytest.raises(KeyError, match="notpresent"): - foo.pivot_table("notpresent", "X", "Y", aggfunc=agg) + df.pivot_table("notpresent", "X", "Y", aggfunc=agg) def test_pivot_table_multiindex_columns_doctest_case(self): # The relevant characteristic is that the call diff --git a/pandas/tests/util/test_deprecate_nonkeyword_arguments.py b/pandas/tests/util/test_deprecate_nonkeyword_arguments.py index f6501fa8315e4..685f009d5ec73 100644 --- a/pandas/tests/util/test_deprecate_nonkeyword_arguments.py +++ b/pandas/tests/util/test_deprecate_nonkeyword_arguments.py @@ -140,18 +140,20 @@ def test_i_signature(): class Foo: @deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "bar"]) - def baz(self, bar=None, foobar=None): + def args(self, non_keyword=None, foobar=None): ... def test_foo_signature(): - assert str(inspect.signature(Foo.baz)) == "(self, bar=None, *, foobar=None)" + assert ( + str(inspect.signature(Foo.args)) == "(self, non_keyword=None, *, foobar=None)" + ) def test_class(): msg = ( - r"In a future version of pandas all arguments of Foo\.baz " - r"except for the argument \'bar\' will be keyword-only" + r"In a future version of pandas all arguments of Foo\.args " + r"except for the argument \'non_keyword\' will be keyword-only" ) with tm.assert_produces_warning(FutureWarning, match=msg): - Foo().baz("qux", "quox") + Foo().args("qux", "quox") diff --git a/pandas/tests/window/test_apply.py b/pandas/tests/window/test_apply.py index 12f9cb27e8cbe..9260542e7a67a 100644 --- a/pandas/tests/window/test_apply.py +++ b/pandas/tests/window/test_apply.py @@ -163,7 +163,7 @@ def test_invalid_raw_numba(): @pytest.mark.parametrize("args_kwargs", [[None, {"par": 10}], [(10,), None]]) def test_rolling_apply_args_kwargs(args_kwargs): # GH 33433 - def foo(x, par): + def numpysum(x, par): return np.sum(x + par) df = DataFrame({"gr": [1, 1], "a": [1, 2]}) @@ -171,7 +171,7 @@ def foo(x, par): idx = Index(["gr", "a"]) expected = DataFrame([[11.0, 11.0], [11.0, 12.0]], columns=idx) - result = df.rolling(1).apply(foo, args=args_kwargs[0], kwargs=args_kwargs[1]) + result = df.rolling(1).apply(numpysum, args=args_kwargs[0], kwargs=args_kwargs[1]) tm.assert_frame_equal(result, expected) midx = MultiIndex.from_tuples([(1, 0), (1, 1)], names=["gr", None]) @@ -179,7 +179,7 @@ def foo(x, par): gb_rolling = df.groupby("gr")["a"].rolling(1) - result = gb_rolling.apply(foo, args=args_kwargs[0], kwargs=args_kwargs[1]) + result = gb_rolling.apply(numpysum, args=args_kwargs[0], kwargs=args_kwargs[1]) tm.assert_series_equal(result, expected) diff --git a/pandas/tests/window/test_groupby.py b/pandas/tests/window/test_groupby.py index 688a93223b3f4..3da14bce6facd 100644 --- a/pandas/tests/window/test_groupby.py +++ b/pandas/tests/window/test_groupby.py @@ -277,11 +277,11 @@ def test_rolling_apply_mutability(self): def test_groupby_rolling(self, expected_value, raw_value): # GH 31754 - def foo(x): + def isnumpyarray(x): return int(isinstance(x, np.ndarray)) df = DataFrame({"id": [1, 1, 1], "value": [1, 2, 3]}) - result = df.groupby("id").value.rolling(1).apply(foo, raw=raw_value) + result = df.groupby("id").value.rolling(1).apply(isnumpyarray, raw=raw_value) expected = Series( [expected_value] * 3, index=MultiIndex.from_tuples(((1, 0), (1, 1), (1, 2)), names=["id", None]), diff --git a/pyproject.toml b/pyproject.toml index 63c2719b3b0fd..ccdb9d14d8298 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,6 @@ disable = [ # pylint type "C": convention, for programming standard violation "consider-using-f-string", - "disallowed-name", "import-outside-toplevel", "invalid-name", "line-too-long", diff --git a/scripts/tests/test_validate_docstrings.py b/scripts/tests/test_validate_docstrings.py index dcfef648e8f1c..58658abd4decb 100644 --- a/scripts/tests/test_validate_docstrings.py +++ b/scripts/tests/test_validate_docstrings.py @@ -25,7 +25,7 @@ def prefix_pandas(self): """ pass - def redundant_import(self, foo=None, bar=None): + def redundant_import(self, paramx=None, paramy=None): """ A sample DataFrame method. From b6251e72b7b16483070f626ece4c1ad366a005f8 Mon Sep 17 00:00:00 2001 From: Stella Lin Date: Fri, 28 Oct 2022 18:20:35 -0500 Subject: [PATCH 02/11] try foo variation, instead --- pandas/tests/base/test_constructors.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/tests/base/test_constructors.py b/pandas/tests/base/test_constructors.py index c4a0c61673e6d..659d0d97b6e11 100644 --- a/pandas/tests/base/test_constructors.py +++ b/pandas/tests/base/test_constructors.py @@ -80,15 +80,15 @@ def test_invalid_delegation(self): msg = "You cannot access the property foo" with pytest.raises(TypeError, match=msg): - delegate.inaccesible + delegate.foox msg = "The property foo cannot be set" with pytest.raises(TypeError, match=msg): - delegate.inaccesible = 5 + delegate.foox = 5 msg = "You cannot access the property foo" with pytest.raises(TypeError, match=msg): - delegate.inaccesible() + delegate.foox() @pytest.mark.skipif(PYPY, reason="not relevant for PyPy") def test_memory_usage(self): From 9c676c462ad460e21175834ab9fbf405456a6b33 Mon Sep 17 00:00:00 2001 From: Stella Lin Date: Fri, 28 Oct 2022 18:48:39 -0500 Subject: [PATCH 03/11] revert change + exclude from linting --- pandas/io/formats/style.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 93b6cb3373dce..3ecd0ceacf341 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -3209,7 +3209,7 @@ def set_properties(self, subset: Subset | None = None, **kwargs) -> Styler: return self.applymap(lambda x: values, subset=subset) @Substitution(subset=subset) - def barchart( + def bar( # pylint: disable=disallowed-name self, subset: Subset | None = None, axis: Axis | None = 0, From bacd290d23f05b3d1a12cd24b8c98edc714bb72f Mon Sep 17 00:00:00 2001 From: Stella Lin Date: Fri, 28 Oct 2022 19:51:21 -0500 Subject: [PATCH 04/11] revert + exclude from linting --- pandas/io/formats/style.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 3ecd0ceacf341..f0a7095da61e9 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -4216,7 +4216,7 @@ def css_calc(x, left: float, right: float, align: str, color: str | list | tuple rgbas = None if cmap is not None: # use the matplotlib colormap input - with _mpl(Styler.barchart) as (plt, mpl): + with _mpl(Styler.bar) as (plt, mpl): from pandas.plotting._matplotlib.compat import mpl_ge_3_6_0 cmap = ( From 51c5cb31bb64390158d143a65d0218af9e849925 Mon Sep 17 00:00:00 2001 From: Stella Lin Date: Fri, 28 Oct 2022 21:09:12 -0500 Subject: [PATCH 05/11] revert + exclude fron linting --- pandas/plotting/_core.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 74ba672bf79c2..35d743a64dd7b 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -1131,7 +1131,9 @@ def line(self, x=None, y=None, **kwargs) -> PlotAccessor: ) @Substitution(kind="bar") @Appender(_bar_or_line_doc) - def barplot(self, x=None, y=None, **kwargs) -> PlotAccessor: + def bar( # pylint: disable=disallowed-name + self, x=None, y=None, **kwargs + ) -> PlotAccessor: """ Vertical bar plot. From 965ee5e14800c891f65214796436372db3b2ee10 Mon Sep 17 00:00:00 2001 From: Stella Lin Date: Fri, 28 Oct 2022 21:13:37 -0500 Subject: [PATCH 06/11] more descriptive names --- pandas/tests/reshape/concat/test_series.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pandas/tests/reshape/concat/test_series.py b/pandas/tests/reshape/concat/test_series.py index cf59ec211ee4b..886ada409a91a 100644 --- a/pandas/tests/reshape/concat/test_series.py +++ b/pandas/tests/reshape/concat/test_series.py @@ -120,18 +120,20 @@ def test_concat_series_name_npscalar_tuple(self, s1name, s2name): def test_concat_series_partial_columns_names(self): # GH10698 - foo_series = Series([1, 2], name="foo") - bar_series = Series([1, 2]) - baz_series = Series([4, 5]) + named_series = Series([1, 2], name="foo") + unnamed_series1 = Series([1, 2]) + unnamed_series2 = Series([4, 5]) - result = concat([foo_series, bar_series, baz_series], axis=1) + result = concat([named_series, unnamed_series1, unnamed_series2], axis=1) expected = DataFrame( {"foo": [1, 2], 0: [1, 2], 1: [4, 5]}, columns=["foo", 0, 1] ) tm.assert_frame_equal(result, expected) result = concat( - [foo_series, bar_series, baz_series], axis=1, keys=["red", "blue", "yellow"] + [named_series, unnamed_series1, unnamed_series2], + axis=1, + keys=["red", "blue", "yellow"], ) expected = DataFrame( {"red": [1, 2], "blue": [1, 2], "yellow": [4, 5]}, @@ -139,7 +141,9 @@ def test_concat_series_partial_columns_names(self): ) tm.assert_frame_equal(result, expected) - result = concat([foo_series, bar_series, baz_series], axis=1, ignore_index=True) + result = concat( + [named_series, unnamed_series1, unnamed_series2], axis=1, ignore_index=True + ) expected = DataFrame({0: [1, 2], 1: [1, 2], 2: [4, 5]}) tm.assert_frame_equal(result, expected) From 52a5dccf8528a8e02d6bd7039fb38aed6d14fa2b Mon Sep 17 00:00:00 2001 From: Stella Lin Date: Fri, 28 Oct 2022 21:56:37 -0500 Subject: [PATCH 07/11] try assigning to itself --- asv_bench/benchmarks/attrs_caching.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asv_bench/benchmarks/attrs_caching.py b/asv_bench/benchmarks/attrs_caching.py index ce9485d7dd492..e5e63ba5f714b 100644 --- a/asv_bench/benchmarks/attrs_caching.py +++ b/asv_bench/benchmarks/attrs_caching.py @@ -15,7 +15,7 @@ def setup(self): self.cur_index = self.df.index def time_get_index(self): - self.foo_index = self.df.index + self.df.index = self.df.index def time_set_index(self): self.df.index = self.cur_index From 92b67321e009b763100b3280c6d53387729ddce8 Mon Sep 17 00:00:00 2001 From: Stella Lin Date: Mon, 31 Oct 2022 08:39:17 -0500 Subject: [PATCH 08/11] more test clean-up --- pandas/tests/base/test_constructors.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pandas/tests/base/test_constructors.py b/pandas/tests/base/test_constructors.py index 659d0d97b6e11..1cd9e3d24ab07 100644 --- a/pandas/tests/base/test_constructors.py +++ b/pandas/tests/base/test_constructors.py @@ -43,16 +43,16 @@ def constructor(request): class TestPandasDelegate: class Delegator: - _properties = ["foo"] + _properties = ["prop"] _methods = ["bar"] - def _set_value(self, value): - self.value = value + def _set_prop(self, value): + self.prop = value - def _get_value(self): - return self.value + def _get_prop(self): + return self.prop - value = property(_get_value, _set_value, doc="foo property") + value = property(_get_prop, _set_prop, doc="foo property") def test_method(self, *args, **kwargs): """a test bar method""" @@ -80,15 +80,15 @@ def test_invalid_delegation(self): msg = "You cannot access the property foo" with pytest.raises(TypeError, match=msg): - delegate.foox + delegate.prop msg = "The property foo cannot be set" with pytest.raises(TypeError, match=msg): - delegate.foox = 5 + delegate.prop = 5 msg = "You cannot access the property foo" with pytest.raises(TypeError, match=msg): - delegate.foox() + delegate.prop() @pytest.mark.skipif(PYPY, reason="not relevant for PyPy") def test_memory_usage(self): From 7a1ee91777b2fdf5328d485c5a8f3a645c7bc359 Mon Sep 17 00:00:00 2001 From: Stella Lin Date: Mon, 31 Oct 2022 09:25:22 -0500 Subject: [PATCH 09/11] try reverting with exclusion --- .../util/test_deprecate_nonkeyword_arguments.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pandas/tests/util/test_deprecate_nonkeyword_arguments.py b/pandas/tests/util/test_deprecate_nonkeyword_arguments.py index 685f009d5ec73..2ea3dae19a3e4 100644 --- a/pandas/tests/util/test_deprecate_nonkeyword_arguments.py +++ b/pandas/tests/util/test_deprecate_nonkeyword_arguments.py @@ -140,20 +140,18 @@ def test_i_signature(): class Foo: @deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "bar"]) - def args(self, non_keyword=None, foobar=None): + def baz(self, bar=None, foobar=None): # pylint: disable=disallowed-name ... def test_foo_signature(): - assert ( - str(inspect.signature(Foo.args)) == "(self, non_keyword=None, *, foobar=None)" - ) + assert str(inspect.signature(Foo.baz)) == "(self, bar=None, *, foobar=None)" def test_class(): msg = ( - r"In a future version of pandas all arguments of Foo\.args " - r"except for the argument \'non_keyword\' will be keyword-only" + r"In a future version of pandas all arguments of Foo\.baz " + r"except for the argument \'bar\' will be keyword-only" ) with tm.assert_produces_warning(FutureWarning, match=msg): - Foo().args("qux", "quox") + Foo().baz("qux", "quox") From 331c3cb2696081a264289a921ac2134450d8a55f Mon Sep 17 00:00:00 2001 From: Stella Lin Date: Mon, 31 Oct 2022 10:26:59 -0500 Subject: [PATCH 10/11] more clean-up --- asv_bench/benchmarks/attrs_caching.py | 2 +- pandas/tests/base/test_constructors.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/asv_bench/benchmarks/attrs_caching.py b/asv_bench/benchmarks/attrs_caching.py index e5e63ba5f714b..d515743ea4431 100644 --- a/asv_bench/benchmarks/attrs_caching.py +++ b/asv_bench/benchmarks/attrs_caching.py @@ -15,7 +15,7 @@ def setup(self): self.cur_index = self.df.index def time_get_index(self): - self.df.index = self.df.index + self.df.index def time_set_index(self): self.df.index = self.cur_index diff --git a/pandas/tests/base/test_constructors.py b/pandas/tests/base/test_constructors.py index 1cd9e3d24ab07..08aec5bfbd10e 100644 --- a/pandas/tests/base/test_constructors.py +++ b/pandas/tests/base/test_constructors.py @@ -44,7 +44,7 @@ def constructor(request): class TestPandasDelegate: class Delegator: _properties = ["prop"] - _methods = ["bar"] + _methods = ["test_method"] def _set_prop(self, value): self.prop = value @@ -52,7 +52,7 @@ def _set_prop(self, value): def _get_prop(self): return self.prop - value = property(_get_prop, _set_prop, doc="foo property") + prop = property(_get_prop, _set_prop, doc="foo property") def test_method(self, *args, **kwargs): """a test bar method""" @@ -78,15 +78,15 @@ def test_invalid_delegation(self): delegate = self.Delegate(self.Delegator()) - msg = "You cannot access the property foo" + msg = "You cannot access the property prop" with pytest.raises(TypeError, match=msg): delegate.prop - msg = "The property foo cannot be set" + msg = "The property prop cannot be set" with pytest.raises(TypeError, match=msg): delegate.prop = 5 - msg = "You cannot access the property foo" + msg = "You cannot access the property prop" with pytest.raises(TypeError, match=msg): delegate.prop() From b959f2ebb6c28f4225aabbbe70112c5dfd50b7f2 Mon Sep 17 00:00:00 2001 From: Stella Lin Date: Wed, 2 Nov 2022 08:09:38 -0500 Subject: [PATCH 11/11] revert --- pandas/tests/base/test_constructors.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/tests/base/test_constructors.py b/pandas/tests/base/test_constructors.py index 08aec5bfbd10e..9576bf57c8503 100644 --- a/pandas/tests/base/test_constructors.py +++ b/pandas/tests/base/test_constructors.py @@ -55,8 +55,7 @@ def _get_prop(self): prop = property(_get_prop, _set_prop, doc="foo property") def test_method(self, *args, **kwargs): - """a test bar method""" - pass + """a test method""" class Delegate(PandasDelegate, PandasObject): def __init__(self, obj) -> None: