mirror of
https://github.com/tdulcet/Table-and-Graph-Libs.git
synced 2025-12-16 00:18:55 +08:00
Updated the style and color options to use Enums.
This commit is contained in:
102
python/test.py
102
python/test.py
@@ -21,17 +21,17 @@ columns = 5
|
||||
|
||||
xmin = -10
|
||||
xmax = 10
|
||||
xscl = 2
|
||||
xstep = 0.5
|
||||
|
||||
print("\nOutput array as table\n")
|
||||
array = [[random.randint(0, sys.maxsize)
|
||||
for j in range(columns)] for i in range(rows)]
|
||||
for k in range(len(tables.styles)):
|
||||
tables.array(array, None, None, style=k)
|
||||
for style in tables.style_types:
|
||||
tables.array(array, None, None, style=style)
|
||||
|
||||
array = [[random.random() for j in range(columns)] for i in range(rows)]
|
||||
for k in range(len(tables.styles)):
|
||||
tables.array(array, None, None, style=k)
|
||||
for style in tables.style_types:
|
||||
tables.array(array, None, None, style=style)
|
||||
|
||||
print("\nOutput char array as table\n")
|
||||
array = [["Header row/column 1", "Header row 2", "Header row 3", "Header row 4", "Header row 5"],
|
||||
@@ -39,8 +39,9 @@ array = [["Header row/column 1", "Header row 2", "Header row 3", "Header row 4",
|
||||
["Header column 3", "Data 5", "Data 6", "Data 7", "Data 8"],
|
||||
["Header column 4", "Data 9", "Data 10", "Data 11", "Data 12"],
|
||||
["Header column 5", "Data 13", "Data 14", "Data 15", "Data 16"]]
|
||||
for k in range(len(tables.styles)):
|
||||
tables.array(array, None, None, headerrow=True, headercolumn=True, style=k)
|
||||
for style in tables.style_types:
|
||||
tables.array(array, None, None, headerrow=True,
|
||||
headercolumn=True, style=style)
|
||||
|
||||
print("\nOutput array as table with separate header row and column\n")
|
||||
array = [["Data {0:n}".format(i + j) for j in range(4)]
|
||||
@@ -50,44 +51,52 @@ headerrow = ["Header row/column 1", "Header row 2",
|
||||
headercolumn = ["Header column 2", "Header column 3",
|
||||
"Header column 4", "Header column 5"]
|
||||
|
||||
for k in range(len(tables.styles)):
|
||||
tables.array(array, headerrow, headercolumn, headerrow=True, headercolumn=True, cellborder=True, style=k)
|
||||
tables.array(array, headerrow, headercolumn, headerrow=True, headercolumn=True, style=k)
|
||||
tables.array(array, headerrow[:-1], None, headerrow=True, style=k)
|
||||
tables.array(array, None, [headerrow[0]] + headercolumn[:-1], headercolumn=True, style=k)
|
||||
tables.array(array, None, None, cellborder=True, style=k)
|
||||
tables.array(array, None, None, tableborder=False, style=k)
|
||||
tables.array(array, headerrow, headercolumn, tableborder=False, headerrow=True, headercolumn=True, style=k)
|
||||
tables.array(array, headerrow[:-1], None, tableborder=False, headerrow=True, style=k)
|
||||
tables.array(array, None, [headerrow[0]] + headercolumn[:-1], tableborder=False, headercolumn=True, style=k)
|
||||
tables.array(array, None, None, tableborder=False, cellborder=True, style=k)
|
||||
for style in tables.style_types:
|
||||
tables.array(array, headerrow, headercolumn, headerrow=True,
|
||||
headercolumn=True, cellborder=True, style=style)
|
||||
tables.array(array, headerrow, headercolumn,
|
||||
headerrow=True, headercolumn=True, style=style)
|
||||
tables.array(array, headerrow[:-1], None, headerrow=True, style=style)
|
||||
tables.array(array, None, [headerrow[0]] +
|
||||
headercolumn[:-1], headercolumn=True, style=style)
|
||||
tables.array(array, None, None, cellborder=True, style=style)
|
||||
tables.array(array, None, None, tableborder=False, style=style)
|
||||
tables.array(array, headerrow, headercolumn, tableborder=False,
|
||||
headerrow=True, headercolumn=True, style=style)
|
||||
tables.array(array, headerrow[:-1], None,
|
||||
tableborder=False, headerrow=True, style=style)
|
||||
tables.array(array, None, [headerrow[0]] + headercolumn[:-1],
|
||||
tableborder=False, headercolumn=True, style=style)
|
||||
tables.array(array, None, None, tableborder=False,
|
||||
cellborder=True, style=style)
|
||||
|
||||
array = [[bool(random.getrandbits(1)) for j in range(columns)]
|
||||
for i in range(rows)]
|
||||
for k in range(len(tables.styles)):
|
||||
tables.array(array, None, None, style=k)
|
||||
for style in tables.style_types:
|
||||
tables.array(array, None, None, style=style)
|
||||
|
||||
print("\nOutput sorted array as table\n")
|
||||
array = ([random.randint(0, sys.maxsize)
|
||||
for j in range(columns)] for i in range(rows))
|
||||
sortdimension = 0
|
||||
array = sorted(array, key=lambda x: x[sortdimension])
|
||||
for k in range(len(tables.styles)):
|
||||
tables.array(array, None, None, style=k)
|
||||
for style in tables.style_types:
|
||||
tables.array(array, None, None, style=style)
|
||||
|
||||
print("\nOutput single function as table\n")
|
||||
for k in range(len(tables.styles)):
|
||||
tables.function(xmin, xmax, xscl, afunction, headerrow=True, style=k)
|
||||
for k in range(len(tables.styles)):
|
||||
tables.function(xmin, xmax, xscl, lambda x: x + 1, headerrow=True, style=k)
|
||||
for style in tables.style_types:
|
||||
tables.function(xmin, xmax, xstep, afunction, headerrow=True, style=style)
|
||||
for style in tables.style_types:
|
||||
tables.function(xmin, xmax, xstep, lambda x: x +
|
||||
1, headerrow=True, style=style)
|
||||
|
||||
print("\nOutput multiple functions as table\n")
|
||||
for k in range(len(tables.styles)):
|
||||
tables.functions(xmin, xmax, xscl, [
|
||||
function1, function2], headerrow=True, style=k)
|
||||
for k in range(len(tables.styles)):
|
||||
tables.functions(xmin, xmax, xscl, [
|
||||
lambda x: 2 * x, lambda x: x ** 2], headerrow=True, style=k)
|
||||
for style in tables.style_types:
|
||||
tables.functions(xmin, xmax, xstep, [
|
||||
function1, function2], headerrow=True, style=style)
|
||||
for style in tables.style_types:
|
||||
tables.functions(xmin, xmax, xstep, [
|
||||
lambda x: 2 * x, lambda x: x ** 2], headerrow=True, style=style)
|
||||
|
||||
height = 160
|
||||
width = 160
|
||||
@@ -99,24 +108,25 @@ ymax = 20
|
||||
|
||||
print("\nOutput single array as plot\n")
|
||||
array = [range(i, i + 2) for i in range(10)]
|
||||
for k in range(len(graphs.styles)):
|
||||
graphs.array(height, width, xmin, xmax, ymin, ymax, array, style=k)
|
||||
for style in graphs.style_types:
|
||||
graphs.array(height, width, xmin, xmax, ymin, ymax, array, style=style)
|
||||
|
||||
print("\nOutput single function as graph\n")
|
||||
for k in range(len(graphs.styles)):
|
||||
graphs.function(height, width, xmin, xmax, ymin, ymax, afunction, style=k)
|
||||
for k in range(len(graphs.styles)):
|
||||
for style in graphs.style_types:
|
||||
graphs.function(height, width, xmin, xmax, ymin,
|
||||
ymax, lambda x: x + 1, style=k)
|
||||
ymax, afunction, style=style)
|
||||
for style in graphs.style_types:
|
||||
graphs.function(height, width, xmin, xmax, ymin,
|
||||
ymax, lambda x: x + 1, style=style)
|
||||
|
||||
print("\nOutput multiple functions as graph\n")
|
||||
for k in range(len(graphs.styles)):
|
||||
graphs.functions(height, width, xmin, xmax, ymin,
|
||||
ymax, [function1, function2], style=k)
|
||||
for k in range(len(graphs.styles)):
|
||||
for style in graphs.style_types:
|
||||
graphs.functions(height, width, xmin, xmax, ymin, ymax,
|
||||
[function1, function2], style=style)
|
||||
for style in graphs.style_types:
|
||||
graphs.functions(height, width, xmin, xmax, ymin, ymax, [
|
||||
lambda x: 2 * x, lambda x: x ** 2], style=k)
|
||||
lambda x: 2 * x, lambda x: x ** 2], style=style)
|
||||
|
||||
for k in range(len(graphs.styles)):
|
||||
graphs.functions(height, width, -(2 * math.pi), 2 * math.pi, -4,
|
||||
4, [math.sin, math.cos, math.tan], axisunitslabel=False, style=k)
|
||||
for style in graphs.style_types:
|
||||
graphs.functions(height, width, -(2 * math.pi), 2 * math.pi, -4, 4,
|
||||
[math.sin, math.cos, math.tan], axisunitslabel=False, style=style)
|
||||
|
||||
Reference in New Issue
Block a user