Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

details in Zariski-Van-Kampen #37281

Merged
merged 2 commits into from
Feb 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 26 additions & 25 deletions src/sage/schemes/curves/zariski_vankampen.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
# ****************************************************************************
import itertools
from copy import copy

from sage.combinat.combination import Combinations
from sage.combinat.permutation import Permutation
from sage.functions.generalized import sign
Expand Down Expand Up @@ -165,7 +166,7 @@
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 @@ -195,9 +196,8 @@
0.2613789792873551? - 0.4527216721561923?*I,
0.2613789792873551? + 0.4527216721561923?*I)
"""
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 @@ -206,7 +206,7 @@
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 @@ -464,7 +464,7 @@
return (G, E, p, EC, DG)


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 @@ -715,7 +715,7 @@
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")

Check warning on line 718 in src/sage/schemes/curves/zariski_vankampen.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/curves/zariski_vankampen.py#L718

Added line #L718 was not covered by tests
result[qapr] = r + envelop
return result

Expand Down Expand Up @@ -847,7 +847,7 @@
sage: B = braid_in_segment(glist, p1b, p2b); B # optional - 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 @@ -908,7 +908,7 @@
return initialbraid * centralbraid * finalbraid


def geometric_basis(G, E, EC0, p, dual_graph):
def geometric_basis(G, E, EC0, p, dual_graph) -> list:
r"""
Return a geometric basis, based on a vertex.

Expand Down Expand Up @@ -982,19 +982,20 @@
if G.size() == E.size():
if E.is_cycle():
return [EC]
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
if EC[-i] in Internal:
EI = [v for v in E if v in 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 @@ -1125,7 +1126,7 @@
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)} # quitar +1 despues de revision
return (roots_base, strands)
Expand Down Expand Up @@ -1206,7 +1207,7 @@
disc = discrim(glist)
else:
disc = []
if len(disc) == 0:
if not disc:
result = []
p1 = F(0)
roots_base, strands = strand_components(g, arrangement1, p1)
Expand Down Expand Up @@ -1303,8 +1304,8 @@
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 @@ -1315,7 +1316,7 @@
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)
Comment on lines -1318 to 1322
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you can make this b = prod(A1, B.one()).

Expand Down Expand Up @@ -1378,8 +1379,8 @@
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))
Comment on lines 1379 to +1383
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- br1 = B0.delta()**r * B0(prod(B0(_) for _ in br0_left[1:]))
+ br1 = B0.delta()**r * prod(map(B0, br0_left[1:]), B0.one())

Also, do you mind renaming _ to say br or something sensible? Variable names shouldn't start with underscores if they are used.

for C in pasos:
U = [(F(a) * C.inverse()).Tietze() for a in U]
ga = F / U
Expand Down Expand Up @@ -1465,7 +1466,7 @@
"""
vertical0 = sorted(vertical)
v = len(vertical0)
if bm == []:
if not bm:
d = degree
else:
d = bm[0].parent().strands()
Expand Down Expand Up @@ -1605,7 +1606,7 @@
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 @@ -1691,15 +1692,15 @@
arrangements, even for hyperplane arrangements defined over a number
subfield of ``QQbar`` after applying a generic line section.
"""
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()
F = R.base_ring()
flist1 = [_ for _ in flist]
flist1 = list(flist)
d = f.degree(y)
while not f.coefficient(y**d) in F:
flist1 = [g.subs({x: x + y}) for g in flist1]
Expand All @@ -1709,7 +1710,7 @@
while f.degree(y) < f.degree():
flist1 = [g.subs({x: x + y}) for g in flist]
f = prod(flist1)
if len(flist1) == 0:
if not flist1:
bm = []
dic = {}
else:
Expand All @@ -1720,7 +1721,7 @@
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