First commit via PyCharm, refactor.

This commit is contained in:
Maria 2021-01-25 02:20:17 +01:00
parent 85478f7e1a
commit 30d1f40670
3 changed files with 146 additions and 97 deletions

View File

@ -1,2 +1,53 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
r"""
This package contains calculations of signature functions for knots (cable sums)
It can be run as a sage script from the terminal or used in interactive mode.
A knot (cable sum) is encoded as a list where each element (also a list)
corresponds to a cable knot, e.g. a list
[[1, 3], [2], [-1, -2], [-3]] encodes
T(2, 3; 2, 7) # T(2, 5) # -T(2, 3; 2, 5) # -T(2, 7).
To calculate the number of characters for which signature function vanish use
the function .
sage: eval_cable_for_null_signature([[1, 3], [2], [-1, -2], [-3]])
T(2, 3; 2, 7) # T(2, 5) # -T(2, 3; 2, 5) # -T(2, 7)
Zero cases: 1
All cases: 1225
Zero theta combinations:
(0, 0, 0, 0)
sage:
The numbers given to the function eval_cable_for_null_signature are k-values
for each component/cable in a direct sum.
To calculate signature function for a knot and a theta value, use function
get_signature_as_function_of_theta (see help/docstring for details).
About notation:
Cables that we work with follow a schema:
T(2, q_1; 2, q_2; 2, q_4) # -T(2, q_2; 2, q_4) #
# T(2, q_3; 2, q_4) # -T(2, q_1; 2, q_3; 2, q_4)
In knot_formula each k[i] is related with some q_i value, where
q_i = 2*k[i] + 1.
So we can work in the following steps:
1) choose a schema/formula by changing the value of knot_formula
2) set each q_i all or choose range in which q_i should varry
3) choose vector v / theata vector.
"""
from .utility import import_sage from .utility import import_sage
import os
package = __name__.split('.')[0]
path = os.path.dirname(__file__)
import_sage('signature', package=package, path=path)
# import_sage('cable_signature', package=package, path=path)
# import_sage('main', package=package, path=path)

View File

@ -15,14 +15,13 @@ SIGMA = 0
SIGNATURE = 1 SIGNATURE = 1
# ############################################################################# # #############################################################################
# 9.11 (9.8) # 9.11 (9.8)
# 9.15 (9.9) # 9.15 (9.9)
PLOTS_DIR = "../plots" PLOTS_DIR = "../plots"
class CableSummand:
class CableSummand:
def __init__(self, knot_as_k_values, verbose=False): def __init__(self, knot_as_k_values, verbose=False):
@ -135,9 +134,9 @@ class CableSummand:
else: else:
raise ValueError('k or q value must be given') raise ValueError('k or q value must be given')
counter = Counter({(2 * a + 1)/(2 * q) : -signum counter = Counter({(2 * a + 1)/(2 * q): -signum
for a in range(k)}) for a in range(k)})
counter.update(Counter({(2 * a + 1)/(2 * q) : signum counter.update(Counter({(2 * a + 1)/(2 * q): signum
for a in range(k + 1, q)})) for a in range(k + 1, q)}))
return sig.SignatureFunction(counter=counter) return sig.SignatureFunction(counter=counter)

View File

