Skip to content

Commit 63491d8

Browse files
committedJun 19, 2020
Bump to v0.4.2, fix build issue
1 parent 17a07a4 commit 63491d8

File tree

3 files changed

+39
-46
lines changed

3 files changed

+39
-46
lines changed
 

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
name='termgraph',
2020
packages=['termgraph'],
2121
entry_points={'console_scripts': ['termgraph=termgraph.termgraph:main']},
22-
version='0.4.1',
22+
version='0.4.2',
2323
author="mkaz",
2424
author_email="marcus@mkaz.com",
2525
url='https://github.com/mkaz/termgraph',

‎termgraph/math_fns.py

-40
This file was deleted.

‎termgraph/termgraph.py

+38-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
import os
1616
import re
1717

18-
from math_fns import find_max
19-
from math_fns import find_min
20-
from math_fns import normalize
21-
22-
VERSION = "0.4.1"
18+
VERSION = "0.4.2"
2319

2420
init()
2521

@@ -134,6 +130,43 @@ def main():
134130
chart(colors, data, args, labels)
135131

136132

133+
def find_min(data):
134+
"""Return the minimum value in sublist of list."""
135+
return min([min(sublist) for sublist in data])
136+
137+
138+
def find_max(data):
139+
"""Return the maximum value in sublist of list."""
140+
return max([max(sublist) for sublist in data])
141+
142+
143+
def normalize(data, width):
144+
"""Normalize the data and return it."""
145+
146+
# We offset by the minimum if there's a negative.
147+
data_offset = []
148+
min_datum = find_min(data)
149+
if min_datum < 0:
150+
min_datum = abs(min_datum)
151+
for datum in data:
152+
data_offset.append([d + min_datum for d in datum])
153+
else:
154+
data_offset = data
155+
min_datum = find_min(data_offset)
156+
max_datum = find_max(data_offset)
157+
158+
# max_dat / width is the value for a single tick. norm_factor is the
159+
# inverse of this value
160+
# If you divide a number to the value of single tick, you will find how
161+
# many ticks it does contain basically.
162+
norm_factor = width / float(max_datum)
163+
normal_data = []
164+
for datum in data_offset:
165+
normal_data.append([v * norm_factor for v in datum])
166+
167+
return normal_data
168+
169+
137170
def find_max_label_length(labels):
138171
"""Return the maximum length for the labels."""
139172
length = 0

0 commit comments

Comments
 (0)
Please sign in to comment.