Skip to content

STYLE: fix pylint redefined-outer-name warnings #49822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/util/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def wrapper(*args, **kwargs) -> Callable[..., Any]:
if alternative.__doc__:
if alternative.__doc__.count("\n") < 3:
raise AssertionError(doc_error_msg)
empty1, summary, empty2, doc = alternative.__doc__.split("\n", 3)
empty1, summary, empty2, doc_string = alternative.__doc__.split("\n", 3)
if empty1 or empty2 and not summary:
raise AssertionError(doc_error_msg)
wrapper.__doc__ = dedent(
Expand All @@ -87,7 +87,7 @@ def wrapper(*args, **kwargs) -> Callable[..., Any]:
.. deprecated:: {version}
{msg}

{dedent(doc)}"""
{dedent(doc_string)}"""
)
# error: Incompatible return value type (got "Callable[[VarArg(Any), KwArg(Any)],
# Callable[...,Any]]", expected "Callable[[F], F]")
Expand Down
12 changes: 6 additions & 6 deletions pandas/util/_doctools.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,28 +168,28 @@ def _make_table(self, ax, df, title: str, height: float | None = None) -> None:


if __name__ == "__main__":
import matplotlib.pyplot as plt
import matplotlib.pyplot as pyplot
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of renaming this (as plt is a pretty standard import), how about we put:

def main():
    import matplotlib.pyplot as plt

    p = TablePlotter()
    <put the rest of the file here>

and then, right underneat that:

if __name__ == "__main__":
    main()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it.


p = TablePlotter()

df1 = pd.DataFrame({"A": [10, 11, 12], "B": [20, 21, 22], "C": [30, 31, 32]})
df2 = pd.DataFrame({"A": [10, 12], "C": [30, 32]})

p.plot([df1, df2], pd.concat([df1, df2]), labels=["df1", "df2"], vertical=True)
plt.show()
pyplot.show()

df3 = pd.DataFrame({"X": [10, 12], "Z": [30, 32]})

p.plot(
[df1, df3], pd.concat([df1, df3], axis=1), labels=["df1", "df2"], vertical=False
)
plt.show()
pyplot.show()

idx = pd.MultiIndex.from_tuples(
[(1, "A"), (1, "B"), (1, "C"), (2, "A"), (2, "B"), (2, "C")]
)
col = pd.MultiIndex.from_tuples([(1, "A"), (1, "B")])
column = pd.MultiIndex.from_tuples([(1, "A"), (1, "B")])
df3 = pd.DataFrame({"v1": [1, 2, 3, 4, 5, 6], "v2": [5, 6, 7, 8, 9, 10]}, index=idx)
df3.columns = col
df3.columns = column
p.plot(df3, df3, labels=["df3"])
plt.show()
pyplot.show()