Skip to content

[Fix] Handle missing geometry keys in latexify for lithium plating mo…#5245

Merged
agriyakhetarpal merged 3 commits intopybamm-team:developfrom
swastim01:fix/latexify-lithium-plating-4218
Dec 23, 2025
Merged

[Fix] Handle missing geometry keys in latexify for lithium plating mo…#5245
agriyakhetarpal merged 3 commits intopybamm-team:developfrom
swastim01:fix/latexify-lithium-plating-4218

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
@swastim01
Copy link
Contributor Author

Hi, this has been open for a while, I would like to get some feedback on this, thanks.

Copy link
Member

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

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

Thanks, @swastim01! Sorry for dropping the ball on this; I just noticed it.

@agriyakhetarpal
Copy link
Member

Could you please rebase and resolve the conflicts? The failures in the tests have been fixed via #5271.

@agriyakhetarpal agriyakhetarpal merged commit 7e0d3ca into pybamm-team:develop Dec 23, 2025
34 of 36 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.

[Bug]: latexify issue while displaying lithium plating equations

3 participants