Check observed collection clocks before labeling fields
This commit is contained in:
@@ -153,6 +153,11 @@ def check_structure(y, v, previous_y):
|
||||
raise RuntimeError('nonfinite structure, travel > D or speed > .025; no retuning')
|
||||
|
||||
|
||||
def check_clock(stepper, release_clock, completed):
|
||||
if stepper.step_count != release_clock+completed:
|
||||
raise RuntimeError('observed solver clock differs from recorded response clock')
|
||||
|
||||
|
||||
def clean_field(fields, flags):
|
||||
"""Canonical modern bit-0 fluid mask; hard-fail before nonfluid zero fill."""
|
||||
ux, uy = np.asarray(fields['ux']), np.asarray(fields['uy'])
|
||||
@@ -365,6 +370,7 @@ def run_role(scene, role, plan, cfgpath, base, helpers, metrics, seed, initial_f
|
||||
force = float(cme.sum(dtype=np.float64)+wen.sum(dtype=np.float64))
|
||||
sensor_sum += sensors
|
||||
force_sum += packed
|
||||
check_clock(sim.stepper, plan['release_clock'], completed)
|
||||
sensors, packed = sensor_sum/plan['si'], force_sum/plan['si']
|
||||
raw = np.r_[sensors*156., packed*2.].astype(np.float32)
|
||||
if norm is not None:
|
||||
|
||||
@@ -182,6 +182,11 @@ class CollectionContracts(unittest.TestCase):
|
||||
|
||||
|
||||
class SelectionContracts(unittest.TestCase):
|
||||
def test_recorded_clock_must_equal_observed_solver(self):
|
||||
driver.check_clock(types.SimpleNamespace(step_count=4579200),4576000,3200)
|
||||
with self.assertRaisesRegex(RuntimeError,'observed solver clock'):
|
||||
driver.check_clock(types.SimpleNamespace(step_count=4579201),4576000,3200)
|
||||
|
||||
@staticmethod
|
||||
def mean(ux, uy, indices):
|
||||
return dict(mean_ux=ux[indices].mean(axis=0), mean_uy=uy[indices].mean(axis=0))
|
||||
|
||||
Reference in New Issue
Block a user