Skip to content

Remove .id#1978

Merged
valentinsulzer merged 13 commits intodevelopfrom
remove-id
Jun 8, 2022
Merged

Remove .id#1978
valentinsulzer merged 13 commits intodevelopfrom
remove-id

Conversation

@valentinsulzer
Copy link
Copy Markdown
Member

Description

Adds __eq__ and __hash__ methods for pybamm.Symbol (possible now we're not using anytree)
Replaces symbol.id with symbol in dictionary keys and for equality checking, where possible

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: $ flake8
  • All tests pass: $ python run-tests.py --unit
  • The documentation builds: $ cd docs and then $ make clean; make html

You can run all three 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

@valentinsulzer valentinsulzer marked this pull request as draft March 10, 2022 22:13
@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2022

Codecov Report

Merging #1978 (f1954ef) into develop (e1f52ff) will decrease coverage by 0.00%.
The diff coverage is 99.46%.

@@             Coverage Diff             @@
##           develop    #1978      +/-   ##
===========================================
- Coverage    99.38%   99.38%   -0.01%     
===========================================
  Files          348      348              
  Lines        19255    19228      -27     
===========================================
- Hits         19136    19109      -27     
  Misses         119      119              
Impacted Files Coverage Δ
pybamm/spatial_methods/spatial_method.py 96.36% <ø> (ø)
pybamm/spatial_methods/finite_volume.py 98.15% <92.30%> (ø)
pybamm/discretisations/discretisation.py 99.79% <100.00%> (ø)
pybamm/expression_tree/binary_operators.py 99.53% <100.00%> (-0.01%) ⬇️
pybamm/expression_tree/concatenations.py 98.70% <100.00%> (-0.04%) ⬇️
pybamm/expression_tree/functions.py 100.00% <100.00%> (ø)
...mm/expression_tree/operations/convert_to_casadi.py 100.00% <100.00%> (ø)
...ybamm/expression_tree/operations/evaluate_julia.py 100.00% <100.00%> (ø)
...bamm/expression_tree/operations/evaluate_python.py 98.29% <100.00%> (ø)
pybamm/expression_tree/operations/jacobian.py 100.00% <100.00%> (ø)
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1f52ff...f1954ef. Read the comment docs.

@valentinsulzer valentinsulzer marked this pull request as ready for review June 6, 2022 21:15
Copy link
Copy Markdown
Contributor

@rtimms rtimms left a comment

Choose a reason for hiding this comment

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

thanks @tinosulzer !

Copy link
Copy Markdown
Member

@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, just a couple of small comments. Thanks Valentin!

Comment thread CHANGELOG.md
for var, julia_id in variable_to_print_name.items():
# e.g. boundary_value_right(cache_123456789) gets replaced with u1(t, 1)
cache_var_id = id_to_julia_variable(var_id, "cache")
cache_var_id = id_to_julia_variable(var.id, "cache")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am a bit confused, why is the .id here now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we still need id here to generate names like cache_12345. I guess it could go into the id_to_julia_variable function

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, I get it. Looks good then!

for var, julia_id in variable_to_print_name.items():
# e.g. boundary_value_right(cache_123456789) gets replaced with u1(t, 1)
cache_var_id = id_to_julia_variable(var_id, "cache")
cache_var_id = id_to_julia_variable(var.id, "cache")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here

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.

3 participants