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

Converts notebook plots to pure Plotly #411

Conversation

BradyPlanden
Copy link
Member

@BradyPlanden BradyPlanden commented Jul 16, 2024

Description

This PR removes the svg based plotting methods for jupyter notebooks, changing to standard to the plotly.show() method. As this remove the rendered figures in GitHub, I've added a README.md to the examples directory which points users to the nbviewer rendered notebooks, which is the recommend method for plotly.

As a result of the above, this PR removes kaleido as a dependency.

Issue reference

Fixes #410

Review

Before you mark your PR as ready for review, please ensure that you've considered the following:

  • Updated the CHANGELOG.md in reverse chronological order (newest at the top) with a concise description of the changes, including the PR number.
  • Noted any breaking changes, including details on how it might impact existing functionality.

Type of change

  • New Feature: A non-breaking change that adds new functionality.
  • Optimization: A code change that improves performance.
  • Examples: A change to existing or additional examples.
  • Bug Fix: A non-breaking change that addresses an issue.
  • Documentation: Updates to documentation or new documentation for new features.
  • Refactoring: Non-functional changes that improve the codebase.
  • Style: Non-functional changes related to code style (formatting, naming, etc).
  • Testing: Additional tests to improve coverage or confirm functionality.
  • Other: (Insert description of change)

Key checklist:

  • No style issues: $ pre-commit run (or $ nox -s pre-commit) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)
  • All unit tests pass: $ nox -s tests
  • The documentation builds: $ nox -s doctest

You can run integration tests, unit tests, and doctests together at once, using $ nox -s quick.

Further checks:

  • Code is well-commented, especially in complex or unclear areas.
  • Added tests that prove my fix is effective or that my feature works.
  • Checked that coverage remains or improves, and added tests if necessary to maintain or increase coverage.

Thank you for contributing to our project! Your efforts help us to deliver great software.

@BradyPlanden BradyPlanden linked an issue Jul 16, 2024 that may be closed by this pull request
Copy link

codecov bot commented Jul 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.01%. Comparing base (7a140bb) to head (6b83edc).
Report is 24 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #411      +/-   ##
===========================================
+ Coverage    98.82%   99.01%   +0.18%     
===========================================
  Files           52       52              
  Lines         3582     3555      -27     
===========================================
- Hits          3540     3520      -20     
+ Misses          42       35       -7     

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

Copy link
Contributor

@brosaplanella brosaplanella left a comment

Choose a reason for hiding this comment

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

Hi Brady! I am not sure I follow what this PR changes (mostly because I am not too familiar with plotly). It seems the main change is to use a log scale in the plots, but there are still some issues with the exponents (see https://github.com/pybop-team/PyBOP/blob/7bae73c60da37932851f8373cc567f8f35e8a078/examples/notebooks/multi_model_identification.ipynb)

…rendering-formu-in-notebooks

# Conflicts:
#	examples/notebooks/LG_M50_ECM/1-single-pulse-circuit-model.ipynb
#	examples/notebooks/comparing_cost_functions.ipynb
#	examples/notebooks/equivalent_circuit_identification.ipynb
#	examples/notebooks/multi_model_identification.ipynb
#	examples/notebooks/multi_optimiser_identification.ipynb
#	examples/notebooks/optimiser_calibration.ipynb
#	examples/notebooks/optimiser_interface.ipynb
#	examples/notebooks/pouch_cell_identification.ipynb
#	examples/notebooks/spm_AdamW.ipynb
#	examples/notebooks/spm_electrode_design.ipynb
@BradyPlanden BradyPlanden force-pushed the 410-bug-incorrect-axis-symbol-rendering-formu-in-notebooks branch from c81af4b to 431a862 Compare August 2, 2024 19:41
@BradyPlanden BradyPlanden changed the title Partial fix for #410 Fixes #410 Aug 5, 2024
@BradyPlanden
Copy link
Member Author

I've now refactored this PR quite a bit, after hitting a few blockers with Kaleido and the GitHub notebook renderer, I've changed direction and reverted notebook plotting to the standard plotly.show() implementation. This reduces the maintenance quite a bit and is much more robust. The only drawback is that the notebook figures won't be rendered on Github. To solve this, a README has been added directing users to the nbviewer implementation.

Copy link
Member

@NicolaCourtier NicolaCourtier left a comment

Choose a reason for hiding this comment

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

Hi @BradyPlanden, when I try to view the figures on nbviewer (e.g. 1-single-pulse-circuit-model), it only shows me one figure and the rest are black rectangles. I am using Firefox on Windows, same on Chrome. Will this issue be fixed by merging?

…rendering-formu-in-notebooks

# Conflicts:
#	examples/notebooks/multi_model_identification.ipynb
#	examples/notebooks/spm_electrode_design.ipynb
@BradyPlanden
Copy link
Member Author

Copy link
Contributor

@brosaplanella brosaplanella 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 to me, thanks!

@BradyPlanden BradyPlanden changed the title Fixes #410 Converts notebook plots to pure Plotly Sep 6, 2024
@BradyPlanden BradyPlanden merged commit 59c8c79 into develop Sep 6, 2024
30 of 31 checks passed
@BradyPlanden BradyPlanden deleted the 410-bug-incorrect-axis-symbol-rendering-formu-in-notebooks branch September 6, 2024 17:11
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.

[Bug]: Incorrect axis symbol rendering for\mu in notebooks
3 participants