Skip to content

Commit

Permalink
Merge pull request #17 from Com1t/fix-plot-results-too-many-tailing-z…
Browse files Browse the repository at this point in the history
…eros

Fixed "plot_results.py" adds too many zeros in the generated "heatmap.pdf"
  • Loading branch information
alexnick83 authored Jul 7, 2023
2 parents f18e3c7 + 129efba commit 857a7ec
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions plot_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
from scipy.stats.mstats import gmean
from npbench.infrastructure import utilities as util

def my_round(x, width):
float_format = "{:." + f"{width}" + "f}"
return float_format.format(x)

# geomean which ignores NA values
def my_geomean(x):
Expand All @@ -31,9 +34,9 @@ def my_speedup_abbr(x):
if x > 100:
x = int(x)
if x > 1000:
label = prefix + str(round(x / 1000, 1)) + "k"
label = prefix + str(my_round(x / 1000, 1)) + "k"
else:
label = prefix + str(round(x, 1))
label = prefix + str(my_round(x, 1))
return str(label)


Expand All @@ -45,7 +48,7 @@ def my_runtime_abbr(x):
if x < 0.1:
x = x * 1000
suffix = " ms"
return str(round(x, 2)) + suffix
return str(my_round(x, 2)) + suffix


def bootstrap_ci(data, statfunction=np.median, alpha=0.05, n_samples=300):
Expand Down Expand Up @@ -298,4 +301,4 @@ def bootstrap_ids(data, n_samples=100):

plt.tight_layout()
plt.savefig("heatmap.pdf", dpi=600)
plt.show()
plt.show()

0 comments on commit 857a7ec

Please sign in to comment.