Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: admcycles
Views: 724
Visibility: Unlisted (only visible to those who know the link)
Image: ubuntu2004
1
from sage.rings.integer_ring import ZZ # pylint: disable=import-error
2
3
4
class Signature(object):
5
"""
6
A signature of a stratum.
7
8
Attributes:
9
sig (tuple): signature tuple
10
g (int): genus
11
n (int): total number of points
12
p (int): number of poles
13
z (int): number of zeroes
14
poles (tuple): tuple of pole orders
15
zeroes (tuple): tuple of zero orders
16
pole_ind (tuple): tuple of indices of poles
17
zero_ind (tuple): tuple of indices of zeroes
18
19
EXAMPLES::
20
21
sage: from admcycles.diffstrata.sig import Signature
22
sage: sig = Signature((2,1,-1,0)); sig
23
Signature((2, 1, -1, 0))
24
sage: sig.g
25
2
26
sage: sig.n
27
4
28
sage: sig.poles
29
(-1,)
30
sage: sig.zeroes
31
(2, 1)
32
sage: sig.pole_ind
33
(2,)
34
sage: sig.zero_ind
35
(0, 1)
36
sage: sig.p
37
1
38
sage: sig.z
39
2
40
"""
41
def __init__(self, sig):
42
"""
43
Initialise signature
44
45
Args:
46
sig (tuple): signature tuple of integers adding up to 2g-2
47
"""
48
self.sig = sig
49
sum_sig = sum(sig)
50
if sum_sig % 2:
51
raise ValueError("Error! Illegal signature: Genus not an integer")
52
self.g = int(sum_sig // 2) + 1
53
self.n = len(sig)
54
self.poles = tuple(p for p in sig if p < 0)
55
self.zeroes = tuple(z for z in sig if z > 0)
56
self.marked_points = tuple(k for k in sig if k == 0)
57
self.p = len(self.poles)
58
self.z = len(self.zeroes)
59
self.pole_ind = tuple(i for i, p in enumerate(sig) if p < 0)
60
self.zero_ind = tuple(i for i, z in enumerate(sig) if z > 0)
61
62
def __repr__(self):
63
return "Signature(%r)" % (self.sig,)
64
65
def __hash__(self):
66
return hash(self.sig)
67
68
def __eq__(self, other):
69
try:
70
return self.sig == other.sig
71
except AttributeError:
72
return False
73
74