Repository navigation
"Hooks" for ShootFromSnapshotsSimulation (i.e., committor) #755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
710eccb
64639b7
c34bc67
789784b
c4803d4
83cf746
3112541
fad83f6
520abf2
4a69542
c2597bb
7b0690b
6d1e134
a2611f1
40a7694
5dcd421
1d66070
45a774e
89473af
a9df664
22461c6
be22dd1
d59b306
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
This will enable analysis, even with parallel hooks
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -130,8 +130,13 @@ def add_hook_method(hook_method, hook_name): | |||||||
|
|
||||||||
| def run_hooks(self, hook_name, **kwargs): | ||||||||
| """Run the hooks for the given ``hook_name``""" | ||||||||
| hook_name_state = {} | ||||||||
| for hook in self.hooks[hook_name]: | ||||||||
| hook(**kwargs) | ||||||||
| result = hook(**kwargs) | ||||||||
| if result is not None: | ||||||||
| hook_name_state.update({hook: result}) | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should always update,
Suggested change
|
||||||||
| if hook_name_state != {}: | ||||||||
| return hook_name_state | ||||||||
|
Comment on lines
+138
to
+139
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should always return, as each of the hook states should be stored with
Suggested change
|
||||||||
|
|
||||||||
| @abc.abstractmethod | ||||||||
| def run(self, n_steps): | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -125,6 +125,7 @@ def run(self, n_per_snapshot, as_chain=False): | |||||||||||
| self.step = 0 | ||||||||||||
| snap_num = 0 | ||||||||||||
| n_snapshots = len(self.initial_snapshots) | ||||||||||||
| hook_state = None | ||||||||||||
| self.run_hooks('before_simulation', sim=self) | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hook_states should be carried around
Suggested change
|
||||||||||||
| for snapshot in self.initial_snapshots: | ||||||||||||
| # before_snapshot | ||||||||||||
|
|
@@ -163,9 +164,11 @@ def run(self, n_per_snapshot, as_chain=False): | |||||||||||
| ) | ||||||||||||
| # shoot_snapshot_task (end) | ||||||||||||
|
|
||||||||||||
| self.run_hooks('after_step', sim=self, | ||||||||||||
| step_number=step_number, step_info=step_info, | ||||||||||||
| state=start_snap, results=mcstep) | ||||||||||||
| hook_state = self.run_hooks( | ||||||||||||
| 'after_step', sim=self, step_number=step_number, | ||||||||||||
| step_info=step_info, state=start_snap, results=mcstep, | ||||||||||||
| hook_state=hook_state | ||||||||||||
| ) | ||||||||||||
|
Comment on lines
+171
to
+172
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
|
||||||||||||
| self.step += 1 | ||||||||||||
| # after_snapshot | ||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be good to (have the option) keep a constant state here, so change this into