Skip to content

Commit

Permalink
changes following sagemath#37281
Browse files Browse the repository at this point in the history
  • Loading branch information
enriqueartal committed Feb 11, 2024
1 parent 73a728d commit 3cbafec
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 48 deletions.
4 changes: 2 additions & 2 deletions src/sage/schemes/curves/plane_curve_arrangement.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def fundamental_group(self, simplified=True, vertical=True,
bm = self._braid_monodromy_vertical
else:
bm = self._braid_monodromy_non_vertical
if bm is not None:
if bm is not None: # bm could be []
if not vertical:
st = self._strands_nonvertical
d1 = prod(L).degree()
Expand Down Expand Up @@ -601,7 +601,7 @@ def meridians(self, simplified=True, vertical=True):
computed = self._meridians_nonsimpl_nonvertical
if computed:
return computed
_ = self.fundamental_group(simplified=simplified, vertical=vertical)
self.fundamental_group(simplified=simplified, vertical=vertical)
if simplified and vertical:
return self._meridians_simpl_vertical
elif simplified and not vertical:
Expand Down
91 changes: 45 additions & 46 deletions src/sage/schemes/curves/zariski_vankampen.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def sgn(x, y):
return B(braid)


def discrim(pols):
def discrim(pols) -> tuple:
r"""
Return the points in the discriminant of the product of the polynomials
of a list or tuple ``pols``.
Expand Down Expand Up @@ -198,9 +198,8 @@ def discrim(pols):
0.2613789792873551? + 0.4527216721561923?*I,
1]
"""
flist = tuple(pols)
x, y = flist[0].parent().gens()
field = flist[0].base_ring()
x, y = pols[0].parent().gens()
field = pols[0].base_ring()
pol_ring = PolynomialRing(field, (x,))

@parallel
Expand All @@ -209,8 +208,8 @@ def discrim_pairs(f, g):
return pol_ring(f.discriminant(y))
return pol_ring(f.resultant(g, y))

pairs = [(f, None) for f in flist] + [(f, g) for f, g
in Combinations(flist, 2)]
pairs = [(f, None) for f in pols] + [tuple(t) for t
in Combinations(pols, 2)]
fdiscrim = discrim_pairs(pairs)
rts = ()
poly = 1
Expand Down Expand Up @@ -484,7 +483,7 @@ def voronoi_cells(V, vertical_lines=frozenset()):
return (G, E, p, EC, DG, vertical_regions)


def followstrand(f, factors, x0, x1, y0a, prec=53):
def followstrand(f, factors, x0, x1, y0a, prec=53) -> list:
r"""
Return a piecewise linear approximation of the homotopy continuation
of the root ``y0a`` from ``x0`` to ``x1``.
Expand Down Expand Up @@ -751,7 +750,7 @@ def roots_interval(f, x0):
envelop = IF(diam) * IF((-1, 1), (-1, 1))
qapr = QQ(CF(r).real()) + QQbar.gen() * QQ(CF(r).imag())
if qapr not in r + envelop:
raise ValueError("Could not approximate roots with exact values")
raise ValueError("could not approximate roots with exact values")
result[qapr] = r + envelop
return result

Expand Down Expand Up @@ -839,7 +838,7 @@ def braid_in_segment(glist, x0, x1, precision={}):
- ``glist`` -- a tuple of polynomials in two variables
- ``x0`` -- a Gauss rational
- ``x1`` -- a Gauss rational
- ``precision`` -- a dictionary (default: `dict()`) which assigns a number
- ``precision`` -- a dictionary (default: `{}`) which assigns a number
precision bits to each element of ``glist``
OUTPUT:
Expand Down Expand Up @@ -882,7 +881,7 @@ def braid_in_segment(glist, x0, x1, precision={}):
sage: B = braid_in_segment(glist, p1b, p2b); B # needs sirocco
s5*s3^-1
"""
precision1 = {_: precision[_] for _ in precision.keys()}
precision1 = precision.copy()
g = prod(glist)
F1 = g.base_ring()
x, y = g.parent().gens()
Expand Down Expand Up @@ -946,7 +945,7 @@ def braid_in_segment(glist, x0, x1, precision={}):
return initialbraid * centralbraid * finalbraid


def geometric_basis(G, E, EC0, p, dual_graph, vertical_regions={}):
def geometric_basis(G, E, EC0, p, dual_graph, vertical_regions={}) -> list:
r"""
Return a geometric basis, based on a vertex.
Expand Down Expand Up @@ -1016,18 +1015,18 @@ def geometric_basis(G, E, EC0, p, dual_graph, vertical_regions={}):
if j in vertical_regions:
vd = {j: 0}
else:
vd = dict()
vd = {}
return [EC], vd
InternalEdges = [_ for _ in G.edges(sort=True) if _ not in
E.edges(sort=True)]
edges_E = E.edges(sort=True)
InternalEdges = [e for e in G.edges(sort=True) if e not in edges_E]
InternalVertices = [v for e in InternalEdges for v in e[:2]]
Internal = G.subgraph(vertices=InternalVertices, edges=InternalEdges)
for i, ECi in enumerate(EC): # q and r are the points we will cut through
if ECi in Internal:
EI = [v for v in E if v in
Internal.connected_component_containing_vertex(ECi, sort=True)
and v != ECi]
if len(EI) > 0:
if EI:
q = ECi
connecting_path = list(EC[:i])
break
Expand All @@ -1036,7 +1035,7 @@ def geometric_basis(G, E, EC0, p, dual_graph, vertical_regions={}):
Internal.connected_component_containing_vertex(EC[-i],
sort=True)
and v != EC[-i]]
if len(EI) > 0:
if EI:
q = EC[-i]
connecting_path = list(reversed(EC[-i:]))
break
Expand Down Expand Up @@ -1135,14 +1134,14 @@ def geometric_basis(G, E, EC0, p, dual_graph, vertical_regions={}):
return (resul, vd)


def vertical_lines_in_braidmon(flist):
def vertical_lines_in_braidmon(pols) -> list:
r"""
Returns the vertical lines in ``flist``, unless
Returns the vertical lines in ``pols``, unless
one of the other components has a vertical asymptote.
INPUT:
- ``flist`` -- a list of polynomials with two variables whose
- ``pols`` -- a list of polynomials with two variables whose
product equals ``f``
OUTPUT:
Expand All @@ -1164,10 +1163,10 @@ def vertical_lines_in_braidmon(flist):
sage: vertical_lines_in_braidmon([])
[]
"""
if not flist:
if not pols:
return []
res = []
for j, f in enumerate(flist):
for j, f in enumerate(pols):
C = Curve(f)
vertical_asymptote = C.has_vertical_asymptote()
if vertical_asymptote:
Expand All @@ -1177,7 +1176,7 @@ def vertical_lines_in_braidmon(flist):
return res


def strand_components(f, flist, p1):
def strand_components(f, pols, p1):
r"""
Compute only the assignment from strands to elements of ``flist``.
Expand All @@ -1186,7 +1185,7 @@ def strand_components(f, flist, p1):
- ``f`` -- a reduced polynomial with two variables, over a number field
with an embedding in the complex numbers
- ``flist`` -- a list of polynomials with two variables whose
- ``pols`` -- a list of polynomials with two variables whose
product equals ``f``
- ``p1`` -- a Gauss rational
Expand All @@ -1211,14 +1210,14 @@ def strand_components(f, flist, p1):
(1, 0), (1.333333333333334?, 1)], {0: 0, 1: 0, 2: 0, 3: 1})
"""
x, y = f.parent().gens()
F = flist[0].base_ring()
F = pols[0].base_ring()
strands = {}
roots_base = []
for i, h in enumerate(flist):
for i, h in enumerate(pols):
h0 = h.subs({x: p1})
h1 = F[y](h0)
rt = h1.roots(QQbar, multiplicities=False)
roots_base += [(_, i) for _ in rt]
roots_base += [(r, i) for r in rt]
roots_base.sort()
strands = {i: par[1] for i, par in enumerate(roots_base)}
return (roots_base, strands)
Expand Down Expand Up @@ -1299,10 +1298,10 @@ def braid_monodromy(f, arrangement=(), vertical=False):
F = fieldI(f.base_ring())
I1 = F(QQbar.gen())
f = f.change_ring(F)
if arrangement == ():
if not arrangement:
arrangement1 = (f,)
else:
arrangement1 = tuple(_.change_ring(F) for _ in arrangement)
arrangement1 = tuple(g.change_ring(F) for g in arrangement)
x, y = f.parent().gens()
if vertical:
indices_v = vertical_lines_in_braidmon(arrangement1)
Expand All @@ -1312,7 +1311,7 @@ def braid_monodromy(f, arrangement=(), vertical=False):
if j not in indices_v)
arrangement_v = tuple(f0 for j, f0 in enumerate(arrangement1)
if j in indices_v)
glist = tuple(_[0] for f0 in arrangement_h for _ in f0.factor())
glist = tuple(fc[0] for f0 in arrangement_h for fc in f0.factor())
g = f.parent()(prod(glist))
d = g.degree(y)
if not arrangement_v: # change of coordinates only if indices_v is empty
Expand All @@ -1326,8 +1325,8 @@ def braid_monodromy(f, arrangement=(), vertical=False):
disc = discrim(glist)
else:
disc = []
vertical_braid = dict()
transversal = dict()
vertical_braid = {}
transversal = {}
vl = []
for f0 in arrangement_v:
pt = [j for j, t in enumerate(disc) if f0.subs({x: t}) == 0]
Expand All @@ -1349,20 +1348,20 @@ def braid_monodromy(f, arrangement=(), vertical=False):
p1 = F(0)
if d > 0:
roots_base, strands = strand_components(g, arrangement_h, p1)
strands1 = dict()
strands1 = {}
for j in range(d):
i = strands[j]
k = arrangement1.index(arrangement_h[i])
strands1[j] = k
else:
strands1 = dict()
strands1 = {}
return (result, strands1, vertical_braids, d)
V = corrected_voronoi_diagram(tuple(disc))
G, E, p, EC, DG, VR = voronoi_cells(V, vertical_lines=vl)
p0 = (p[0], p[1])
p1 = p0[0] + I1 * p0[1]
roots_base, strands = strand_components(g, arrangement_h, p1)
strands1 = dict()
strands1 = {}
for j in range(d):
i = strands[j]
k = arrangement1.index(arrangement_h[i])
Expand Down Expand Up @@ -1403,7 +1402,7 @@ def braid_monodromy(f, arrangement=(), vertical=False):
x1 = tuple(path[i + 1].vector())
braidpath = braidpath * segsbraids[(x0, x1)]
result.append(braidpath)
vertical_braids = dict()
vertical_braids = {}
r = len(result)
t = 0
for f0 in arrangement_v:
Expand Down Expand Up @@ -1465,8 +1464,8 @@ def conjugate_positive_form(braid):
cuts = [j for j in range(d + 1) if j not in gns]
blocks = []
for i in range(len(cuts) - 1):
block = [j for j in L1 if j > cuts[i] and j < cuts[i + 1]]
if len(block) > 0:
block = [j for j in L1 if cuts[i] < j < cuts[i + 1]]
if block:
blocks.append(block)
shorts = []
for a in blocks:
Expand All @@ -1477,7 +1476,7 @@ def conjugate_positive_form(braid):
A1 = rightnormalform(sg)
par = A1[-1][0] % 2
A1 = [B(a) for a in A1[:-1]]
if len(A1) == 0:
if not A1:
b = B.one()
else:
b = prod(A1)
Expand Down Expand Up @@ -1540,8 +1539,8 @@ def braid2rels(L):
br1 = B0.delta()**r * B0(prod(B0(_) for _ in br0_left[1:]))
cox = prod(F0.gens())
U0 = [cox**q * (f0 * br1) / cox**q / f0 for f0 in F0.gens()[:-1]]
U = [tuple(sign(k1)*(abs(k1) + k) for k1 in _.Tietze()) for _ in U0]
pasos = [B.one()] + [_ for _ in reversed(L1)]
U = [tuple(sign(k1) * (abs(k1) + k) for k1 in _.Tietze()) for _ in U0]
pasos = [B.one()] + list(reversed(L1))
for C in pasos:
U = [(F(a) * C.inverse()).Tietze() for a in U]
ga = F / U
Expand Down Expand Up @@ -1632,7 +1631,7 @@ def fundamental_group_from_braid_mon(bm, degree=None,
"""
vertical0 = sorted(vertical)
v = len(vertical0)
if bm == []:
if not bm:
d = degree
elif bm[0].parent().order() == 1:
d = 1
Expand Down Expand Up @@ -1776,7 +1775,7 @@ def fundamental_group(f, simplified=True, projective=False, puiseux=True):
while g.degree(y) < g.degree():
g = g.subs({x: x + y})
bm = braid_monodromy(g)[0]
if bm == []:
if not bm:
d = g.degree(y)
else:
d = bm[0].parent().strands()
Expand Down Expand Up @@ -1886,14 +1885,14 @@ def fundamental_group_arrangement(flist, simplified=True, projective=False,
x1*x2*x0*x1^-1*x0^-1*x2^-1 >,
{0: [x2], 1: [x0], 2: [x3], 3: [x1], 4: [x3^-1*x2^-1*x1^-1*x0^-1]})
"""
if len(flist) > 0:
if flist:
f = prod(flist)
R = f.parent()
else:
R = PolynomialRing(QQ, ('x', 'y'))
f = R(1)
x, y = R.gens()
flist1 = [_ for _ in flist]
flist1 = tuple(list(flist).copy())
if vertical and vertical_lines_in_braidmon(flist1):
infinity = all([Curve(g).is_vertical_line() or
g.degree(y) == g.degree() for g in flist1])
Expand All @@ -1904,7 +1903,7 @@ def fundamental_group_arrangement(flist, simplified=True, projective=False,
infinity = all([g.degree(y) == g.degree() for g in flist1])
if braid_data:
bm, dic, dv, d1 = braid_data
elif len(flist1) == 0:
elif not flist:
bm = []
dic = {}
dv = {j: j for j, f in flist1}
Expand All @@ -1924,7 +1923,7 @@ def fundamental_group_arrangement(flist, simplified=True, projective=False,
else:
hom = g.hom(codomain=g, im_gens=list(g.gens()), check=False)
g1 = hom.codomain()
if len(flist) == 0:
if not flist:
return (g1, {})
dic1 = {}
for i in range(len(flist1)):
Expand Down

0 comments on commit 3cbafec

Please sign in to comment.