@ -20,31 +20,46 @@ package = __name__.split('.')[0]
path = os.path.dirname(__file__) path = os.path.dirname(__file__)
class Config:
def __init__(self):
self.f_results = os.path.join(os.getcwd(), "results.out") # class Config:
# def __init__(self):
# self.f_results = os.path.join(os.getcwd(), "results.out")
self.short_3_layers_a = "[[ k[5], k[3]], " + \ class Schemas:
# knot_formula = "[[k[0], k[1], k[2]],\
# [ k[3], k[4]],\
# [-k[0], -k[3], -k[4]],\
# [ -k[1], -k[2]]]"
#
# knot_formula = "[[k[0], k[1], k[2]],\
# [ k[3]],\
# [-k[0], -k[1], -k[3]],\
# [ -k[2]]]"
short_3_layers_a = "[[ k[5], k[3]], " + \
"[ -k[1], -k[3]], " + \ "[ -k[1], -k[3]], " + \
"[ k[3]], " + \ "[ k[3]], " + \
"[ -k[4], -k[6], -k[3]]]" "[ -k[4], -k[6], -k[3]]]"
self.short_3_layers_b = "[[k[4], k[1], k[7]], " + \ short_3_layers_b = "[[k[4], k[1], k[7]], " + \
"[ -k[7]], " + \
"[k[6], k[7]], " + \
"[-k[5], -k[7]]]"
self.schema_short1 = "[ [k[5], k[3]], " + \
"[ -k[1], -k[3]], " + \
"[ k[3]], " + \
"[ -k[6], -k[3]]]"
self.schema_short2 = "[[ k[1], k[7]], " + \
"[ -k[7]], " + \ "[ -k[7]], " + \
"[ k[6], k[7]], " + \ "[ k[6], k[7]], " + \
"[ -k[5], -k[7]]]" "[ -k[5], -k[7]]]"
self.schema_short = "[[ k[5], k[3]], " + \ schema_short1 = "[ [k[5], k[3]], " + \
"[ -k[1], -k[3]], " + \
"[ k[3]], " + \
"[ -k[6], -k[3]]]"
schema_short2 = "[[ k[1], k[7]], " + \
"[ -k[7]], " + \
"[ k[6], k[7]], " + \
"[ -k[5], -k[7]]]"
schema_short = "[[ k[5], k[3]], " + \
"[ -k[1], -k[3]], " + \ "[ -k[1], -k[3]], " + \
"[ k[3]], " + \ "[ k[3]], " + \
"[ -k[6], -k[3]], " + \ "[ -k[6], -k[3]], " + \
@ -53,53 +68,40 @@ class Config:
"[ k[6], k[7]], " + \ "[ k[6], k[7]], " + \
"[ -k[5], -k[7]]]" "[ -k[5], -k[7]]]"
# two_summands_schema = "[ [k[0], k[1], k[4]], [-k[1], -k[3]],\
# [k[2], k[3]], [-k[0], -k[2], -k[4]] ]"
# two_small_summands_schema = "[[k[3]], [-k[3]],\
# [k[3]], [-k[3]] ]"
#
# four_summands_schema = "[[k[3], k[2], k[0]],\
# [ -k[2], -k[0]],\
# [ k[1], k[0]],\
# [-k[3], -k[1], -k[0]]]"
#
four_summands_schema = "[[ k[0], k[1], k[3]]," + \
"[ -k[1], -k[3]]," + \
"[ k[2], k[3]]," + \
"[ -k[0], -k[2], -k[3]]]"
self.two_summands_schema = "[\ # formula_1 = "[[ k[0], k[5], k[3]], " + \
[k[0], k[1], k[4]], [-k[1], -k[3]],\ # "[ -k[1], -k[3]], " + \
[k[2], k[3]], [-k[0], -k[2], -k[4]]\ # "[ k[2], k[3]], " + \
]" # "[ -k[0], -k[2], -k[3]]]"
knot_formula = "[[k[0], k[1], k[2]], [k[3], k[4]],\ #
[-k[0], -k[3], -k[4]], [-k[1], -k[2]]]" # formula_2 = "[[ k[4], k[1], k[7]], " + \
# "[ -k[5], -k[7]], " + \
knot_formula = "[[k[0], k[1], k[2]], [k[3]],\ # "[ k[6], k[7]], " + \
[-k[0], -k[1], -k[3]], [-k[2]]]" # "[ -k[4], -k[6], -k[7]]]"
#
# formula_1 = "[[ k[0], k[5], k[3]], " + \
# "[ -k[5], -k[3]], " + \
self.two_small_summands_schema = "[[k[3]], [-k[3]],\ # "[ k[2], k[3]], " + \
[k[3]], [-k[3]] ]" # "[-k[4], -k[2], -k[3]]]"
#
self.four_summands_schema = "[[k[3], k[2], k[0]],\ # formula_2 = "[[ k[4], k[1], k[7]], " + \
[-k[2], -k[0]],\ # "[ -k[1], -k[7]], " + \
[k[1], k[0]],\ # "[ k[6], k[7]], " + \
[-k[3], -k[1], -k[0]]]" # "[-k[0], -k[6], -k[7]]]"
self.four_summands_schema = "[[k[0], k[1], k[3]]," + \
" [-k[1], -k[3]]," + \
" [k[2], k[3]]," + \
" [-k[0], -k[2], -k[3]]]"
formula_1 = "[[k[0], k[5], k[3]], " + \
"[-k[1], -k[3]], " + \
"[k[2], k[3]], " + \
"[-k[0], -k[2], -k[3]]]"
formula_2 = "[[k[4], k[1], k[7]], " + \
"[-k[5], -k[7]], " + \
"[k[6], k[7]], " + \
"[-k[4], -k[6], -k[7]]]"
formula_1 = "[[k[0], k[5], k[3]], " + \
"[-k[5], -k[3]], " + \
"[k[2], k[3]], " + \
"[-k[4], -k[2], -k[3]]]"
formula_2 = "[[k[4], k[1], k[7]], " + \
"[-k[1], -k[7]], " + \
"[k[6], k[7]], " + \
"[-k[0], -k[6], -k[7]]]"
def main(arg=None): def main(arg=None):
@ -110,13 +112,13 @@ def main(arg=None):
conf = Config() conf = Config()
cable_loop_with_details(conf) cable_loop_with_details(conf)
def print_sigma_for_cable(verbose=True, conf=None):
conf = conf or Config() def print_sigma_for_cable(verbose=True, Schemas=None):
schema_short1 = conf.schema_short1
schema_short2 = conf.schema_short2 schema_short1 = Schemas.schema_short1
schema_short = conf.schema_short schema_short2 = Schemas.schema_short2
schema_four = conf.four_summands_schema schema_short = Schemas.schema_short
schema_four = Schemas.four_summands_schema
cable_template = cs.CableTemplate(knot_formula=schema_short) cable_template = cs.CableTemplate(knot_formula=schema_short)
cable_template.fill_q_vector() cable_template.fill_q_vector()
@ -141,12 +143,11 @@ def print_sigma_for_cable(verbose=True, conf=None):
# cable2.plot_sigma_for_summands() # cable2.plot_sigma_for_summands()
def cable_loop_with_details(verbose=True, conf=None): def cable_loop_with_details(verbose=True):
conf = conf or Config()
# verbose = False # verbose = False
schema_short1 = conf.schema_short1 schema_short1 = Schemas.schema_short1
schema_short2 = conf.schema_short2 schema_short2 = Schemas.schema_short2
schema_short = conf.schema_short schema_short = Schemas.schema_short
cable_template = cs.CableTemplate(knot_formula=schema_short) cable_template = cs.CableTemplate(knot_formula=schema_short)
list_of_q_vectors = [] list_of_q_vectors = []
@ -174,12 +175,12 @@ def cable_loop_with_details(verbose=True, conf=None):
print("sigma is not big for all metabolizers") print("sigma is not big for all metabolizers")
print("\n" * 3) print("\n" * 3)
def few_cable_without_calc(verbose=False, conf=None):
conf = conf or Config() def few_cable_without_calc(verbose=False):
schema_short1 = conf.schema_short1
schema_short2 = conf.schema_short2 schema_short1 = Schemas.schema_short1
schema_short = conf.schema_short schema_short2 = Schemas.schema_short2
schema_short = Schemas.schema_short
cable_template = cs.CableTemplate(knot_formula=schema_short) cable_template = cs.CableTemplate(knot_formula=schema_short)
@ -205,12 +206,12 @@ def few_cable_without_calc(verbose=False, conf=None):
print("sigma is not big for all metabolizers") print("sigma is not big for all metabolizers")
print("\n" * 3) print("\n" * 3)
def smallest_cable(verbose=True, conf=None):
conf = conf or Config() def smallest_cable(verbose=True):
schema_short1 = conf.schema_short1
schema_short2 = conf.schema_short2 schema_short1 = Schemas.schema_short1
schema_short = conf.schema_short schema_short2 = Schemas.schema_short2
schema_short = Schemas.schema_short
cable_template = cs.CableTemplate(knot_formula=schema_short) cable_template = cs.CableTemplate(knot_formula=schema_short)
@ -225,6 +226,7 @@ def smallest_cable(verbose=True, conf=None):
cable1.is_function_big_for_all_metabolizers(invariant=sigma) cable1.is_function_big_for_all_metabolizers(invariant=sigma)
cable2.is_function_big_for_all_metabolizers(invariant=sigma) cable2.is_function_big_for_all_metabolizers(invariant=sigma)
def plot_many_untwisted_signature_functions(range_tuple=(1, 10)): def plot_many_untwisted_signature_functions(range_tuple=(1, 10)):
P = Primes() P = Primes()
for i in range(*range_tuple): for i in range(*range_tuple):
@ -234,8 +236,6 @@ def plot_many_untwisted_signature_functions(range_tuple=(1, 10)):
if __name__ == '__main__': if __name__ == '__main__':
global config
config = Config()
if '__file__' in globals(): if '__file__' in globals():
# skiped in interactive mode as __file__ is not defined # skiped in interactive mode as __file__ is not defined
main(sys.argv) main(sys.argv)
@ -243,8 +243,7 @@ if __name__ == '__main__':
pass pass
# main() # main()
#
#
# formula_long = "[[k[0], k[5], k[3]], " + \ # formula_long = "[[k[0], k[5], k[3]], " + \
# "[-k[5], -k[3]], " + \ # "[-k[5], -k[3]], " + \
# "[k[2], k[3]], " + \ # "[k[2], k[3]], " + \