delete some unused fragments from SignatureFunction
This commit is contained in:
parent
d0505ee366
commit
93911d0dfd
@ -7,8 +7,6 @@ from sage.arith.functions import LCM_list
|
||||
import warnings
|
||||
import re
|
||||
|
||||
SIGNATURE = 0
|
||||
SIGMA = 1
|
||||
|
||||
# 9.11 (9.8)
|
||||
# 9.15 (9.9)
|
||||
@ -94,10 +92,6 @@ class SignatureFunction(object):
|
||||
return SignatureFunction(counter=counter)
|
||||
|
||||
def __eq__(self, other):
|
||||
self_cnt = Counter({k : v for k, v in self.cnt_signature_jumps.items()
|
||||
if v != 0})
|
||||
other_cnt = Counter({k : v for k, v in other.cnt_signature_jumps.items()
|
||||
if v != 0})
|
||||
return self.cnt_signature_jumps == other.cnt_signature_jumps
|
||||
|
||||
def __str__(self):
|
||||
@ -120,18 +114,13 @@ class SignatureFunction(object):
|
||||
|
||||
def total_sign_jump(self):
|
||||
# Total signature jump is the sum of all jumps.
|
||||
return sum([j[1] for j in self.to_list()])
|
||||
|
||||
def to_list(self):
|
||||
# Return signature jumps formated as a list
|
||||
return sorted(self.cnt_signature_jumps.items())
|
||||
return sum([j[1] for j in sorted(self.cnt_signature_jumps.items())])
|
||||
|
||||
def step_function_data(self):
|
||||
# Transform the signature jump data to a format understandable
|
||||
# by the plot function.
|
||||
l = self.to_list()
|
||||
assert l == sorted(self.cnt_signature_jumps.items())
|
||||
vals = ([(d[0], sum(2 * j[1] for j in l[:l.index(d)+1])) for d in l] +
|
||||
lst = sorted(self.cnt_signature_jumps.items())
|
||||
vals = ([(d[0], sum(2 * j[1] for j in lst[:lst.index(d)+1])) for d in lst] +
|
||||
[(0,self.cnt_signature_jumps[0]), (1,self.total_sign_jump())])
|
||||
print("step_function_data")
|
||||
print(vals)
|
||||
@ -268,82 +257,29 @@ class TorusCable(object):
|
||||
def q_vector(self, new_q_vector):
|
||||
self.k_vector = [(q - 1)/2 for q in new_q_vector]
|
||||
|
||||
def add_with_shift(self, other):
|
||||
# print("*" * 100)
|
||||
# print("BEFORE")
|
||||
# print(self.knot_description)
|
||||
# print(self.knot_sum)
|
||||
# print("*" * 100)
|
||||
# print("BEFORE k_vectors self, other")
|
||||
# print(self.k_vector)
|
||||
# print(other.k_vector)
|
||||
|
||||
shift = len(self.k_vector)
|
||||
formula = re.sub(r'\d+', lambda x: str(int(x.group()) + shift),
|
||||
other.knot_formula)
|
||||
|
||||
knot_formula = self.knot_formula[:-1] + ",\n" + formula[1:]
|
||||
k_vector = self.k_vector + other.k_vector
|
||||
cable = TorusCable(knot_formula, k_vector=k_vector)
|
||||
s_signature_as_function_of_theta = self.signature_as_function_of_theta
|
||||
o_signature_as_function_of_theta = other.signature_as_function_of_theta
|
||||
|
||||
shift = len(self.knot_sum)
|
||||
shift = len(self.knot_sum)
|
||||
def signature_as_function_of_theta(*thetas, **kwargs):
|
||||
result = s_signature_as_function_of_theta(*thetas[shift:]) + \
|
||||
o_signature_as_function_of_theta(*thetas[0:shift])
|
||||
return result
|
||||
cable._signature_as_function_of_theta = signature_as_function_of_theta
|
||||
# print("*" * 100)
|
||||
# print("AFTER")
|
||||
# print(self.knot_description)
|
||||
# print(self.knot_formula)
|
||||
# print(self.knot_sum)
|
||||
# print("*" * 100)
|
||||
# print("AFTER k_vector, q_vector")
|
||||
# print(self.k_vector)
|
||||
# print(self.q_vector)
|
||||
return cable
|
||||
|
||||
def __add__(self, other):
|
||||
if self.k_vector != other.k_vector:
|
||||
msg = "k_vectors are different. k-vector preserving addition is " +\
|
||||
"impossible. The function add_with_shift was called instead"
|
||||
"impossible."
|
||||
warnings.warn(msg)
|
||||
# print("*" * 100)
|
||||
# print("BEFORE")
|
||||
# print(self.knot_description)
|
||||
# print(self.knot_sum)
|
||||
# print("*" * 100)
|
||||
# print("BEFORE k_vectors self, other")
|
||||
|
||||
knot_formula = self.knot_formula[:-1] + ",\n" + other.knot_formula[1:]
|
||||
shift = len(self.k_vector)
|
||||
formula = re.sub(r'\d+', lambda x: str(int(x.group()) + shift),
|
||||
other.knot_formula)
|
||||
self.k_vector = self.k_vector + other.k_vector
|
||||
other.k_vector = self.k_vector
|
||||
else:
|
||||
knot_formula = self.knot_formula[:-1] + ",\n" + \
|
||||
other.knot_formula[1:]
|
||||
cable = TorusCable(knot_formula, k_vector=self.k_vector)
|
||||
s_signature_as_function_of_theta = self.signature_as_function_of_theta
|
||||
o_signature_as_function_of_theta = other.signature_as_function_of_theta
|
||||
# print("FUNCTIONS ")
|
||||
# print(s_signature_as_function_of_theta([1,1,1,2]))
|
||||
# print(o_signature_as_function_of_theta([1,1,1,2]))
|
||||
# print("FUNCTIONS 1111")
|
||||
# print(s_signature_as_function_of_theta([1,1,1,1]))
|
||||
# print(o_signature_as_function_of_theta([1,1,1,1]))
|
||||
|
||||
shift = len(self.knot_sum)
|
||||
def signature_as_function_of_theta(*thetas, **kwargs):
|
||||
result = s_signature_as_function_of_theta(*thetas[shift:]) + \
|
||||
o_signature_as_function_of_theta(*thetas[0:shift])
|
||||
return result
|
||||
cable._signature_as_function_of_theta = signature_as_function_of_theta
|
||||
# print("*" * 100)
|
||||
# print("AFTER")
|
||||
# print(self.knot_description)
|
||||
# print(self.knot_formula)
|
||||
# print(self.knot_sum)
|
||||
# print("*" * 100)
|
||||
# print("AFTER k_vector, q_vector")
|
||||
# print(self.k_vector)
|
||||
# print(self.q_vector)
|
||||
return cable
|
||||
|
||||
|
||||
@ -445,14 +381,10 @@ class TorusCable(object):
|
||||
|
||||
@staticmethod
|
||||
def get_layers_from_formula(knot_formula):
|
||||
layers = []
|
||||
k_indices = re.sub(r'k', '', knot_formula)
|
||||
k_indices = re.sub(r'-', '', k_indices)
|
||||
k_indices = re.sub(r'\n', '', k_indices)
|
||||
k_indices = re.sub(r'[k-]', '', knot_formula)
|
||||
k_indices = re.sub(r'\[\d+\]', lambda x: x.group()[1:-1], k_indices)
|
||||
k_indices = eval(k_indices)
|
||||
number_of_layers = max(len(lst) for lst in k_indices)
|
||||
print(k_indices)
|
||||
layers = []
|
||||
for i in range(1, number_of_layers + 1):
|
||||
layer = set()
|
||||
@ -638,7 +570,6 @@ class TorusCable(object):
|
||||
return True
|
||||
|
||||
elif len(self.knot_sum) == 4:
|
||||
print("\n\n\nhohohohohoho")
|
||||
upper_bounds = self.last_k_list[:3]
|
||||
ranges_list = [range(0, i + 1) for i in upper_bounds]
|
||||
ranges_list.append(range(0, 2))
|
||||
|
32
main.sage
32
main.sage
@ -1,4 +1,10 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# TBD: read about Factory Method, variable in docstring, sage documentation,
|
||||
# print calc. to output file
|
||||
# delete separation for twisted_part and untwisted_part
|
||||
# decide about printing option
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
@ -12,9 +18,6 @@ attach("my_signature.sage")
|
||||
|
||||
|
||||
|
||||
# TBD: read about Factory Method, variable in docstring, sage documentation
|
||||
|
||||
|
||||
class Config(object):
|
||||
def __init__(self):
|
||||
self.f_results = os.path.join(os.getcwd(), "results.out")
|
||||
@ -29,8 +32,6 @@ class Config(object):
|
||||
# self.knot_formula = "[[k[0], k[1], k[4]], [-k[1], -k[3]], \
|
||||
# [k[2], k[3]], [-k[0], -k[2], -k[4]]]"
|
||||
#
|
||||
#
|
||||
#
|
||||
# self.knot_formula = "[[k[3]], [-k[3]], \
|
||||
# [k[3]], [-k[3]] ]"
|
||||
#
|
||||
@ -43,29 +44,16 @@ class Config(object):
|
||||
# [-k[0], -k[1], -k[3]], [-k[2]]]"
|
||||
self.limit = 3
|
||||
|
||||
# in rch for large sigma, for 1. checked knot q_1 = 3 + start_shift
|
||||
self.start_shift = 0
|
||||
|
||||
self.verbose = True
|
||||
# self.verbose = False
|
||||
|
||||
self.print_results = True
|
||||
# self.print_results = False
|
||||
|
||||
# is the ratio restriction for values in q_vector taken into account
|
||||
self.only_slice_candidates = True
|
||||
self.only_slice_candidates = False
|
||||
|
||||
|
||||
|
||||
|
||||
def main(arg=None):
|
||||
try:
|
||||
limit = int(arg[1])
|
||||
except (IndexError, TypeError):
|
||||
limit = None
|
||||
|
||||
global cable, cab_2, cab_1, joined_formula
|
||||
global cable # , cab_2, cab_1
|
||||
# self.knot_formula = "[[k[0], k[1], k[3]], " + \
|
||||
# "[-k[1], -k[3]], " + \
|
||||
# "[k[2], k[3]], " + \
|
||||
@ -73,10 +61,7 @@ def main(arg=None):
|
||||
|
||||
# knot_formula = config.knot_formula
|
||||
# q_vector = (3, 5, 7, 13)
|
||||
# cab_to_update = TorusCable(knot_formula=knot_formula, q_vector=q_vector)
|
||||
# q_vector = (3, 5, 7, 11)
|
||||
# cab_to_add = TorusCable(knot_formula=knot_formula, q_vector=q_vector)
|
||||
# cab_shifted = cab_to_update.add_with_shift(cab_to_add)
|
||||
|
||||
# q_vector = (5, 13, 19, 41,\
|
||||
# 5, 17, 23, 43)
|
||||
@ -94,9 +79,6 @@ def main(arg=None):
|
||||
cab_2 = TorusCable(knot_formula=formula_2, q_vector=q_vector)
|
||||
cable = cab_1 + cab_2
|
||||
|
||||
joined_formula = cable.knot_formula
|
||||
# print(cable.is_signature_big_for_all_metabolizers())
|
||||
|
||||
if __name__ == '__main__':
|
||||
global config
|
||||
config = Config()
|
||||
|
Loading…
Reference in New Issue
Block a user