Repository navigation
Allow Duration to be negative - #220
Merged
Merged
Conversation
dirk-thomas
reviewed
Aug 10, 2018
|
|
||
| with self.assertRaises(ValueError): | ||
| duration = Duration(seconds=-1) | ||
| duration = Duration(seconds=-1) |
Member
There was a problem hiding this comment.
It would be good to assert the resulting duration.nanoseconds in this case. Maybe also try the lowest possible value and check that smaller values raise too?
Contributor
Author
There was a problem hiding this comment.
Added check on resulting duration.nanoseconds plus a check on lowest possible value 7697213
The float seconds to integer nanoseconds precision isn't very good at that range. On my machine Duration(seconds=-2**63 / 1e9 - 954e-9) is the first negative floating point number to OverflowError, but I'm not sure how portable that is so I did -2**63 / 1e9 - 1 instead.
Member
|
thanks for following up on this @sloretz. For context, this is a follow up to #209 (comment) |
dirk-thomas
approved these changes
Aug 10, 2018
Contributor
Author
YuanYuYuan
pushed a commit
to YuanYuYuan/rclpy
that referenced
this pull request
Nov 12, 2025
Update roslibrust_serde_rosmsg to improve serialization speed
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.
This allows
Durationinstances to be negative as talked about in ros2/rclcpp#525.Timeis unchanged and cannot have negative values in this PR.