script_interface: fix time_step==-1 sentinel restore guard (bug-sweep #35)#5365
Draft
RudolfWeeber wants to merge 1 commit into
Draft
script_interface: fix time_step==-1 sentinel restore guard (bug-sweep #35)#5365RudolfWeeber wants to merge 1 commit into
RudolfWeeber wants to merge 1 commit into
Conversation
…35) IntegratorHandle::on_bind_system has a guard that skips re-applying the default -1. sentinel time_step during deserialization, since System::set_time_step(-1.) throws std::domain_error for non-positive values. The 5th guard clause evaluated get_value<double> on the *bool* returned by is_type<double>(...) instead of on the stored value. The bool coerces to 1.0, so the clause was permanently 1.0 == -1. (false) and the guard never skipped. Restoring a System whose time_step was never set (stays at the -1. sentinel, default Velocity Verlet / NVT) therefore re-applied set_time_step(-1.) and raised a ValueError. Evaluate the actual stored value: get_value<double>(params.at(key)), restoring the pre-refactor logic. The preceding is_type<double> clause already guarantees the variant holds a double, so this is safe. Added testsuite/python/integrator_time_step_restore.py: a pickle round-trip of a System with an unset time_step must succeed and keep the -1. sentinel. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
tiny-ocorner corner case, but seems to be legit. |
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.
IntegratorHandle::on_bind_system has a guard that skips re-applying the
default -1. sentinel time_step during deserialization, since
System::set_time_step(-1.) throws std::domain_error for non-positive
values. The 5th guard clause evaluated get_value on the bool
returned by is_type(...) instead of on the stored value. The
bool coerces to 1.0, so the clause was permanently 1.0 == -1. (false)
and the guard never skipped. Restoring a System whose time_step was
never set (stays at the -1. sentinel, default Velocity Verlet / NVT)
therefore re-applied set_time_step(-1.) and raised a ValueError.
Evaluate the actual stored value: get_value(params.at(key)),
restoring the pre-refactor logic. The preceding is_type clause
already guarantees the variant holds a double, so this is safe.
Added testsuite/python/integrator_time_step_restore.py: a pickle
round-trip of a System with an unset time_step must succeed and keep
the -1. sentinel.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
🤖 Generated with Claude Code