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

#2763 start improving latexify #2764

Merged
merged 15 commits into from
Mar 19, 2023
Merged

#2763 start improving latexify #2764

merged 15 commits into from
Mar 19, 2023

Conversation

valentinsulzer
Copy link
Member

Description

Start improving latexify. Goal is for the output of SPM, SPMe, and DFN to be clean.

Fixes #2763
Fixes #2762

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist:

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

You can run unit and doctests together at once, using $ python run-tests.py --quick.

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@valentinsulzer valentinsulzer marked this pull request as draft March 10, 2023 18:06
@valentinsulzer
Copy link
Member Author

valentinsulzer commented Mar 10, 2023

This code snippet would allow us to update print names semi-automatically, not sure if it's a good idea though since it uses locals()

import pybamm

var2 = pybamm.Variable("var")
test = pybamm.Variable("c_e")

loc = {k: v for k, v in locals().items() if isinstance(v, pybamm.Symbol)}

for key, value in loc.items():
    value.print_name = key

print(var2.print_name)  # prints var2
print(test.print_name)  # prints test

Combined with this it might be fully automatable

@codecov
Copy link

codecov bot commented Mar 13, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.01 ⚠️

Comparison is base (d773b8d) 99.68% compared to head (c19fbed) 99.68%.

❗ Current head c19fbed differs from pull request most recent head 9800bbd. Consider uploading reports for the commit 9800bbd to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2764      +/-   ##
===========================================
- Coverage    99.68%   99.68%   -0.01%     
===========================================
  Files          272      272              
  Lines        19031    19027       -4     
===========================================
- Hits         18972    18968       -4     
  Misses          59       59              
Impacted Files Coverage Δ
pybamm/models/submodels/thermal/lumped.py 100.00% <ø> (ø)
pybamm/expression_tree/concatenations.py 100.00% <100.00%> (ø)
pybamm/expression_tree/operations/latexify.py 100.00% <100.00%> (ø)
pybamm/expression_tree/printing/print_name.py 100.00% <100.00%> (ø)
pybamm/expression_tree/variable.py 100.00% <100.00%> (ø)
pybamm/models/base_model.py 99.30% <100.00%> (ø)
...s/full_battery_models/lithium_ion/electrode_soh.py 100.00% <100.00%> (ø)
.../submodels/active_material/base_active_material.py 100.00% <100.00%> (ø)
...lectrolyte_diffusion/base_electrolyte_diffusion.py 100.00% <100.00%> (ø)
...ybamm/models/submodels/interface/base_interface.py 100.00% <100.00%> (ø)
... and 5 more

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@valentinsulzer valentinsulzer marked this pull request as ready for review March 16, 2023 02:58
@valentinsulzer valentinsulzer changed the title #2763 [WIP] start improving latexify #2763 start improving latexify Mar 16, 2023
Copy link
Member

@priyanshuone6 priyanshuone6 left a comment

Choose a reason for hiding this comment

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

A lot of code changed. Looks good to me!

@valentinsulzer
Copy link
Member Author

I was struggling to understand the regex code so just rewrote it

@valentinsulzer valentinsulzer merged commit e59bb51 into develop Mar 19, 2023
@valentinsulzer valentinsulzer deleted the issue-2763-latexify branch March 19, 2023 21:25
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 [Bug]: Class Variable returns None when getting the print_name attribute instead of the name
2 participants