Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
180 views
unlisted
ubuntu2004
1
# -*- coding: utf-8 -*-
2
r"""
3
The possible different moduli.
4
"""
5
6
import numbers
7
8
# Moduli types
9
MODULI_SM = 0 # smooth (no edge, just the trivial graph)
10
MODULI_RT = 1 # rational tails (tree with genus 0 vertices but one)
11
MODULI_CT = 2 # compact type (tree with any kind of vertices)
12
MODULI_TL = 3 # tree like (tree with self-loops)
13
MODULI_ST = 4 # stable curves (general case)
14
15
_moduli_to_str = {
16
MODULI_SM: 'sm', # smooth curves
17
MODULI_RT: 'rt', # rational tails
18
MODULI_CT: 'ct', # compact type
19
MODULI_TL: 'tl', # tree like
20
MODULI_ST: 'st' # all stable curves
21
}
22
_str_to_moduli = {v: k for k, v in _moduli_to_str.items()}
23
24
25
def get_moduli(arg, default=MODULI_ST, DRpy=False):
26
if DRpy:
27
return min(3, get_moduli(arg, default))
28
if arg is None:
29
return default
30
elif isinstance(arg, str):
31
try:
32
return _str_to_moduli[arg]
33
except KeyError:
34
raise ValueError('invalid moduli {!r}'.format(arg))
35
elif isinstance(arg, numbers.Integral):
36
if arg < MODULI_SM or arg > MODULI_ST:
37
raise ValueError('invalid moduli {!r}'.format(arg))
38
return int(arg)
39
else:
40
raise TypeError("invalid moduli; must be a string 'sm', 'rt', 'ct', 'tl', or 'st' (got {!r})".format(arg))
41
42
43
def socle_degree(g, n, moduli):
44
if moduli == MODULI_ST:
45
# stable curves
46
return 3 * g - 3 + n
47
elif moduli == MODULI_TL:
48
# tree-like
49
# TODO: this is an over estimation. It is very likely that the socle dimension
50
# is smaller.
51
return 3 * g - 3 + n
52
elif moduli == MODULI_CT:
53
# compact type
54
return 2 * g - 3 + n
55
elif moduli == MODULI_RT:
56
# rational tails
57
return g - 2 + n - (g == 0)
58
elif moduli == MODULI_SM:
59
# smooth
60
return g - 1 + (g == 0) - (n == 0)
61
else:
62
raise ValueError('unknown moduli')
63
64