dbbs-lab / bsb-core

The Brain Scaffold Builder
https://bsb.readthedocs.io
GNU General Public License v3.0
21 stars 16 forks source link

Add copy and deepcopy function to node class. #800

Closed drodarie closed 8 months ago

drodarie commented 8 months ago

Add copy and __deep_copy__ functions to Node class.

Remaining corrections to apply:

codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (27ab0a9) 84.03% compared to head (478b393) 84.07%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #800 +/- ## ========================================== + Coverage 84.03% 84.07% +0.03% ========================================== Files 104 104 Lines 12869 12894 +25 ========================================== + Hits 10815 10840 +25 Misses 2054 2054 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Helveg commented 8 months ago

Oh @drodarie another thing this kind of overlooks is that the a configuration tree is not a pure tree, there's all kinds of dependencies between the nodes, and after a tree gets bootstrapped with a scaffold there is a bunch of hidden state;

in short: a copied node might not function properly until you place it back into a configuration tree and bootstrap it.

You also ought to make sure that the nodes you copy are bijective between their component form and tree form, sometimes there's small differences

drodarie commented 8 months ago

Ok so if I understand you correctly, the __copy__ function should ask the user for the configuration tree (root) in which to "place" the copied node if the node to copy is not at the root of the config? So I should check for the _is_root property and the _config_dynamic_root? I understand what you mean by checking the bijective state of the tree but I am not sure of how to do it.

Helveg commented 8 months ago

Ok so if I understand you correctly, the __copy__ function should ask the user for the configuration tree (root) in which to "place" the copied node if the node to copy is not at the root of the config? So I should check for the _is_root property and the _config_dynamic_root? I understand what you mean by checking the bijective state of the tree but I am not sure of how to do it.

Ah, those were just 'caveat emptors', the person using copy should understand the limitations. The copied nodes do not belong to a configuration tree, so if the copied nodes depend on being "booted" before being used, or on nodes that haven't been copied along, then they won't work anymore.

We can't do anything to overcome these limitations.