Skip to content

Support for OO Optimization #21093

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 21 commits into from
May 30, 2018
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
11 changes: 11 additions & 0 deletions pandas/tests/test_downstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"""
Testing that we work in the downstream packages
"""
import subprocess

import pytest
import numpy as np # noqa
from pandas import DataFrame
Expand Down Expand Up @@ -53,6 +55,15 @@ def test_xarray(df):
assert df.to_xarray() is not None


def test_xarray_oo_optimizable():
Copy link
Member

Choose a reason for hiding this comment

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

you can remove the "xarray" here, as it is generally useful to ensure this, not only for xarray

# GH 21071
ret = subprocess.run(["python", "-OO", "-c", "import pandas"])
result = ret.returncode
expected = 0

assert result == expected


@tm.network
def test_statsmodels():

Expand Down
7 changes: 5 additions & 2 deletions pandas/tseries/offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1090,12 +1090,15 @@ def apply(self, other):


class CustomBusinessMonthEnd(_CustomBusinessMonth):
__doc__ = _CustomBusinessMonth.__doc__.replace('[BEGIN/END]', 'end')
if _CustomBusinessMonth.__doc__:
__doc__ = _CustomBusinessMonth.__doc__.replace('[BEGIN/END]', 'end')
_prefix = 'CBM'


class CustomBusinessMonthBegin(_CustomBusinessMonth):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think better to do this with @subsitution and template this. We dont' use this pattern anywhere and might be confusing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense - I'll take a look and repush

__doc__ = _CustomBusinessMonth.__doc__.replace('[BEGIN/END]', 'beginning')
if _CustomBusinessMonth.__doc__:
__doc__ = _CustomBusinessMonth.__doc__.replace('[BEGIN/END]',
'beginning')
_prefix = 'CBMS'


Expand Down
9 changes: 5 additions & 4 deletions pandas/util/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ def wrapper(*args, **kwargs):
{rest}
""")
rest = getattr(wrapper, '__doc__', '')
docstring = tpl.format(version=version,
msg='\n '.join(wrap(msg, 70)),
rest=dedent(rest))
wrapper.__doc__ = docstring
if rest:
docstring = tpl.format(version=version,
msg='\n '.join(wrap(msg, 70)),
rest=dedent(rest))
wrapper.__doc__ = docstring

return wrapper

Expand Down