#!/usr/bin/python # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2019 Lenovo # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import io 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() tdata = io.BytesIO() plt.savefig(tdata) writer = DumbWriter() writer.draw(tdata) 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)))