Revised the Factor object.
This commit is contained in:
+9
-26
@@ -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]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user