Skip to content

Commit

Permalink
Trac #28972: some details about all(...) and return
Browse files Browse the repository at this point in the history
URL: https://trac.sagemath.org/28972
Reported by: chapoton
Ticket author(s): Frédéric Chapoton
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager committed Jan 15, 2020
2 parents 6fa6de6 + 3b38acf commit e13339b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
44 changes: 23 additions & 21 deletions src/sage/dynamics/arithmetic_dynamics/projective_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class initialization directly.
from sage.combinat.subset import Subsets
from sage.symbolic.ring import SR


class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space,
DynamicalSystem):
r"""A dynamical system of projective schemes determined by homogeneous
Expand Down Expand Up @@ -486,7 +487,7 @@ def _number_field_from_algebraics(self):
r"""
Return a dynamical system defined over the number field of its coefficients.
OTUPUT: dynamical system.
OUTPUT: dynamical system.
EXAMPLES::
Expand Down Expand Up @@ -1321,7 +1322,7 @@ def orbit(self, P, N, **kwds):
if N[0] < 0 or N[1] < 0:
raise TypeError("orbit bounds must be non-negative")
if N[0] > N[1]:
return([])
return []

R = self.domain()(P)
if R in self.domain(): #Check whether R is a zero-dimensional point
Expand All @@ -1342,7 +1343,7 @@ def orbit(self, P, N, **kwds):
if normalize:
Q.normalize_coordinates()
orb.append(Q)
return(orb)
return orb

def resultant(self, normalize=False):
r"""
Expand Down Expand Up @@ -1415,7 +1416,7 @@ def resultant(self, normalize=False):
try:
res = (f.lc() ** (d - g.degree()) * g.lc() ** (d - f.degree())
* f.__pari__().polresultant(g, x))
return(self.domain().base_ring()(res))
return self.domain().base_ring()(res)
except (TypeError, PariError):
pass
#Otherwise, use Macaulay
Expand Down Expand Up @@ -1541,7 +1542,7 @@ def primes_of_bad_reduction(self, check=True):
badprimes.pop(index)
else:
index += 1
return(badprimes)
return badprimes
else:
raise TypeError("base ring must be number field or number field ring")

Expand Down Expand Up @@ -2165,7 +2166,7 @@ def height_difference_bound(self, prec=None):
maxh = max(maxh, val[1])
L = abs(R(gcdRes).log() - R((N + 1) * binomial(N + D - d, D - d)).log() - maxh)
C = max(U, L) #height difference dh(P) - L <= h(f(P)) <= dh(P) +U
return(C / (d - 1))
return C / (d - 1)

def multiplier(self, P, n, check=True):
r"""
Expand Down Expand Up @@ -2330,7 +2331,7 @@ def _multipliermod(self, P, n, p, k):
F = self.dehomogenize((indexlist[i],indexlist[i+1]))
l = (F.jacobian()(tuple(Q.dehomogenize(indexlist[i])))*l) % (p ** k)
Q = R
return(l)
return l

def _nth_preimage_tree_helper(self, Q, n, m, **kwds):
r"""
Expand Down Expand Up @@ -2677,7 +2678,7 @@ def _preperiodic_points_to_cyclegraph(self, preper):
E.append([Q])
from sage.graphs.digraph import DiGraph
g = DiGraph(dict(zip(V, E)), loops=True)
return(g)
return g

def is_PGL_minimal(self, prime_list=None):
r"""
Expand Down Expand Up @@ -3169,11 +3170,11 @@ def automorphism_group(self, **kwds):
from .endPN_automorphism_group import automorphism_group_QQ_CRT, automorphism_group_QQ_fixedpoints
if alg is None:
if self.degree() <= 12:
return(automorphism_group_QQ_fixedpoints(F, return_functions, iso_type))
return(automorphism_group_QQ_CRT(F, p, return_functions, iso_type))
return automorphism_group_QQ_fixedpoints(F, return_functions, iso_type)
return automorphism_group_QQ_CRT(F, p, return_functions, iso_type)
elif alg == 'CRT':
return(automorphism_group_QQ_CRT(F, p, return_functions, iso_type))
return(automorphism_group_QQ_fixedpoints(F, return_functions, iso_type))
return automorphism_group_QQ_CRT(F, p, return_functions, iso_type)
return automorphism_group_QQ_fixedpoints(F, return_functions, iso_type)

