Skip to content

Refactor casadi conversion#5436

Merged
MarcBerliner merged 14 commits intomainfrom
simplified-casadi-conversion
Apr 8, 2026
Merged

Refactor casadi conversion#5436
MarcBerliner merged 14 commits intomainfrom
simplified-casadi-conversion

Conversation

@MarcBerliner
Copy link
Copy Markdown
Member

Description

Refactors the casadi conversion functionality to live in the Symbol subclasses, removing the monolithic CasadiConverter

Also improves the build/eval time for the pchip interpolator:

Pchip build time (µs/call)

N Before After Speedup
10 3.6 ms 311 µs 12x
100 33.5 ms 347 µs 97x
500 159.3 ms 439 µs 362x
1000 316.8 ms 566 µs 560x

Pchip evaluation time (batch=100, uniform grid, µs/eval)

N Before After Speedup
10 54.9 11.2 5x
100 433.5 10.6 41x
500 2139.4 11.7 183x
1000 4400.7 12.4 355x

Fixes # (issue)

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #)

Important checks:

Please confirm the following before marking the PR as ready for review:

  • No style issues: nox -s pre-commit
  • All tests pass: nox -s tests
  • The documentation builds: nox -s doctests
  • Code is commented for hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 97.58713% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.36%. Comparing base (2de8f10) to head (68434cc).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/pybamm/expression_tree/functions.py 90.47% 4 Missing ⚠️
src/pybamm/expression_tree/interpolant.py 97.05% 3 Missing ⚠️
src/pybamm/expression_tree/concatenations.py 89.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5436      +/-   ##
==========================================
+ Coverage   98.34%   98.36%   +0.01%     
==========================================
  Files         333      333              
  Lines       30480    30484       +4     
==========================================
+ Hits        29976    29985       +9     
+ Misses        504      499       -5     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MarcBerliner MarcBerliner marked this pull request as ready for review April 7, 2026 18:16
@MarcBerliner MarcBerliner requested a review from a team as a code owner April 7, 2026 18:16
Copy link
Copy Markdown
Member

@BradyPlanden BradyPlanden left a comment

Choose a reason for hiding this comment

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

This is looking good, thanks!

Comment thread src/pybamm/expression_tree/functions.py Outdated
Comment thread src/pybamm/expression_tree/symbol.py Outdated
@MarcBerliner MarcBerliner merged commit ce70e21 into main Apr 8, 2026
44 of 46 checks passed
@MarcBerliner MarcBerliner deleted the simplified-casadi-conversion branch April 8, 2026 15:56
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.

2 participants