bugfix in human_readable_stat when timedelta is a string with a number smaller than 1 #502
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.
I recently encountered a bug when creating a performance visualization of a heuristics net containing transitions that were smaller than 1 second.
The code for creating the visual loops over all edges to create the labels for the visualization.
In this loop the performance metric is first converted to a string and subsequently passed to the
human_readable_stat
function to create the nicely formatted text.See
visualization/heuristics_net/variants/pydotplus_vis.py
lines 193 and 215.The utility function was changed last year to include support for millisecond and nanosecond annotations and I believe this introduced this small bug. The multiplication for ms and ns annotations is done before the conversion to float.
Reordering of these fixes the bug.
The following code can be used to reproduce the bug in the current release (version 2.7.12):
The last line will raise a ValueError in the current release and is fixed in this pull request.