def critical_subscheme(self):
r"""
Expand Down Expand Up @@ -3388,7 +3389,7 @@ def is_postcritically_finite(self, err=0.01, use_algebraic_closure=True):
if crit_points[i].is_preperiodic(F, err) == False:
pcf = False
i += 1
return(pcf)
return pcf

def critical_point_portrait(self, check=True, use_algebraic_closure=True):
r"""
Expand Down Expand Up @@ -3501,7 +3502,7 @@ def critical_point_portrait(self, check=True, use_algebraic_closure=True):
else:
crit_points.append(Q)
Q = F(Q)
return(F._preperiodic_points_to_cyclegraph(crit_points))
return F._preperiodic_points_to_cyclegraph(crit_points)

def critical_height(self, **kwds):
r"""
Expand Down Expand Up @@ -3792,7 +3793,7 @@ def preperiodic_points(self, m, n, **kwds):
points = [dom(Q) for Q in X.rational_points()]
good_points = []
for Q in points:
#check if point is in indeterminacy
# check if point is in indeterminacy
if not all(F(list(Q)) == 0 for F in f):
good_points.append(Q)
points = good_points
Expand All @@ -3807,7 +3808,7 @@ def preperiodic_points(self, m, n, **kwds):
orbit = [P]
Q = f(P)
n_plus_m = 1
while not Q in orbit:
while Q not in orbit:
orbit.append(Q)
Q = f(Q)
n_plus_m += 1
Expand Down Expand Up @@ -4024,7 +4025,7 @@ def periodic_points(self, n, minimal=True, R=None, algorithm='variety',
else:
if n % m == 0:
points = points + cycle[:-1]
return(points)
return points
else:
raise TypeError("ring must be finite to generate cyclegraph")
elif algorithm == 'variety':
Expand Down Expand Up @@ -4949,14 +4950,15 @@ def _is_preperiodic(self, P, err=0.1, return_period=False):
if H <= B: #it must have been in the cycle
if return_period:
m = orbit.index(Q)
return((m, n-m))
return (m, n - m)
else:
return True
if return_period:
return (0,0)
else:
return False


class DynamicalSystem_projective_field(DynamicalSystem_projective,
SchemeMorphism_polynomial_projective_space_field):

Expand Down Expand Up @@ -5161,7 +5163,7 @@ def lift_to_rational_periodic(self, points_modp, B=None):
done = True
k += 1

return(good_points)
return good_points

def all_periodic_points(self, **kwds):
r"""
Expand Down Expand Up @@ -5815,7 +5817,7 @@ def all_preperiodic_points(self, **kwds):
periods = DS.possible_periods(prime_bound=primebound,
bad_primes=badprimes, ncpus=num_cpus)
if periods == []:
return([]) #no rational preperiodic points
return [] #no rational preperiodic points
else:
p = kwds.pop("lifting_prime", 23)
#find the rational preperiodic points
Expand Down Expand Up @@ -7229,7 +7231,7 @@ def automorphism_group(self, absolute=False, iso_type=False, return_functions=Fa
else:
F = f[0].numerator().polynomial(z)
from .endPN_automorphism_group import automorphism_group_FF
return(automorphism_group_FF(F, absolute, iso_type, return_functions))
return automorphism_group_FF(F, absolute, iso_type, return_functions)

def all_periodic_points(self, **kwds):
r"""
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/function_field/place.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,8 @@ def _residue_field(self, name=None):
To: Number Field in s with defining polynomial x^2 - 2*x + 2)]
sage: for p in L.places_above(I.place()):
....: k, fr_k, to_k = p.residue_field()
....: assert all([fr_k(k(e)) == e for e in range(10)])
....: assert all([to_k(fr_k(e)) == e for e in [k.random_element() for i in [1..10]]])
....: assert all(fr_k(k(e)) == e for e in range(10))
....: assert all(to_k(fr_k(e)) == e for e in [k.random_element() for i in [1..10]])
::
Expand Down

0 comments on commit e13339b

Please sign in to comment.