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

Mutable tree #45

Merged
merged 13 commits into from
May 7, 2021
Merged

Mutable tree #45

merged 13 commits into from
May 7, 2021

Conversation

ANeaves
Copy link
Contributor

@ANeaves ANeaves commented Apr 19, 2021

Created a Mutable Flag for Parameter Tree. Setting this flag allows the creation and deletion of nodes in the parameter tree. This includes branch nodes and leaf nodes. Care should be taken when using a Mutable Parameter Tree to avoid overwriting Accessors and other nodes accidentally.

This change also removed the (long depreciated) Callback system from Parameter Tree

@ANeaves ANeaves self-assigned this Apr 19, 2021
@codecov
Copy link

codecov bot commented Apr 19, 2021

Codecov Report

Merging #45 (f7a15fc) into master (3dc6e5b) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #45   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           14        14           
  Lines         1087      1106   +19     
=========================================
+ Hits          1087      1106   +19     
Impacted Files Coverage Δ
src/odin/adapters/parameter_tree.py 100.00% <100.00%> (ø)

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 3dc6e5b...f7a15fc. Read the comment docs.

Copy link
Collaborator

@timcnicholls timcnicholls 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! Some minor comments above about docstrings, commenting and removing commented-out code from test cases 👍

src/odin/adapters/parameter_tree.py Show resolved Hide resolved
src/odin/adapters/parameter_tree.py Show resolved Hide resolved
src/odin/adapters/parameter_tree.py Outdated Show resolved Hide resolved
tests/adapters/test_parameter_tree.py Outdated Show resolved Hide resolved
tests/adapters/test_parameter_tree.py Outdated Show resolved Hide resolved
@ANeaves ANeaves marked this pull request as draft April 23, 2021 15:04
if isinstance(subtree, dict):
subtree = subtree[level]
else:
subtree = subtree[int(level)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you just explain this part a little to me? You traverse down the tree and assume if the subtree isn't a dict then the next path level is always going to be an integer, is my understanding right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pretty much, yeah. This was based off the traversal stuff in the set method, which does the same thing. The idea being that, if you're still traversing the path you set, you're either:
at a branch node of the tree, thus the next part should be another dict
at a node that contains a list, thus the next part of the path should be the list index
Then, obviously, if its neither of these things, you're path is invalid and it raises the ParameterTreeError

Copy link
Contributor

Choose a reason for hiding this comment

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

I think some comments dotted throughout the code explaining these details at each step would be useful

@ANeaves ANeaves marked this pull request as ready for review April 29, 2021 08:51
@ANeaves ANeaves merged commit 366085b into master May 7, 2021
@timcnicholls timcnicholls deleted the mutable-tree branch March 9, 2022 15:52
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.

4 participants