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

Remove .id #1978

Merged
merged 13 commits into from
Jun 8, 2022
Merged

Remove .id #1978

merged 13 commits into from
Jun 8, 2022

Conversation

valentinsulzer
Copy link
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

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
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
Sponsor 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!

CHANGELOG.md Show resolved Hide resolved
# 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
Sponsor 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
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
Sponsor 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!

# 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
Sponsor 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