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

[FIX] rich display in jupyter notebook/lab #4183

Merged
merged 2 commits into from Jan 4, 2024

Conversation

jeromedockes
Copy link
Member

I'm not 100% sure why but at least on some jupyter versions defining _repr_html_ is not enough; defining _repr_mimebundle_ instead (or as well) fixes the issue.

main branch:

screenshot_2024-01-03T11:35:24+01:00

this PR:

Screenshot 2024-01-03 at 11-34-30 Untitled

❯ jupyter --version
Selected Jupyter core packages...
IPython          : 8.19.0
ipykernel        : 6.28.0
ipywidgets       : 8.1.1
jupyter_client   : 8.6.0
jupyter_core     : 5.6.1
jupyter_server   : 2.12.1
jupyterlab       : 4.0.10
nbclient         : 0.8.0
nbconvert        : 7.14.0
nbformat         : 5.9.2
notebook         : 7.0.6
qtconsole        : 5.5.1
traitlets        : 5.14.0

Copy link
Contributor

github-actions bot commented Jan 3, 2024

👋 @jeromedockes Thanks for creating a PR!

Until this PR is ready for review, you can include the [WIP] tag in its title, or leave it as a github draft.

Please make sure it is compliant with our contributing guidelines. In particular, be sure it checks the boxes listed below.

  • PR has an interpretable title.
  • PR links to Github issue with mention Closes #XXXX (see our documentation on PR structure)
  • Code is PEP8-compliant (see our documentation on coding style)
  • Changelog or what's new entry in doc/changes/latest.rst (see our documentation on PR structure)

For new features:

  • There is at least one unit test per new function / class (see our documentation on testing)
  • The new feature is demoed in at least one relevant example.

For bug fixes:

  • There is at least one test that would fail under the original bug conditions.

We will review it as quick as possible, feel free to ping us with questions if needed.

Copy link

codecov bot commented Jan 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (14ff3ae) 92.02% compared to head (149bf8a) 92.02%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4183   +/-   ##
=======================================
  Coverage   92.02%   92.02%           
=======================================
  Files         144      144           
  Lines       16373    16376    +3     
  Branches     3427     3427           
=======================================
+ Hits        15067    15070    +3     
  Misses        766      766           
  Partials      540      540           
Flag Coverage Δ
macos-latest_3.10_test_plotting 91.80% <100.00%> (+<0.01%) ⬆️
macos-latest_3.11_test_plotting 91.80% <100.00%> (+<0.01%) ⬆️
macos-latest_3.12_test_plotting 91.80% <100.00%> (+<0.01%) ⬆️
macos-latest_3.8_test_plotting 91.76% <100.00%> (+<0.01%) ⬆️
macos-latest_3.9_test_plotting 91.77% <100.00%> (+<0.01%) ⬆️
ubuntu-latest_3.10_test_plotting 91.80% <100.00%> (+<0.01%) ⬆️
ubuntu-latest_3.11_test_plotting 91.80% <100.00%> (+<0.01%) ⬆️
ubuntu-latest_3.12_test_plotting 91.80% <100.00%> (+<0.01%) ⬆️
ubuntu-latest_3.12_test_pre 91.80% <100.00%> (+<0.01%) ⬆️
ubuntu-latest_3.8_test_min 68.98% <0.00%> (-0.02%) ⬇️
ubuntu-latest_3.8_test_plot_min 91.52% <100.00%> (+<0.01%) ⬆️
ubuntu-latest_3.8_test_plotting 91.76% <100.00%> (+<0.01%) ⬆️
ubuntu-latest_3.9_test_plotting 91.77% <100.00%> (+<0.01%) ⬆️
windows-latest_3.10_test_plotting 91.78% <100.00%> (+<0.01%) ⬆️
windows-latest_3.11_test_plotting 91.78% <100.00%> (+<0.01%) ⬆️
windows-latest_3.12_test_plotting 91.78% <100.00%> (+<0.01%) ⬆️
windows-latest_3.8_test_plotting 91.74% <100.00%> (+<0.01%) ⬆️
windows-latest_3.9_test_plotting 91.74% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ymzayek
Copy link
Member

ymzayek commented Jan 3, 2024

Should we then remove _repr_html_ or do you think it may be needed for some jupyter versions?

@jeromedockes
Copy link
Member Author

according to the documentation _repr_html_ is ignored when _repr_mimebundle_ is defined and does not return None so both keeping it and removing it should behave the same. OTOH according to the documentation _repr_html_ by itself should work (and apparently in some cases it doesn't), so maybe it's safer to keep both. WDYT?

@ymzayek
Copy link
Member

ymzayek commented Jan 3, 2024

Ok let's keep both for now. Can you link the docs here?

@jeromedockes
Copy link
Member Author

sorry I thought I had done so: https://ipython.readthedocs.io/en/stable/config/integrating.html#MyObject._repr_mimebundle_

@jeromedockes
Copy link
Member Author

I'll link them in the docstrings as well

Copy link
Member

@ymzayek ymzayek left a comment

Choose a reason for hiding this comment

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

Good with me!

Copy link
Member

@bthirion bthirion left a comment

Choose a reason for hiding this comment

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

LGTM, thx !

@ymzayek ymzayek merged commit cfc4c03 into nilearn:main Jan 4, 2024
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants