From 47edb1dbd1e1bdb44a222a4a898b58b17a53a899 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 25 Apr 2019 13:51:50 -0400 Subject: [PATCH] Add a prototype stats command for CLI commands --- misc/stats | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 misc/stats diff --git a/misc/stats b/misc/stats new file mode 100755 index 00000000..d608831c --- /dev/null +++ b/misc/stats @@ -0,0 +1,37 @@ +#!/usr/bin/python + +import numpy as np +import matplotlib as mpl +mpl.use('Agg') +import matplotlib.pyplot as plt +import os +import sixel +import subprocess +import sys +import tempfile + +class DumbWriter(sixel.SixelWriter): + def restore_position(self, output): + return + + +plotdata = [] +data = sys.stdin.readline() +while data: + datum = float(data.split()[-1]) + plotdata.append(datum) + data = sys.stdin.readline() +n, bins, patches = plt.hist(plotdata, 20) +plt.show() +path = tempfile.mkdtemp() +plt.savefig('{0}/histo.png'.format(path)) +writer = DumbWriter() +writer.draw('{0}/histo.png'.format(path)) +print('Min: {3} Median: {0} Mean: {1} Max: {4} Standard Deviation: {2} Samples: {5}'.format(np.median(plotdata), np.mean(plotdata), np.std(plotdata), np.min(plotdata), np.max(plotdata), len(plotdata))) +os.remove('{0}/histo.png'.format(path)) +os.rmdir(path) + + + + +