2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 11:01:09 +00:00
confluent/misc/stats

49 lines
1.4 KiB
Plaintext
Raw Normal View History

#!/usr/bin/python
2019-04-25 17:59:15 +00:00
# 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()
2019-04-25 17:59:15 +00:00
tdata = io.BytesIO()
plt.savefig(tdata)
writer = DumbWriter()
2019-04-25 17:59:15 +00:00
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)))