-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dyn] add
brainpy.reset_state()
and brainpy.clear_input()
for mor…
…e consistent and flexible state managements
- Loading branch information
1 parent
1c0e38d
commit d3d4aec
Showing
9 changed files
with
94 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from .dynsys import DynamicalSystem, DynView | ||
from brainpy._src.dyn.base import IonChaDyn | ||
|
||
__all__ = [ | ||
'reset_state', | ||
'clear_input', | ||
] | ||
|
||
|
||
def reset_state(target: DynamicalSystem, *args, **kwargs): | ||
"""Reset states of all children nodes in the given target. | ||
See https://brainpy.readthedocs.io/en/latest/tutorial_toolbox/state_resetting.html for details. | ||
Args: | ||
target: The target DynamicalSystem. | ||
*args: | ||
**kwargs: | ||
""" | ||
for node in target.nodes().subset(DynamicalSystem).not_subset(DynView).not_subset(IonChaDyn).unique().values(): | ||
node.reset_state(*args, **kwargs) | ||
|
||
|
||
def clear_input(target: DynamicalSystem, *args, **kwargs): | ||
"""Clear all inputs in the given target. | ||
Args: | ||
target:The target DynamicalSystem. | ||
""" | ||
for node in target.nodes().subset(DynamicalSystem).not_subset(DynView).unique().values(): | ||
node.clear_input(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters