Handle null reduced actions with an absolute derivative floor

This commit is contained in:
2026-09-17 09:45:56 -04:00
parent c393847c6f
commit 4ae2f3f134
3 changed files with 19 additions and 4 deletions

View File

@@ -246,7 +246,8 @@ class Assessment:
continue
alpha, error, relative, floor = (number(row, key) for key in ("alpha", "difference_quotient_error", "relative_error", "residual_subtraction_roundoff_scale"))
valid.append((alpha, error, relative, floor))
self.check(f"reduced_fd_{alpha:g}_finite", all(nonnegative(x) for x in (error, relative, floor)))
self.check(f"reduced_fd_{alpha:g}_finite", all(nonnegative(x) for x in (error, floor)) and
(nonnegative(relative) or abs(action) <= roundoff(action)))
self.check(f"reduced_fd_{alpha:g}_completed_sides", all(nonnegative(number(row, key)) and number(row, key) <= tolerance for key in ("plus_gravity_norm", "minus_gravity_norm")))
if error > 20.0 * floor:
reliable.append((alpha, error))
@@ -254,7 +255,8 @@ class Assessment:
if not valid:
self.incomplete("reduced_central_difference_available", reason="No pair completed on both sides")
return
self.check("reduced_central_difference_accuracy", min(item[2] for item in valid) <= 1e-5,
self.check("reduced_central_difference_accuracy", any(
(nonnegative(item[2]) and item[2] <= 1e-5) or item[1] <= 20.0 * item[3] for item in valid),
minimum_relative_error=min(item[2] for item in valid), tolerance=1e-5)
reliable.sort(reverse=True)
orders = [math.log(b[1] / a[1]) / math.log(b[0] / a[0]) for a, b in zip(reliable, reliable[1:]) if a[0] != b[0]]