function name included in generator instance variables and genList[3]

This commit is contained in:
lukew3
2020-10-20 10:13:54 -04:00
parent 82a0e1433a
commit b4044facf6
7 changed files with 121 additions and 97 deletions

View File

@@ -2,6 +2,7 @@
# NOTE: not anymore. but still leaving this comment in.
from mathgenerator.mathgen import *
def array2markdown_table(string):
string = string.replace("[[", "<table><tr><td>")
string = string.replace("[", "<tr><td>")
@@ -20,29 +21,31 @@ with open('mathgenerator/mathgen.py', 'r') as f:
allRows = []
# get the first line of the functions in mathgen.py
line = lines.index('# Funcs_start - DO NOT REMOVE!\n') + 1
# line = lines.index('# Funcs_start - DO NOT REMOVE!\n') + 1
for item in wList:
myGen = item[2]
# NOTE: renamed 'sol' to 'solu' to make it look nicer
# print(item[3])
prob, solu = myGen()
prob = str(prob).rstrip("\n")
solu = str(solu).rstrip("\n")
# edge case for matrixMultiplication
if item[0] == 46:
prob, solu = myGen(10, 4)
prob, solu = myGen(maxVal=10, max_dim=4)
prob = str(prob).rstrip("\n")
solu = str(solu).rstrip("\n")
prob = array2markdown_table(prob)
solu = array2markdown_table(solu)
instName = lines[line]
# instName = lines[line]
# NOTE: renamed 'def_name' to 'func_name' because it suits it more
func_name = instName[:instName.find('=')].strip()
#func_name = instName[:instName.find('=')].strip()
func_name = item[3]
row = [myGen.id, myGen.title, prob, solu, func_name]
print('added', item[1],'-', func_name, 'to the README.md')
line += 1
if line > len(lines):
break
print('added', item[1], '-', func_name, 'to the README.md')
# line += 1
# if line > len(lines):
# break
allRows.append(row)
with open('README.md', "r") as g: