Updated the Factor class with a new utility function. Fixed a few small bugs in it as well.
This commit is contained in:
+22
-2
@@ -1,4 +1,4 @@
|
||||
class Factor:
|
||||
class Factor:
|
||||
simple_one = []
|
||||
simple_two = []
|
||||
compound_one = []
|
||||
@@ -13,7 +13,7 @@ class Factor:
|
||||
self.base_list = base_list
|
||||
|
||||
def calculate_factors(self, factor, include_compound = False, include_complex = False):
|
||||
clear_factors_lists(self)
|
||||
self.clear_factors_lists()
|
||||
|
||||
for item in self.base_list:
|
||||
self.simple_one.append(factor / item)
|
||||
@@ -54,6 +54,26 @@ class Factor:
|
||||
print(self.complex_four)
|
||||
print()
|
||||
|
||||
def get_flat_factors_list(self):
|
||||
flat_list = []
|
||||
for i in range(len(self.simple_one)):
|
||||
flat_list.append(self.simple_one[i])
|
||||
flat_list.append(self.simple_two[i])
|
||||
|
||||
if len(self.compound_one) > 0:
|
||||
for i in range(len(self.compound_one)):
|
||||
flat_list.append(self.compound_one[i])
|
||||
flat_list.append(self.compound_two[i])
|
||||
|
||||
if len(self.complex_one) > 0:
|
||||
for i in range(len(self.complex_one)):
|
||||
flat_list.append(self.complex_one[i])
|
||||
flat_list.append(self.complex_two[i])
|
||||
flat_list.append(self.complex_three[i])
|
||||
flat_list.append(self.complex_four[i])
|
||||
|
||||
return flat_list
|
||||
|
||||
def clear_factors_lists(self):
|
||||
self.simple_one = []
|
||||
self.simple_two = []
|
||||
|
||||
Reference in New Issue
Block a user