You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As reported in the discourse forum, using a VariableView of a subgroup in linked_var will lead to a ReferenceError. The following example reproduces the issue:
The problem is that group1[3:8].v creates a VariableView object which only holds a weak reference to its group, and group1[3:8] therefore disappears. In linked_var, we are trying to access the group attribute which leads to the error.
I think in general the approach to only store a weak reference is the right one, because VariableView objects were previously a major source of memory problems. We can get away with this normally even if its group argument disappears because we hold strong references to the Variable object (which has the full data of v) and the Indexing object (which allows us to deduce that we need values 3–8 of v). This should be fixable by moving a bit around the logic of index interpretation between linked_var and LinkedVariable, but I'll have to have a closer look.
I'll mark this as low priority, though, because there are a number of workarounds. All the following variants will work:
# named subgroupsubgroup=group1[3:8]
group2.v=linked_var(subgroup.v)
# avoid VariableView by separating group and variable namegroup2.v=linked_var(group1[3:8], 'v')
# link to full group and use absolute indicesgroup2.v=linked_var(group1, 'v', index=np.arange(3, 8))
The text was updated successfully, but these errors were encountered:
Hello @mstimberg ,
I am Rohith Varma (@rohithvarma3000) and I would like to help to solve this issue. Could you guide me on how to help you solve this issue?
As reported in the discourse forum, using a
VariableView
of a subgroup inlinked_var
will lead to aReferenceError
. The following example reproduces the issue:The problem is that
group1[3:8].v
creates aVariableView
object which only holds a weak reference to itsgroup
, andgroup1[3:8]
therefore disappears. Inlinked_var
, we are trying to access thegroup
attribute which leads to the error.I think in general the approach to only store a weak reference is the right one, because
VariableView
objects were previously a major source of memory problems. We can get away with this normally even if its group argument disappears because we hold strong references to theVariable
object (which has the full data ofv
) and theIndexing
object (which allows us to deduce that we need values 3–8 ofv
). This should be fixable by moving a bit around the logic of index interpretation betweenlinked_var
andLinkedVariable
, but I'll have to have a closer look.I'll mark this as low priority, though, because there are a number of workarounds. All the following variants will work:
The text was updated successfully, but these errors were encountered: