[tor-commits] [sbws/master] Add method to obtain data for plotting

juga at torproject.org juga at torproject.org
Tue Sep 18 09:26:11 UTC 2018


commit bce5f89882694abdab04addfbe663328ded113d9
Author: juga0 <juga at riseup.net>
Date:   Fri Aug 31 12:27:50 2018 +0000

    Add method to obtain data for plotting
---
 sbws/lib/v3bwfile.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sbws/lib/v3bwfile.py b/sbws/lib/v3bwfile.py
index 65a99a8..04699c6 100644
--- a/sbws/lib/v3bwfile.py
+++ b/sbws/lib/v3bwfile.py
@@ -724,6 +724,15 @@ class V3BWFile(object):
     def median_bw(self):
         return median([l.bw for l in self.bw_lines])
 
+    def to_plt(self, attrs=['bw'], sorted_by=None):
+        """Return bandwidth data in a format useful for matplotlib.
+
+        Used from external tool to plot.
+        """
+        x = [i for i in range(0, self.num)]
+        ys = [[getattr(l, k) for l in self.bw_lines] for k in attrs]
+        return x, ys, attrs
+
     def write(self, output):
         if output == '/dev/stdout':
             log.info("Writing to stdout is not supported.")





More information about the tor-commits mailing list