Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix in human_readable_stat when timedelta is a string with a number smaller than 1 #502

Open
wants to merge 1 commit into
base: release
Choose a base branch
from

Conversation

jlucas95
Copy link

@jlucas95 jlucas95 commented Oct 2, 2024

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):

from pm4py.util.vis_utils import human_readable_stat

print(human_readable_stat(1.2))
print(human_readable_stat('1.2'))
print(human_readable_stat(0.2))
print(human_readable_stat('0.2'))

The last line will raise a ValueError in the current release and is fixed in this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants