Add a checked stepped_over to RotorLag - #350
Open
naseem173 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #298.
Adds
RotorLag::try_stepped_over, a checked variant ofstepped_overfor a variable-rate loop where the tick length was not already validated byRotorLag::new(for example, one computed from a pair of timestamps that can come out the wrong way round). A negative tick composes into runaway growth rather than a small backward step, since(-timestep / time_constant).exp()then exceeds one, so this is worth rejecting explicitly rather than leaving it to the caller.What changed
try_stepped_overvalidates onlytimestep(finite and strictly positive), matchingstepped/stepped_over's existing "checking the command is the caller's job" behavior — the command vector is not checked here either.PlantError::NonFinite/PlantError::NonPositiveTimestepvariants; no new error variants needed.selfis left unchanged (covered by a dedicated test).try_naming convention for a fallible variant living alongside an infallible sibling (e.g.try_with_connection_radius,try_normalized), rather thanchecked_, which this codebase reserves for arithmetic.Testing
cargo test -p multicalc rotor_lag(targeted) andcargo test -p multicalc(full suite incl. doctests)cargo test -p multicalc --features alloccargo fmt --all --checkcargo clippy -p multicalc --all-targets --features alloc -- -D warningscargo doc -p multicalc --no-deps --all-featuresAdded 4 new tests: the checked step matching the fixed-rate model at the total elapsed time, rejecting a non-positive timestep, rejecting a non-finite timestep, and leaving the rotors untouched on rejection.