Skip to content

Commit b51f5e8

Browse files
committed
rename VariableRef to VariableView
1 parent c6ee3e8 commit b51f5e8

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

brainpy/dyn/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ def __init__(
12891289
for _ in range(v.batch_axis - len(self.index) + 1)])))
12901290
else:
12911291
index = self.index
1292-
self.slice_vars[k] = bm.VariableRef(v, index)
1292+
self.slice_vars[k] = bm.VariableView(v, index)
12931293

12941294
# sub-nodes
12951295
nodes = target.nodes(method='relative', level=1, include_self=False).subset(DynamicalSystem)

brainpy/math/jaxarray.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
'Variable',
1717
'TrainVar',
1818
'Parameter',
19-
'VariableRef',
19+
'VariableView',
2020
]
2121

2222
# Ways to change values in a zero-dimensional array
@@ -1494,14 +1494,20 @@ def __init__(self, value, dtype=None, batch_axis: int = None):
14941494
lambda aux_data, flat_contents: Parameter(*flat_contents))
14951495

14961496

1497-
class VariableRef(Variable):
1498-
"""A reference of Variable instance."""
1497+
class VariableView(Variable):
1498+
"""A view of a Variable instance.
1499+
1500+
This class is used to create a slice view of ``brainpy.math.Variable``.
1501+
1502+
``VariableView`` can be used to update the subset of the original
1503+
Variable instance, and make operations on this subset of the Variable.
1504+
"""
14991505
def __init__(self, value: Variable, index):
15001506
self.index = index
15011507
if not isinstance(value, Variable):
15021508
raise ValueError('Must be instance of Variable.')
15031509
temp_shape = tuple([1] * len(index))
1504-
super(VariableRef, self).__init__(jnp.zeros(temp_shape), batch_axis=value.batch_axis)
1510+
super(VariableView, self).__init__(jnp.zeros(temp_shape), batch_axis=value.batch_axis)
15051511
self._value = value
15061512

15071513
@property

0 commit comments

Comments
 (0)