@@ -121,22 +121,23 @@ def check(cwd='./'):
121121 Routine to check the differences between using a switch estimator or not
122122 """
123123
124- dt_list = [1e -1 , 1e -2 , 1e -3 ]
124+ dt_list = [4e -1 , 4e -2 , 4e -3 ]
125125 use_switch_estimator = [True , False ]
126126 restarts_all = []
127127 restarts_dict = dict ()
128128 for dt_item in dt_list :
129- for item in use_switch_estimator :
130- stats , description = run (dt = dt_item , use_switch_estimator = item )
129+ for use_SE in use_switch_estimator :
130+ stats , description = run (dt = dt_item , use_switch_estimator = use_SE )
131131
132- assert len (get_recomputed (stats , type = 'switch' , sortby = 'time' )) >= 1 , 'No switches found!'
132+ if use_SE :
133+ assert len (get_recomputed (stats , type = 'switch' , sortby = 'time' )) >= 1 , 'No switches found for dt={}!' .format (dt_item )
133134
134- fname = 'data/battery_2condensators_dt{}_USE{}.dat' .format (dt_item , item )
135+ fname = 'data/battery_2condensators_dt{}_USE{}.dat' .format (dt_item , use_SE )
135136 f = open (fname , 'wb' )
136137 dill .dump (stats , f )
137138 f .close ()
138139
139- if item :
140+ if use_SE :
140141 restarts_dict [dt_item ] = np .array (get_sorted (stats , type = 'restart' , recomputed = None , sortby = 'time' ))
141142 restarts = restarts_dict [dt_item ][:, 1 ]
142143 restarts_all .append (np .sum (restarts ))
@@ -203,10 +204,10 @@ def check(cwd='./'):
203204 restarts_dt = restarts_dict [dt_item ]
204205 for i in range (len (restarts_dt [:, 0 ])):
205206 if round (restarts_dt [i , 0 ], 13 ) == round (t_switch [0 ], 13 ):
206- restarts_dt_switch1 .append (np .sum (restarts_dt [0 : i , 1 ]))
207+ restarts_dt_switch1 .append (np .sum (restarts_dt [0 : i - 1 , 1 ]))
207208
208209 if round (restarts_dt [i , 0 ], 13 ) == round (t_switch [1 ], 13 ):
209- restarts_dt_switch2 .append (np .sum (restarts_dt [i - 1 :, 1 ]))
210+ restarts_dt_switch2 .append (np .sum (restarts_dt [i - 2 :, 1 ]))
210211
211212 setup_mpl ()
212213 fig1 , ax1 = plt_helper .plt .subplots (1 , 1 , figsize = (4.5 , 3 ))
0 commit comments