Closed merangelik closed 5 years ago
This behaviour is expected. Components are included in per_hts() by reference.
After talking to @merangelik I realized that this issue was actually related to user experience. Users might find it confusing if references are used in such a manner. I suppose the bug label should be replaced by something else to clarify this.
My suggestion is therefore to refactor per_hts()
such that it behaves more predictable for package users with less experience in reference semantics.
per_hts()
, per_x13()
and per_tramo()
objects.as.persephone()
as.data.table()
per_hts()
constructor and leave as.persephone()
as is.Call copy in per_hts seems to be the most straight forward solution that fixes the user experience issue.
It turned out that te default deep copy logic in R6 recursively copies all R6 fields. Therefore, the fix just required to create deep copies in as.persephone()
.
However, for deeply nested hierarchies, a lot of copies are created which could slow down the creation of per_hts
objects. Therefore, we could introduce a new parameter "copy_components"in the constructor function, which allow users to switch to the old behavior.
Example: