Skip to content

Resampler: IPython 5.0 triggers wrong FutureWarning #13618

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

Closed
jorisvandenbossche opened this issue Jul 11, 2016 · 7 comments
Closed

Resampler: IPython 5.0 triggers wrong FutureWarning #13618

jorisvandenbossche opened this issue Jul 11, 2016 · 7 comments
Labels
Output-Formatting __repr__ of pandas objects, to_string Resample resample method
Milestone

Comments

@jorisvandenbossche
Copy link
Member

With the latest IPython:

In [1]: rng = pd.date_range('20130101', periods=10, freq='T')
   ...: ts = pd.Series(np.arange(len(rng)), index=rng)

In [3]: r = ts.resample('2T')

In [4]: r
Out[4]: c:\users\vdbosscj\scipy\ipython-joris\IPython\utils\dir2.py:65: FutureWa
rning: .resample() is now a deferred operation
use .resample(...).mean() instead of .resample(...)
  canary = getattr(obj, '_ipython_canary_method_should_not_exist_', None)
DatetimeIndexResampler [freq=<2 * Minutes>, axis=0, closed=left, label=left, con
vention=start, base=0]

In [5]: import IPython

In [6]: IPython.__version__
Out[6]: '5.0.0'

In [7]: pd.__version__
Out[7]: '0.18.1+184.g15c2a3a'

while using IPython 4.2:

In [1]: rng = pd.date_range('20130101', periods=10, freq='T')

In [2]: ts = pd.Series(np.arange(len(rng)), index=rng)

In [3]: r = ts.resample('2T')

In [4]: r
Out[4]: DatetimeIndexResampler [freq=<2 * Minutes>, axis=0, closed=left, label=l
eft, convention=start, base=0]

In [5]: import IPython

In [6]: IPython.__version__
Out[6]: '4.2.0'

In [7]: pd.__version__
Out[7]: '0.18.1+184.g15c2a3a'
@jorisvandenbossche
Copy link
Member Author

@takluyver This seems to be related to ipython/ipython#9289 (previously, it was first checked if method is a callable, and only then it was checked if it could retrieve a non-existing attribute, while now the callable check is moved to the end of get_real_method).
The problem is that the deprecation warning is only triggered once you "do" something with it, and now it is triggered by displaying its repr

@jorisvandenbossche jorisvandenbossche added Output-Formatting __repr__ of pandas objects, to_string Resample resample method labels Jul 11, 2016
@takluyver
Copy link
Contributor

That's unfortunate. But if our check for the canary attribute triggers this, won't our checks for _repr_pretty_, _repr_json_, etc. also trigger it?

@jorisvandenbossche
Copy link
Member Author

jorisvandenbossche commented Jul 13, 2016

Apparently not. Where are those checks in the IPython code?

It does trigger the warning if I manually do getattr(r, '_repr_json_'), but this does check does not then not seem to occur when displaying an object.

@takluyver
Copy link
Contributor

IPython.core.formatters - they're somewhat hidden in infrastructure, but if you search for print_method in that module, it should be possible to work out what's going on.

@jorisvandenbossche
Copy link
Member Author

Ah, I was in a terminal, so I suppose there only the plain text displayer will be used?
If I try it in a notebook, but using IPython 4.2, the same issue already shows up

@takluyver
Copy link
Contributor

I thought the same machinery would check for _repr_pretty_ even in the terminal, but maybe it's done a bit differently.

@chris-b1 chris-b1 mentioned this issue Jul 16, 2016
4 tasks
@jreback jreback added this to the 0.19.0 milestone Jul 18, 2016
@jorisvandenbossche
Copy link
Member Author

@takluyver We solved it at our side! (at least, @chris-b1 did :-) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string Resample resample method
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants