Skip to content

Conversation

@swastim01
Copy link
Contributor

@swastim01 swastim01 commented Oct 28, 2025

[Fix] Handle missing geometry keys in latexify for lithium plating models (#4218)

Description

This PR fixes a KeyError: 'min' that occurred when using latexify() on models with lithium plating (e.g., SPM with options={"lithium plating": "irreversible"}).
The issue was caused by missing geometry keys (min/max) during LaTeX equation generation.
This change adds safe handling for those missing keys, allowing correct LaTeX output without errors.

Fixes

Fixes #4218

Type of change

  • Bug fix (non-breaking change)

Changes Made

  • Added checks for "min" and "max" keys in latexify.py
  • Added unit test test_latexify_with_lithium_plating to verify the fix

Changelog

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

- Fixes `KeyError: 'min'` in `latexify()` for lithium plating models when certain geometry keys are missing. ([#5245](https://github.com/pybamm-team/PyBaMM/pull/5245))

Testing

  • Manual test:
    import pybamm
    model = pybamm.lithium_ion.SPM(options={"lithium plating": "irreversible"})
    model.latexify()
    
  • All unit tests passed.
  • Code style checks passed.

Checklist

  • No style issues
  • All tests pass
  • Documentation builds
  • Code is commented where needed
  • Test added to confirm the fix works
image

@swastim01 swastim01 requested a review from a team as a code owner October 28, 2025 08:20
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]: latexify issue while displaying lithium plating equations

2 participants