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

@@ -1,3 +1,5 @@
import sys
import traceback
genList = []
@@ -8,7 +10,12 @@ class Generator:
self.generalProb = generalProb
self.generalSol = generalSol
self.func = func
genList.append([id, title, self])
(filename, line_number, function_name, text) = traceback.extract_stack()[-2]
funcname = filename[filename.rfind('/'):].strip()
funcname = funcname[1:-3]
print(funcname)
genList.append([id, title, self, funcname])
def __str__(self):
return str(

View File

@@ -1,5 +1,6 @@
from .__init__ import *
from ..__init__ import Generator
import math
def angleBtwVectorsFunc(maxEltAmt=20):
@@ -15,7 +16,7 @@ def angleBtwVectorsFunc(maxEltAmt=20):
solution = ''
try:
solution = str(math.acos(s / mags))
except MathDomainError:
except ValueError:
print('angleBtwVectorsFunc has some issues with math module, line 16')
solution = 'NaN'
# would return the answer in radians

View File

@@ -4,7 +4,10 @@ from ..__init__ import Generator
def multiplicationFunc(maxRes=99, maxMulti=99):
a = random.randint(0, maxMulti)
b = random.randint(0, min(int(maxMulti / a), maxRes))
if a == 0:
b = random.randint(0, maxRes)
else:
b = random.randint(0, min(int(maxMulti / a), maxRes))
c = a * b
problem = str(a) + "*" + str(b) + "="

View File

@@ -2,7 +2,8 @@ from .__init__ import *
from numpy import pi
def radianToDegFunc(max_rad=pi):
def radianToDegFunc(max_rad=3):
# max_rad is supposed to be pi but random can't handle non-integer
a = random.randint(0, max_rad)
b = (180 * a) / pi
b = round(b, 2)