Coverage for pySDC/projects/soft_failure/FaultHooks.py: 100%
20 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 14:51 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 14:51 +0000
1from __future__ import division
3import numpy as np
5from pySDC.core.hooks import Hooks
8class fault_hook(Hooks):
9 def __init__(self):
10 """
11 Initialization of fault hooks
12 """
13 super(fault_hook, self).__init__()
15 self.fault_iteration = None
17 def pre_run(self, step, level_number):
18 super(fault_hook, self).pre_run(step, level_number)
20 L = step.levels[level_number]
22 L.sweep.reset_fault_stats()
24 self.fault_iteration = np.random.randint(1, L.sweep.params.niters)
26 def pre_iteration(self, step, level_number):
27 super(fault_hook, self).pre_iteration(step, level_number)
29 L = step.levels[level_number]
31 L.sweep.fault_iteration = self.fault_iteration == step.status.iter
33 def post_run(self, step, level_number):
34 super(fault_hook, self).post_run(step, level_number)
36 L = step.levels[level_number]
38 self.add_to_stats(
39 process=step.status.slot,
40 time=L.time,
41 level=L.level_index,
42 iter=step.status.iter,
43 sweep=L.status.sweep,
44 type='fault_stats',
45 value=L.sweep.fault_stats,
46 )