Skip to content
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

Make option_context a ContextDecorator. #34253

Merged
merged 1 commit into from
May 25, 2020
Merged

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented May 19, 2020

This makes it possible to use option_context as a decorator over an
entire function, saving an indent level and making it easy to comment
out (or in) the context while keeping correct indentation.

  • closes #xxxx (N/A)
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Looks good - test failure should be unrelated

@WillAyd WillAyd added this to the 1.1 milestone May 19, 2020
@WillAyd
Copy link
Member

WillAyd commented May 20, 2020

Can you merge master and repush? Should get CI green

@anntzer
Copy link
Contributor Author

anntzer commented May 20, 2020

done

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

lgtm. doc-comments, ping on green.

@@ -236,6 +236,7 @@ Other enhancements
and :class:`~pandas.io.stata.StataWriterUTF8` (:issue:`26599`).
- :meth:`HDFStore.put` now accepts `track_times` parameter. Parameter is passed to ``create_table`` method of ``PyTables`` (:issue:`32682`).
- Make :class:`pandas.core.window.Rolling` and :class:`pandas.core.window.Expanding` iterable(:issue:`11704`)
- Make ``option_context`` a :class:`contextlib.ContextDecorator`, which allows it to be used as a decorator over an entire function.
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add this PR number as the issue number

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -410,6 +410,12 @@ def eq(val):
self.cf.set_option("a", 17)
eq(17)

@self.cf.option_context("a", 123)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a comment with this issue number here (and a comment on what we are testing here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

This makes it possible to use option_context as a decorator over an
entire function, saving an indent level and making it easy to comment
out (or in) the context while keeping correct indentation.
@jreback jreback merged commit 238e04f into pandas-dev:master May 25, 2020
@jreback
Copy link
Contributor

jreback commented May 25, 2020

thanks @anntzer

@anntzer anntzer deleted the occd branch May 25, 2020 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants