[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



commit bce5f89882694abdab04addfbe663328ded113d9
Author: juga0 <juga@xxxxxxxxxx>
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.")



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits