[tor-commits] [onionperf/develop] Move two data.empty checks after data.dropna calls.

karsten at torproject.org karsten at torproject.org
Sun Dec 13 21:58:58 UTC 2020


commit c46deb00967899bdd9c15b9b7ee41ca5c588883b
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Sun Dec 13 22:26:52 2020 +0100

    Move two data.empty checks after data.dropna calls.
    
    Suggested by acute, still related to #40012.
---
 onionperf/visualization.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/onionperf/visualization.py b/onionperf/visualization.py
index 75ec2b5..a793791 100644
--- a/onionperf/visualization.py
+++ b/onionperf/visualization.py
@@ -298,25 +298,26 @@ class TGenVisualization(Visualization):
         plt.close()
 
     def __draw_countplot(self, x, data, title, xlabel, ylabel, hue=None, hue_name=None):
+        data = data.dropna(subset=[x])
         if data.empty:
             return
         plt.figure()
         if hue is not None:
             data = data.rename(columns={hue: hue_name})
-        g = sns.countplot(data=data.dropna(subset=[x]), x=x, hue=hue_name)
+        g = sns.countplot(data=data, x=x, hue=hue_name)
         g.set(xlabel=xlabel, ylabel=ylabel, title=title)
         sns.despine()
         self.page.savefig()
         plt.close()
 
     def __draw_stripplot(self, x, y, hue, hue_name, data, title, xlabel, ylabel):
+        data = data.dropna(subset=[y])
         if data.empty:
             return
         plt.figure()
         data = data.rename(columns={hue: hue_name})
         xmin = data[x].min()
         xmax = data[x].max()
-        data = data.dropna(subset=[y])
         g = sns.stripplot(data=data, x=x, y=y, hue=hue_name)
         g.set(title=title, xlabel=xlabel, ylabel=ylabel,
               xlim=(xmin - 0.03 * (xmax - xmin), xmax + 0.03 * (xmax - xmin)))





More information about the tor-commits mailing list