-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
26 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import zntrack | ||
|
||
|
||
class NodeWithPostLoad(zntrack.Node): | ||
params: float = zntrack.params() | ||
outs: float = zntrack.outs() | ||
|
||
def _post_load_(self): | ||
self.params += 1 | ||
|
||
def run(self): | ||
self.outs = self.params | ||
|
||
|
||
def test_post_load(proj_path): | ||
project = zntrack.Project() | ||
with project: | ||
node = NodeWithPostLoad(params=1) | ||
|
||
assert node.params == 1 | ||
project.repro() | ||
|
||
n = node.from_rev() | ||
assert n.params == 2 # modified by _post_load_ | ||
assert n.outs == 1 |
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