[util/graph] Remove docstrings in prep for more complete documentation

This commit is contained in:
tobi-wan-kenobi 2020-05-10 13:07:08 +02:00
parent 560083ce0c
commit 106bb9e8c3

View file

@ -2,22 +2,13 @@ MAX_PERCENTS = 100.0
class Bar(object): class Bar(object):
"""superclass"""
bars = None bars = None
def __init__(self, value): def __init__(self, value):
"""
Args:
value (float): value between 0. and 100. meaning percents
"""
self.value = value self.value = value
class HBar(Bar): class HBar(Bar):
"""horizontal bar (1 char)"""
bars = [ bars = [
"\u2581", "\u2581",
"\u2582", "\u2582",
@ -30,20 +21,10 @@ class HBar(Bar):
] ]
def __init__(self, value): def __init__(self, value):
"""
Args:
value (float): value between 0. and 100. meaning percents
"""
super(HBar, self).__init__(value) super(HBar, self).__init__(value)
self.step = MAX_PERCENTS / len(HBar.bars) self.step = MAX_PERCENTS / len(HBar.bars)
def get_char(self): def get_char(self):
"""
Decide which char to draw
Return: str
"""
for i in range(len(HBar.bars)): for i in range(len(HBar.bars)):
left = i * self.step left = i * self.step
right = (i + 1) * self.step right = (i + 1) * self.step
@ -53,13 +34,10 @@ class HBar(Bar):
def hbar(value): def hbar(value):
"""wrapper function"""
return HBar(value).get_char() return HBar(value).get_char()
class VBar(Bar): class VBar(Bar):
"""vertical bar (can be more than 1 char)"""
bars = [ bars = [
"\u258f", "\u258f",
"\u258e", "\u258e",
@ -72,23 +50,11 @@ class VBar(Bar):
] ]
def __init__(self, value, width=1): def __init__(self, value, width=1):
"""
Args:
value (float): value between 0. and 100. meaning percents
width (int): width
"""
super(VBar, self).__init__(value) super(VBar, self).__init__(value)
self.step = MAX_PERCENTS / (len(VBar.bars) * width) self.step = MAX_PERCENTS / (len(VBar.bars) * width)
self.width = width self.width = width
def get_chars(self): def get_chars(self):
"""
Decide which char to draw
Return: str
"""
if self.value == 100: if self.value == 100:
return self.bars[-1] * self.width return self.bars[-1] * self.width
if self.width == 1: if self.width == 1:
@ -111,16 +77,10 @@ class VBar(Bar):
def vbar(value, width): def vbar(value, width):
"""wrapper function"""
return VBar(value, width).get_chars() return VBar(value, width).get_chars()
class BrailleGraph(object): class BrailleGraph(object):
"""
graph using Braille chars
scaled to passed values
"""
chars = { chars = {
(0, 0): " ", (0, 0): " ",
(1, 0): "\u2840", (1, 0): "\u2840",
@ -150,11 +110,6 @@ class BrailleGraph(object):
} }
def __init__(self, values): def __init__(self, values):
"""
Args:
values (list): list of values
"""
self.values = values self.values = values
# length of values list must be even # length of values list must be even
# because one Braille char displays two values # because one Braille char displays two values
@ -165,15 +120,6 @@ class BrailleGraph(object):
@staticmethod @staticmethod
def get_height(value, unit): def get_height(value, unit):
"""
Compute height of a value relative to unit
Args:
value (number): value
unit (number): unit
"""
if value < unit / 10.0: if value < unit / 10.0:
return 0 return 0
elif value <= unit: elif value <= unit:
@ -186,11 +132,6 @@ class BrailleGraph(object):
return 4 return 4
def get_steps(self): def get_steps(self):
"""
Convert the list of values to a list of steps
Return: list
"""
maxval = max(self.values) maxval = max(self.values)
unit = maxval / 4.0 unit = maxval / 4.0
if unit == 0: if unit == 0:
@ -201,11 +142,6 @@ class BrailleGraph(object):
return stepslist return stepslist
def get_chars(self): def get_chars(self):
"""
Decide which chars to draw
Return: str
"""
chars = [] chars = []
for part in self.parts: for part in self.parts:
chars.append(BrailleGraph.chars[part]) chars.append(BrailleGraph.chars[part])
@ -213,7 +149,6 @@ class BrailleGraph(object):
def braille(values): def braille(values):
"""wrapper function"""
return BrailleGraph(values).get_chars() return BrailleGraph(values).get_chars()