Skip to content

BUG: Restore return value in notebook reprs #16171

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 3 commits into from
May 1, 2017

Conversation

TomAugspurger
Copy link
Contributor

Monkey patches the ipython_display method onto NDFrame, so that
notebook cells have a real return value. Setting the
display.html.table_schema will monkey patch the method on,
and remove it when unset.

closes ipython/ipython#10491

Monkey patches the _ipython_display_ method onto NDFrame, so that
notebook cells have a real return value. Setting the
display.html.table_schema will monkey patch the method on,
and remove it when unset.

closes ipython/ipython#10491
@TomAugspurger TomAugspurger added IO Data IO issues that don't fit into a more specific label Regression Functionality that used to work in a prior pandas version labels Apr 29, 2017
@TomAugspurger TomAugspurger added this to the 0.20.0 milestone Apr 29, 2017
@@ -307,6 +307,48 @@ def mpl_style_cb(key):
return val


def table_schema_cb(key):
# Having _ipython_display_ defined messes with the return value
# from cells, so the Out[x] dicitonary breaks.
Copy link
Contributor

Choose a reason for hiding this comment

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

don't write the full method here
instead inside the cb import a method a call it

Copy link
Contributor

Choose a reason for hiding this comment

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

actually i would create this dynamically
simply define 2 methods and have the cb just set one of them

we do in set_use_numexpr just like this

Copy link
Contributor

Choose a reason for hiding this comment

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

would not create dynamically (typo)

@codecov
Copy link

codecov bot commented Apr 29, 2017

Codecov Report

Merging #16171 into master will increase coverage by 0.02%.
The diff coverage is 85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16171      +/-   ##
==========================================
+ Coverage   90.86%   90.88%   +0.02%     
==========================================
  Files         162      162              
  Lines       50819    50826       +7     
==========================================
+ Hits        46177    46195      +18     
+ Misses       4642     4631      -11
Flag Coverage Δ
#multiple 88.67% <85%> (+0.02%) ⬆️
#single 40.32% <15%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/generic.py 91.67% <ø> (+0.03%) ⬆️
pandas/core/config_init.py 93.86% <85%> (-0.43%) ⬇️
pandas/core/common.py 90.68% <0%> (-0.35%) ⬇️
pandas/plotting/_converter.py 65.35% <0%> (+1.81%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a7a0574...c70de54. Read the comment docs.

@codecov
Copy link

codecov bot commented Apr 29, 2017

Codecov Report

Merging #16171 into master will increase coverage by 0.02%.
The diff coverage is 90.9%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16171      +/-   ##
==========================================
+ Coverage   90.86%   90.88%   +0.02%     
==========================================
  Files         162      162              
  Lines       50819    50827       +8     
==========================================
+ Hits        46177    46195      +18     
+ Misses       4642     4632      -10
Flag Coverage Δ
#multiple 88.66% <90.9%> (+0.02%) ⬆️
#single 40.33% <13.63%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/config_init.py 94.52% <100%> (+0.23%) ⬆️
pandas/core/generic.py 91.63% <87.5%> (ø) ⬆️
pandas/core/common.py 90.68% <0%> (-0.35%) ⬇️
pandas/compat/__init__.py 62.22% <0%> (-0.11%) ⬇️
pandas/plotting/_converter.py 65.35% <0%> (+1.81%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a7a0574...fd24e27. Read the comment docs.

return None

# Series doesn't define _repr_html_ or _repr_latex_
latex = self._repr_latex_() if hasattr(self, '_repr_latex_') else None
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should define his for Series (trivial version) to avoid this kind of logic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TomAugspurger TomAugspurger mentioned this pull request May 1, 2017
@TomAugspurger
Copy link
Contributor Author

@jreback look ok to you?

@jreback
Copy link
Contributor

jreback commented May 1, 2017

yep

@TomAugspurger TomAugspurger merged commit d647045 into pandas-dev:master May 1, 2017
cbertinato pushed a commit to cbertinato/pandas that referenced this pull request May 1, 2017
* BUG: Restore return value in notebook reprs

Monkey patches the _ipython_display_ method onto NDFrame, so that
notebook cells have a real return value. Setting the
display.html.table_schema will monkey patch the method on,
and remove it when unset.

closes ipython/ipython#10491

* Define in generic.py

* PEP8
@TomAugspurger TomAugspurger deleted the ipython-repr branch May 3, 2017 22:10
pcluo pushed a commit to pcluo/pandas that referenced this pull request May 22, 2017
* BUG: Restore return value in notebook reprs

Monkey patches the _ipython_display_ method onto NDFrame, so that
notebook cells have a real return value. Setting the
display.html.table_schema will monkey patch the method on,
and remove it when unset.

closes ipython/ipython#10491

* Define in generic.py

* PEP8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO Data IO issues that don't fit into a more specific label Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Output on objects defining _ipython_display_
2 participants