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 anytree #1912

Merged
merged 6 commits into from
Jan 23, 2022
Merged

Remove anytree #1912

merged 6 commits into from
Jan 23, 2022

Conversation

valentinsulzer
Copy link
Member

Description

It seems like we can get away with not using anytree when creating expression trees, which saves a fair amount of overhead. Functionality like render still works fine, as long as the symbol has a children attribute.
Symbol.new_copy no longer needs to be used, but I have left the functions there in case we need to go back.

Let's give it a couple of releases to be sure, but if things are working well without anytree we can also:

  • remove Symbol.id and implement __eq__ and __hash__ instead (previously, these were not implemented to avoid loops in anytree)
  • Simplify model.new_copy to just make shallow copies

I'll open an issue for that if this PR is approved.

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
Copy link
Member Author

🚀
Screen Shot 2022-01-21 at 2 08 05 PM

@codecov
Copy link

codecov bot commented Jan 21, 2022

Codecov Report

Merging #1912 (0b02b32) into develop (b86b0c7) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 0b02b32 differs from pull request most recent head d8c069a. Consider uploading reports for the commit d8c069a to get more accurate results
Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1912   +/-   ##
========================================
  Coverage    99.32%   99.33%           
========================================
  Files          346      346           
  Lines        19135    19105   -30     
========================================
- Hits         19006    18977   -29     
+ Misses         129      128    -1     
Impacted Files Coverage Δ
pybamm/discretisations/discretisation.py 99.78% <100.00%> (-0.01%) ⬇️
pybamm/expression_tree/averages.py 100.00% <100.00%> (ø)
pybamm/expression_tree/concatenations.py 98.31% <100.00%> (ø)
pybamm/expression_tree/input_parameter.py 100.00% <100.00%> (ø)
pybamm/expression_tree/operations/jacobian.py 100.00% <100.00%> (ø)
...bamm/expression_tree/operations/replace_symbols.py 100.00% <100.00%> (ø)
pybamm/expression_tree/symbol.py 98.74% <100.00%> (-0.26%) ⬇️
pybamm/expression_tree/unary_operators.py 100.00% <100.00%> (ø)
pybamm/parameters/parameter_values.py 99.46% <100.00%> (-0.01%) ⬇️
pybamm/solvers/base_solver.py 100.00% <100.00%> (+0.49%) ⬆️
... and 3 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 b86b0c7...d8c069a. Read the comment docs.

Copy link
Contributor

@martinjrobins martinjrobins left a comment

Choose a reason for hiding this comment

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

this looks great, glad to be rid of anytree!

@valentinsulzer valentinsulzer merged commit dc4ff98 into develop Jan 23, 2022
@valentinsulzer valentinsulzer deleted the remove-anytree branch January 23, 2022 02:10
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.

2 participants