Revised the Factor object.

This commit is contained in:
2020-04-13 01:17:39 -05:00
parent d1231b062f
commit 39c94aafa9
2 changed files with 12 additions and 26 deletions
+9 -26
View File
@@ -8,25 +8,24 @@ class Factor:
complex_three = []
complex_four = []
def __init__(self, variable_name, factors, factor_type):
self.variable_name = varianle_name
self.factors = factors
self.factor_type = factor_type
def __init__(self, variable_name, base_list):
self.variable_name = variable_name
self.base_list = base_list
def calculate_factors(self, factor, base_list, include_compound = False, include_complex = False):
def calculate_factors(self, factor, include_compound = False, include_complex = False):
clear_factors_lists(self)
for item in base_list:
for item in self.base_list:
simple_one.append(factor / item)
simple_two.append(factor * item)
simple_two.append(factor * item)
if include_compound:
for item in base_list:
for item in self.base_list:
compound_one.append(((1 + factor) ** (1 / item)) - 1)
compound_two.append(((1 + factor) ** item) - 1)
if include_complex:
for item in base_list:
for item in self.base_list:
complex_one.append(item * (((1 + factor) ** (1 / item)) - 1))
complex_two.append(1 / item * (((1 + factor) ** (1 / item)) - 1))
complex_three.append(item * (((1 + factor) ** item) - 1 ))
@@ -64,20 +63,4 @@ class Factor:
self.complex_two = []
self.complex_three = []
self.complex_four = []
class FactorTypes:
simple = 0
compound = 1
complex = 2
FACTOR_TYPES = {
0 : "Simple",
1 : "Compound",
2 : "Complex"
}
@staticmethod
def get_factor_type_name(factor_type):
if not factor_type in FACTOR_TYPES:
raise ValueError("The factor types is invalid.", "factor_type")
return FACTOR_TYPES[factor_type]
+3
View File
@@ -20,3 +20,6 @@ with open("expression.json", "r") as f:
for t in tokens:
print("%s (%s) " %(t.value, token.TokenType.get_token_type_name(t.type)), end = "")
print()
def factors(factor_object, starting_point, variable_type)