From 904ef2b0321b52267e7af29e05fda81231a48f71 Mon Sep 17 00:00:00 2001 From: lukew3 Date: Sat, 9 Oct 2021 04:05:56 -0400 Subject: [PATCH] fixed lint errors --- .../funcs/algebra/compound_interest.py | 9 ++-- mathgenerator/funcs/algebra/expanding.py | 8 +-- mathgenerator/funcs/algebra/invert_matrix.py | 6 +-- .../funcs/algebra/simple_interest.py | 6 +-- .../funcs/geometry/basic_trigonometry.py | 4 +- .../equation_of_line_from_two_points.py | 50 ------------------- .../funcs/geometry/volume_frustum.py | 6 +-- mathgenerator/funcs/misc/complex_to_polar.py | 4 +- mathgenerator/funcs/template.py | 3 +- mathgenerator/funcs/template_comments.py | 13 ++--- scripts/addFuture.py | 3 +- scripts/adoptGenerator.py | 7 ++- 12 files changed, 37 insertions(+), 82 deletions(-) diff --git a/mathgenerator/funcs/algebra/compound_interest.py b/mathgenerator/funcs/algebra/compound_interest.py index 785aff1..9826fef 100644 --- a/mathgenerator/funcs/algebra/compound_interest.py +++ b/mathgenerator/funcs/algebra/compound_interest.py @@ -2,9 +2,9 @@ from .__init__ import * def gen_func(maxPrinciple=10000, - maxRate=10, - maxTime=10, - format='string'): + maxRate=10, + maxTime=10, + format='string'): p = random.randint(1000, maxPrinciple) r = random.randint(1, maxRate) n = random.randint(1, maxTime) @@ -13,7 +13,8 @@ def gen_func(maxPrinciple=10000, if format == 'string': problem = "Compound interest for a principle amount of " + \ str(p) + " dollars, " + str(r) + \ - "% rate of interest and for a time period of " + str(n) + " year is = " + "% rate of interest and for a time period of " + \ + str(n) + " year is = " return problem, str(a) elif format == 'latex': return "Latex unavailable" diff --git a/mathgenerator/funcs/algebra/expanding.py b/mathgenerator/funcs/algebra/expanding.py index 62d4945..4bf869d 100644 --- a/mathgenerator/funcs/algebra/expanding.py +++ b/mathgenerator/funcs/algebra/expanding.py @@ -2,10 +2,10 @@ from .__init__ import * def gen_func(range_x1=10, - range_x2=10, - range_a=10, - range_b=10, - format='string'): + range_x2=10, + range_a=10, + range_b=10, + format='string'): x1 = random.randint(-range_x1, range_x1) x2 = random.randint(-range_x2, range_x2) a = random.randint(-range_a, range_a) diff --git a/mathgenerator/funcs/algebra/invert_matrix.py b/mathgenerator/funcs/algebra/invert_matrix.py index bca6983..468ec06 100644 --- a/mathgenerator/funcs/algebra/invert_matrix.py +++ b/mathgenerator/funcs/algebra/invert_matrix.py @@ -3,9 +3,9 @@ import sympy def gen_func(SquareMatrixDimension=3, - MaxMatrixElement=99, - OnlyIntegerElementsInInvertedMatrix=False, - format='string'): + MaxMatrixElement=99, + OnlyIntegerElementsInInvertedMatrix=False, + format='string'): if OnlyIntegerElementsInInvertedMatrix is True: isItOk = False Mat = list() diff --git a/mathgenerator/funcs/algebra/simple_interest.py b/mathgenerator/funcs/algebra/simple_interest.py index d80e42b..12b8a7e 100644 --- a/mathgenerator/funcs/algebra/simple_interest.py +++ b/mathgenerator/funcs/algebra/simple_interest.py @@ -2,9 +2,9 @@ from .__init__ import * def gen_func(maxPrinciple=10000, - maxRate=10, - maxTime=10, - format='string'): + maxRate=10, + maxTime=10, + format='string'): a = random.randint(1000, maxPrinciple) b = random.randint(1, maxRate) c = random.randint(1, maxTime) diff --git a/mathgenerator/funcs/geometry/basic_trigonometry.py b/mathgenerator/funcs/geometry/basic_trigonometry.py index 1f9ac2a..0f51d1d 100644 --- a/mathgenerator/funcs/geometry/basic_trigonometry.py +++ b/mathgenerator/funcs/geometry/basic_trigonometry.py @@ -5,8 +5,8 @@ import math # Handles degrees in quadrant one def gen_func(angles=[0, 30, 45, 60, 90], - functions=["sin", "cos", "tan"], - format='string'): + functions=["sin", "cos", "tan"], + format='string'): angle = random.choice(angles) function = random.choice(functions) diff --git a/mathgenerator/funcs/geometry/equation_of_line_from_two_points.py b/mathgenerator/funcs/geometry/equation_of_line_from_two_points.py index 2ae97d3..e69de29 100644 --- a/mathgenerator/funcs/geometry/equation_of_line_from_two_points.py +++ b/mathgenerator/funcs/geometry/equation_of_line_from_two_points.py @@ -1,50 +0,0 @@ -from .__init__ import * - - -def gen_func(maxCoordinate=20, minCoordinate=-20, format='string'): - def greatest_common_divisor(num1,num2): - if num2==0: - return num1 - else: - return greatest_common_divisor(num2 , num1%num2) - - x1 = random.randint(minCoordinate, maxCoordinate) - x2 = random.randint(minCoordinate, maxCoordinate) - - y1 = random.randint(minCoordinate, maxCoordinate) - y2 = random.randint(minCoordinate, maxCoordinate) - - coeff_y = (x2-x1) - coeff_x = (y2-y1) - constant = y2*coeff_y - x2*coeff_x - - gcd = greatest_common_divisor(abs(coeff_x), abs(coeff_y)) - - if gcd !=1: - if coeff_y > 0: coeff_y //= gcd - if coeff_x > 0: coeff_x //= gcd - if constant > 0: constant //= gcd - if coeff_y < 0: coeff_y = -(-coeff_y//gcd) - if coeff_x < 0: coeff_x = -(-coeff_x//gcd) - if constant < 0: constant = -(-constant//gcd) - if coeff_y < 0 : - coeff_y = -(coeff_y) - coeff_x = -(coeff_x) - constant = -(constant) - - if format == 'string': - problem = f"What is the equation of the line between points ({x1},{y1}) and ({x2},{y2}) in slope-intercept form?" - if constant > 0: - solution = str(coeff_y)+"y = " + str(coeff_x)+ "x + " + str(constant) - else: - solution = str(coeff_y)+"y = " + str(coeff_x)+ "x - " + str(-constant) - return problem, solution - elif format == 'latex': - return 'Latex unavailable' - else: - return x1, x2, y1, y2, coeff_x, coeff_y, constant - - -equation_of_line_from_two_points = Generator( - "Equation of line from two points", 114, gen_func, - ["maxCoordinate=20", "minCoordinate=-20"]) diff --git a/mathgenerator/funcs/geometry/volume_frustum.py b/mathgenerator/funcs/geometry/volume_frustum.py index e0f9cb3..715d2c2 100644 --- a/mathgenerator/funcs/geometry/volume_frustum.py +++ b/mathgenerator/funcs/geometry/volume_frustum.py @@ -1,11 +1,11 @@ from .__init__ import * -def gen_func(maxR1=20, maxR2 = 20, maxHeight=50, unit='m', format='string'): +def gen_func(maxR1=20, maxR2=20, maxHeight=50, unit='m', format='string'): h = random.randint(1, maxHeight) r1 = random.randint(1, maxR1) r2 = random.randint(1, maxR2) - ans = ((math.pi*h)*(r1**2 + r2**2 + r1*r2))//3 + ans = ((math.pi * h) * (r1 ** 2 + r2 ** 2 + r1 * r2)) // 3 if format == 'string': problem = f"Volume of frustum with height = {h}{unit} and r1 = {r1}{unit} is and r2 = {r1}{unit} is " @@ -18,4 +18,4 @@ def gen_func(maxR1=20, maxR2 = 20, maxHeight=50, unit='m', format='string'): volume_frustum = Generator("Volume of frustum", 113, gen_func, - ["maxR1=20","maxR2=20", "maxHeight=50", "unit='m'"]) + ["maxR1=20", "maxR2=20", "maxHeight=50", "unit='m'"]) diff --git a/mathgenerator/funcs/misc/complex_to_polar.py b/mathgenerator/funcs/misc/complex_to_polar.py index 8ce0fde..eaba4ba 100644 --- a/mathgenerator/funcs/misc/complex_to_polar.py +++ b/mathgenerator/funcs/misc/complex_to_polar.py @@ -4,8 +4,8 @@ import math def gen_func(minRealImaginaryNum=-20, - maxRealImaginaryNum=20, - format='string'): + maxRealImaginaryNum=20, + format='string'): num = complex(random.randint(minRealImaginaryNum, maxRealImaginaryNum), random.randint(minRealImaginaryNum, maxRealImaginaryNum)) a = num.real diff --git a/mathgenerator/funcs/template.py b/mathgenerator/funcs/template.py index eddf71b..18217d7 100644 --- a/mathgenerator/funcs/template.py +++ b/mathgenerator/funcs/template.py @@ -3,7 +3,6 @@ from .__init__ import * def gen_func(format='string'): - if format == 'string': return problem, solution @@ -16,4 +15,4 @@ def gen_func(format='string'): generator_name = Generator("", id, gen_func, - ["<kwarg1>"]) + ["<kwarg1>"]) diff --git a/mathgenerator/funcs/template_comments.py b/mathgenerator/funcs/template_comments.py index d18aad6..816b735 100644 --- a/mathgenerator/funcs/template_comments.py +++ b/mathgenerator/funcs/template_comments.py @@ -9,17 +9,18 @@ def gen_func(format='string'): return problem, solution elif format == 'latex': # code that generates latex representation of problem, and solution goes here - # if you can't do this, leave the return 'Latex unavailable' - #return latex_problem, latex_solution + # if you can't do this, leave the return 'Latex unavailable' + # return latex_problem, latex_solution return 'Latex unavailable' else: # Return necessary variables here - # Any variables that go into the problem and solution string without formatting + # Any variables that go into the problem and solution string without formatting return a, b + # generator_name should be the same as the file name -# id can be generated by running nextId.py inside of the scripts folder +# replace id with number generated by running nextId.py inside of the scripts folder # last argument of Generator should be a list of the kwargs used in your gen_func(). -generator_name = Generator("<Title>", <id>, gen_func, - ["<kwarg1>"]) +generator_name = Generator("<Title>", id, gen_func, + ["<kwarg1>"]) # Delete all comments before submitting a pr diff --git a/scripts/addFuture.py b/scripts/addFuture.py index fae6364..47f0fde 100644 --- a/scripts/addFuture.py +++ b/scripts/addFuture.py @@ -13,4 +13,5 @@ else: file = './futureGenerators.md' with open(file, 'a') as f: - f.writelines(f'| {title} | {example_problem} | {example_solution} | {further_explanation} |\n') + f.writelines( + f'| {title} | {example_problem} | {example_solution} | {further_explanation} |\n') diff --git a/scripts/adoptGenerator.py b/scripts/adoptGenerator.py index 3afea71..e6d4902 100644 --- a/scripts/adoptGenerator.py +++ b/scripts/adoptGenerator.py @@ -1,6 +1,7 @@ import os from makeReadme import main + def get_filepaths(subject_name): """ This function will generate the file names in a directory @@ -23,7 +24,9 @@ def get_filepaths(subject_name): return file_paths -subjects = ['algebra', 'basic_math', 'calculus', 'computer_science', 'geometry', 'misc', 'statistics'] + +subjects = ['algebra', 'basic_math', 'calculus', + 'computer_science', 'geometry', 'misc', 'statistics'] for subject in subjects: full_file_paths = get_filepaths(subject) full_file_paths.sort() @@ -34,4 +37,4 @@ for subject in subjects: with open(f'../mathgenerator/funcs/{subject}/__init__.py', 'w') as f: f.writelines(lines) -main() #makes readme +main() # makes readme