mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
lint fixes
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
from mathgenerator.mathgen import *
|
||||
|
||||
write_list = []
|
||||
subjects = ['algebra', 'basic_math', 'calculus', 'computer_science', 'geometry', 'misc', 'statistics']
|
||||
subjects = ['algebra', 'basic_math', 'calculus',
|
||||
'computer_science', 'geometry', 'misc', 'statistics']
|
||||
wList = getGenList()
|
||||
|
||||
|
||||
def array2markdown_table(string):
|
||||
string = string.replace("[[", "<table><tr><td>")
|
||||
string = string.replace("[", "<tr><td>")
|
||||
@@ -14,6 +16,7 @@ def array2markdown_table(string):
|
||||
string = string.replace("\n", "")
|
||||
return string
|
||||
|
||||
|
||||
def write_table_of_contents():
|
||||
lines = []
|
||||
|
||||
@@ -47,6 +50,7 @@ def write_table_of_contents():
|
||||
with open('README.md', "w") as g:
|
||||
g.writelines(lines)
|
||||
|
||||
|
||||
def gen_to_row_string(item):
|
||||
myGen = item[2]
|
||||
# NOTE: renamed 'sol' to 'solu' to make it look nicer
|
||||
@@ -75,6 +79,7 @@ def gen_to_row_string(item):
|
||||
print('added', item[1], '-', func_name, 'to the README.md')
|
||||
return tableLine
|
||||
|
||||
|
||||
def make_table_header(name):
|
||||
lines = [
|
||||
'## ' + name + '\n',
|
||||
@@ -84,6 +89,7 @@ def make_table_header(name):
|
||||
for line in lines:
|
||||
write_list.append(line)
|
||||
|
||||
|
||||
def write_subject_table(subject_name, full_gen_list):
|
||||
subject_list = []
|
||||
# Create list of generators in given subject
|
||||
@@ -119,5 +125,6 @@ def main():
|
||||
|
||||
print("New README.md table generated")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
|
||||
|
||||
def get_filepaths(directory):
|
||||
"""
|
||||
This function will generate the file names in a directory
|
||||
@@ -19,6 +20,7 @@ def get_filepaths(directory):
|
||||
|
||||
return file_paths # Self-explanatory.
|
||||
|
||||
|
||||
# Run the above function and store its results in a variable.
|
||||
full_file_paths = get_filepaths("mathgenerator/funcs/statistics")
|
||||
full_file_paths.sort()
|
||||
|
||||
@@ -15,8 +15,10 @@ def multiplyIntToMatrix22(maxMatrixVal=10, maxRes=100, style='raw'):
|
||||
d1 = d * constant
|
||||
|
||||
if style == 'latex':
|
||||
problem = "\\(" + str(constant) + "\\cdot\\begin{bmatrix}" + str(a) + "&" + str(b) + "\\\\" + str(c) + "&" + str(d) + "\\end{bmatrix}=\\)"
|
||||
solution = "\\(\\begin{bmatrix}" + str(a1) + "&" + str(b1) + "\\\\" + str(c1) + "&" + str(d1) + "\\end{bmatrix}\\)"
|
||||
problem = "\\(" + str(constant) + "\\cdot\\begin{bmatrix}" + str(
|
||||
a) + "&" + str(b) + "\\\\" + str(c) + "&" + str(d) + "\\end{bmatrix}=\\)"
|
||||
solution = "\\(\\begin{bmatrix}" + str(a1) + "&" + str(b1) + \
|
||||
"\\\\" + str(c1) + "&" + str(d1) + "\\end{bmatrix}\\)"
|
||||
else:
|
||||
problem = f"{constant} * [[{a}, {b}], [{c}, {d}]] = "
|
||||
solution = f"[[{a1},{b1}],[{c1},{d1}]]"
|
||||
|
||||
@@ -9,7 +9,8 @@ def cubeRootFunc(minNo=1, maxNo=1000, style='raw'):
|
||||
problem = f"\\(\\sqrt[3]{{{b}}}=\\)"
|
||||
solution = "\\(" + str(round(a, 2)) + "\\)"
|
||||
else:
|
||||
problem = "What is the cube root of " + str(b) + " up to 2 decimal places?"
|
||||
problem = "What is the cube root of " + \
|
||||
str(b) + " up to 2 decimal places?"
|
||||
solution = str(round(a, 2))
|
||||
return problem, solution
|
||||
|
||||
|
||||
@@ -30,11 +30,13 @@ def divideFractionsFunc(maxVal=10, style='raw'):
|
||||
x = f"{sol_numerator}"
|
||||
|
||||
if style == 'latex':
|
||||
problem = "\\(\\frac{" + str(a) + "}{" + str(b) + "}\\div\\frac{" + str(c) + "}{" + str(d) + "}=\\)"
|
||||
problem = "\\(\\frac{" + str(a) + "}{" + str(b) + \
|
||||
"}\\div\\frac{" + str(c) + "}{" + str(d) + "}=\\)"
|
||||
if tmp_d == 1 or tmp_d == gcd:
|
||||
solution = "\\(" + str(sol_numerator) + "\\)"
|
||||
else:
|
||||
solution = "\\(\\frac{" + str(sol_numerator) + "}{" + str(sol_denominator) + "}\\)"
|
||||
solution = "\\(\\frac{" + str(sol_numerator) + \
|
||||
"}{" + str(sol_denominator) + "}\\)"
|
||||
else:
|
||||
problem = f"({a}/{b})/({c}/{d})"
|
||||
solution = x
|
||||
|
||||
@@ -18,4 +18,5 @@ def divisionToIntFunc(maxA=25, maxB=25, style='raw'):
|
||||
return problem, solution
|
||||
|
||||
|
||||
division = Generator("Division", 3, "a/b=", "c", divisionToIntFunc, ["maxA=25", "maxB=25"])
|
||||
division = Generator("Division", 3, "a/b=", "c",
|
||||
divisionToIntFunc, ["maxA=25", "maxB=25"])
|
||||
|
||||
@@ -15,4 +15,5 @@ def factorialFunc(maxInput=6):
|
||||
return problem, solution
|
||||
|
||||
|
||||
factorial = Generator("Factorial", 31, "a! = ", "b", factorialFunc, ["maxInput=6"])
|
||||
factorial = Generator("Factorial", 31, "a! = ", "b",
|
||||
factorialFunc, ["maxInput=6"])
|
||||
|
||||
@@ -8,7 +8,8 @@ def powerOfPowersFunc(maxBase=50, maxPower=10, style='raw'):
|
||||
step = power1 * power2
|
||||
|
||||
if style == 'latex':
|
||||
problem = "Simplify \\(" + str(base) + "^{" + str(power1) + "^{" + str(power2) + "}}\\)"
|
||||
problem = "Simplify \\(" + str(base) + \
|
||||
"^{" + str(power1) + "^{" + str(power2) + "}}\\)"
|
||||
solution = f"\\({base}^{{{step}}}\\)"
|
||||
else:
|
||||
problem = f"Simplify {base}^{power1}^{power2}="
|
||||
|
||||
@@ -14,4 +14,5 @@ def squareRootFunc(minNo=1, maxNo=12, style='raw'):
|
||||
return problem, solution
|
||||
|
||||
|
||||
square_root = Generator("Square Root", 6, "sqrt(a)=", "b", squareRootFunc, ["minNo=1", "maxNo=12"])
|
||||
square_root = Generator("Square Root", 6, "sqrt(a)=",
|
||||
"b", squareRootFunc, ["minNo=1", "maxNo=12"])
|
||||
|
||||
@@ -11,4 +11,5 @@ def subtractionFunc(maxMinuend=99, maxDiff=99):
|
||||
return problem, solution
|
||||
|
||||
|
||||
subtraction = Generator("Subtraction", 1, "a-b=", "c", subtractionFunc, ["maxMinuend=99", "maxDiff=99"])
|
||||
subtraction = Generator("Subtraction", 1, "a-b=", "c",
|
||||
subtractionFunc, ["maxMinuend=99", "maxDiff=99"])
|
||||
|
||||
@@ -8,7 +8,8 @@ def arithmeticProgressionSumFunc(maxd=100, maxa=100, maxn=100):
|
||||
a3 = a1 + 2 * d
|
||||
n = random.randint(4, maxn)
|
||||
apString = str(a1) + ', ' + str(a2) + ', ' + str(a3) + ' ... '
|
||||
problem = 'Find the sum of first ' + str(n) + ' terms of the AP series: ' + apString
|
||||
problem = 'Find the sum of first ' + \
|
||||
str(n) + ' terms of the AP series: ' + apString
|
||||
an = a1 + (n - 1) * d
|
||||
solution = n * (a1 + an) / 2
|
||||
return problem, solution
|
||||
|
||||
@@ -13,7 +13,8 @@ def set_operation(minval=3, maxval=7, n_a=4, n_b=5):
|
||||
a = set(a)
|
||||
b = set(b)
|
||||
problem = "Given the two sets a=" + \
|
||||
str(a) + " ,b=" + str(b) + ".Find the Union,intersection,a-b,b-a and symmetric difference"
|
||||
str(a) + " ,b=" + str(b) + \
|
||||
".Find the Union,intersection,a-b,b-a and symmetric difference"
|
||||
solution = "Union is " + str(a.union(b)) + ",Intersection is " + str(
|
||||
a.intersection(b)) + ", a-b is " + str(
|
||||
a.difference(b)) + ",b-a is " + str(
|
||||
|
||||
@@ -9,7 +9,8 @@ def conditionalProbFunc():
|
||||
def BayesFormula(P_disease, true_positive, true_negative):
|
||||
P_notDisease = 100. - P_disease
|
||||
false_positive = 100. - true_negative
|
||||
P_plus = (P_disease) * (true_positive) + (P_notDisease) * (false_positive)
|
||||
P_plus = (P_disease) * (true_positive) + \
|
||||
(P_notDisease) * (false_positive)
|
||||
P_disease_plus = ((true_positive) * (100 * P_disease)) / P_plus
|
||||
|
||||
return P_disease_plus
|
||||
@@ -18,7 +19,8 @@ def conditionalProbFunc():
|
||||
"Test sensitivity (true positive) is equal to SN= {1:.2f}% whereas test specificity (true negative) SP= {2:.2f}%. " \
|
||||
"What is the probability that this guy really has that disease?".format(
|
||||
P_disease, true_positive, true_negative)
|
||||
answer = str(round(BayesFormula(P_disease, true_positive, true_negative), 2)) + "%"
|
||||
answer = str(
|
||||
round(BayesFormula(P_disease, true_positive, true_negative), 2)) + "%"
|
||||
|
||||
return problem, answer
|
||||
|
||||
|
||||
Reference in New Issue
Block a user