before adding sigma

This commit is contained in:
Maria Marchwicka 2020-11-10 17:20:02 +01:00
parent 412adc9abd
commit b843cb9a1f
2 changed files with 20 additions and 27 deletions

View File

@ -243,6 +243,7 @@ class CableSum():
save_path = os.path.join(save_path, dir_name) save_path = os.path.join(save_path, dir_name)
else: else:
save_path = None save_path = None
for i, knot in enumerate(self.knot_summands): for i, knot in enumerate(self.knot_summands):
knot.plot_summand_for_theta(thetas[i], save_path=save_path) knot.plot_summand_for_theta(thetas[i], save_path=save_path)
@ -255,20 +256,11 @@ class CableSum():
sig.SignaturePloter.plot_sum_of_two(pp, sp, title=title, sig.SignaturePloter.plot_sum_of_two(pp, sp, title=title,
save_path=file_path) save_path=file_path)
if save_path is not None: if save_path is not None:
file_path = os.path.join(save_path, "all_" + file_name) file_path = os.path.join(save_path, "all_" + file_name)
sf_list = [knot.signature_as_function_of_theta(thetas[i])[2] sf_list = [knot.signature_as_function_of_theta(thetas[i])[2]
for i, knot in enumerate(self.knot_summands)] for i, knot in enumerate(self.knot_summands)]
sf_list.append(sf_list[-1]) sig.SignaturePloter.plot_many(*sf_list, cols=2)
sf_list.append(sf_list[-1])
sf_list.append(sf_list[-1])
sf_list.append(sf_list[-1])
sf_list.append(sf_list[-1])
sf_list.append(sf_list[-1])
# sf_list.append(sf_list[-1])
sig.SignaturePloter.plot_many(*sf_list)
# pp, sp, sf = knot.signature_as_function_of_theta(thetas[i]) # pp, sp, sf = knot.signature_as_function_of_theta(thetas[i])
# (pp + sp) = sp.plot # (pp + sp) = sp.plot
# #
@ -276,9 +268,6 @@ class CableSum():
# save_path=file_path) # save_path=file_path)
return dir_name return dir_name
def plot_all_summands(self): def plot_all_summands(self):
@ -377,7 +366,8 @@ class CableSum():
shifted_thetas = [shift * th for th in thetas] shifted_thetas = [shift * th for th in thetas]
pp, sp, sf= self.signature_as_function_of_theta(*shifted_thetas) pp, sp, sf= self.signature_as_function_of_theta(*shifted_thetas)
limit = 5 + np.count_nonzero(shifted_thetas) limit = 5 + np.count_nonzero(shifted_thetas)
extremum = abs(sf.extremum(limit=limit)[1]) ext = sf.extremum(limit=limit)[1]
extremum = abs(ext)
if shift > 1: if shift > 1:
print(shifted_thetas, end=" ") print(shifted_thetas, end=" ")
print(extremum) print(extremum)
@ -387,7 +377,7 @@ class CableSum():
elif shift == 1: elif shift == 1:
print("*" * 10) print("*" * 10)
print(shifted_thetas, end=" ") print(shifted_thetas, end=" ")
print(extremum) print(ext)
if signature_is_small: if signature_is_small:
print("\n" * 10 + "!" * 1000) print("\n" * 10 + "!" * 1000)
return False return False
@ -416,7 +406,7 @@ class CableSum():
class CableTemplate(): class CableTemplate():
def __init__(self, knot_formula, q_vector=None, k_vector=None, def __init__(self, knot_formula, q_vector=None, k_vector=None,
generate_q_vector=True, slice_candidate=True): generate_q_vector=True, slice=True):
self._knot_formula = knot_formula self._knot_formula = knot_formula
# q_i = 2 * k_i + 1 # q_i = 2 * k_i + 1
if k_vector is not None: if k_vector is not None:
@ -424,7 +414,7 @@ class CableTemplate():
elif q_vector is not None: elif q_vector is not None:
self.q_vector = q_vector self.q_vector = q_vector
elif generate_q_vector: elif generate_q_vector:
self.q_vector = self.get_q_vector(knot_formula, slice_candidate) self.q_vector = self.get_q_vector(slice=slice)
@property @property
def cable(self): def cable(self):
@ -436,7 +426,7 @@ class CableTemplate():
return self._cable return self._cable
def fill_q_vector(self, q_vector=None, slice=True): def fill_q_vector(self, q_vector=None, slice=True):
self.q_vector = q_vector or self.get_q_vector(self.knot_formula, slice) self.q_vector = q_vector or self.get_q_vector(slice)
@property @property
def knot_formula(self): def knot_formula(self):
@ -471,12 +461,12 @@ class CableTemplate():
numbers = map(int, numbers) numbers = map(int, numbers)
return max(numbers) return max(numbers)
@classmethod def get_q_vector(self, slice=True):
def get_q_vector(cls, knot_formula, slice=True): knot_formula = self.knot_formula
lowest_number = 2 lowest_number = 2
q_vector = [0] * (cls.extract_max(knot_formula) + 1) q_vector = [0] * (self.extract_max(knot_formula) + 1)
P = Primes() P = Primes()
for layer in cls.get_layers_from_formula(knot_formula)[::-1]: for layer in self.get_layers_from_formula(knot_formula)[::-1]:
for el in layer: for el in layer:
q_vector[el] = P.next(lowest_number) q_vector[el] = P.next(lowest_number)
lowest_number = q_vector[el] lowest_number = q_vector[el]

View File

@ -142,7 +142,7 @@ class SignatureFunction:
class SignaturePloter: class SignaturePloter:
@classmethod @classmethod
def plot_many(cls, *sf_list, save_path=None, title='',): def plot_many(cls, *sf_list, save_path=None, title='', cols=None):
axes_num = len(sf_list) axes_num = len(sf_list)
if axes_num > 36: if axes_num > 36:
@ -153,11 +153,14 @@ class SignaturePloter:
warnings.warn(msg) warnings.warn(msg)
# print war, set val in conf # print war, set val in conf
rows = ceil(sqrt(axes_num)) cols = cols or ceil(sqrt(axes_num))
cols = ceil(axes_num/rows) rows = ceil(axes_num/cols)
fig, axes_matrix = plt.subplots(rows, cols, fig, axes_matrix = plt.subplots(rows, cols,
sharey=True, sharex='col', sharey='row',
sharex=True,) gridspec_kw={'hspace': 0, 'wspace': 0},
# sharey=True,
# sharex=True,
)
for i, sf in enumerate(sf_list): for i, sf in enumerate(sf_list):
col = i % cols col = i % cols
row = (i - col)/cols row = (i - col)/cols