anishmehta24 opened a new issue, #40263: URL: https://github.com/apache/beam/issues/40263
### What happened? `Duration(seconds)` truncates instead of rounding when `seconds` is a float, so it can land one microsecond below the value passed in. This is the same thing #40235 described for `Timestamp`, which #40257 fixed, but `Duration.__init__` still does: ```python self.micros = int(seconds * 1000000) + int(micros) ``` ```python >>> from apache_beam.utils.timestamp import Duration >>> Duration(2.000002).micros 2000001 # expected 2000002 >>> Duration(-2.000002).micros -2000001 # expected -2000002 ``` Using `round()` like the `Timestamp` constructor now does fixes it. ### Issue Priority Priority: 3 (minor) ### Issue Components - [x] Component: Python SDK -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
