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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid using "is_prime_field" in dynamics #38925

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/sage/dynamics/arithmetic_dynamics/affine_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- Ben Hutz (2017) relocate code and create new class
"""

#*****************************************************************************
# ****************************************************************************
# Copyright (C) 2011 Volker Braun <[email protected]>
# Copyright (C) 2006 David Kohel <[email protected]>
# Copyright (C) 2006 William Stein <[email protected]>
Expand All @@ -34,8 +34,8 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************
# https://www.gnu.org/licenses/
# ****************************************************************************

from sage.categories.fields import Fields
from sage.dynamics.arithmetic_dynamics.generic_ds import DynamicalSystem
Expand Down Expand Up @@ -255,7 +255,7 @@
if isinstance(R, FiniteField):
return DynamicalSystem_affine_finite_field(polys, domain)
return DynamicalSystem_affine_field(polys, domain)
elif isinstance(morphism_or_polys,(list, tuple)):
elif isinstance(morphism_or_polys, (list, tuple)):
polys = list(morphism_or_polys)
else:
polys = [morphism_or_polys]
Expand Down Expand Up @@ -321,7 +321,7 @@
L = polys_or_rat_fncts
# Next attribute needed for _fast_eval and _fastpolys
R = L[0].base_ring()
self._is_prime_finite_field = isinstance(R, FiniteField) and R.is_prime_field()
self._is_prime_finite_field = isinstance(R, FiniteField) and R.degree() == 1
DynamicalSystem.__init__(self, L, domain)

def __copy__(self):
Expand Down Expand Up @@ -535,15 +535,15 @@
if isinstance(F.parent(), sage.rings.abc.SymbolicRing):
from sage.symbolic.ring import var
u = var(self.domain().coordinate_ring().variable_name())
return F.subs({F.variables()[0]:u,F.variables()[1]:1})
return F.subs({F.variables()[0]: u, F.variables()[1]: 1})

Check warning on line 538 in src/sage/dynamics/arithmetic_dynamics/affine_ds.py

View check run for this annotation

Codecov / codecov/patch

src/sage/dynamics/arithmetic_dynamics/affine_ds.py#L538

Added line #L538 was not covered by tests
elif T(F.denominator()).degree() == 0:
R = F.parent()
phi = R.hom([S.gen(0), 1], S)
return phi(F)
else:
R = F.numerator().parent()
phi = R.hom([S.gen(0), 1], S)
return phi(F.numerator())/phi(F.denominator())
return phi(F.numerator()) / phi(F.denominator())

def nth_iterate_map(self, n):
r"""
Expand Down Expand Up @@ -612,8 +612,8 @@
for i in range(len(D)):
for k in range(D[i]):
PHI = [poly(F) for poly in PHI]
if i != len(D)-1: #avoid extra iterate
F = [R(poly(F)) for poly in F] #'square'
if i != len(D) - 1: # avoid extra iterate
F = [R(poly(F)) for poly in F] # 'square'
return DynamicalSystem_affine(PHI, domain=self.domain())

def nth_iterate(self, P, n):
Expand Down Expand Up @@ -724,11 +724,11 @@
if isinstance(n, (list, tuple)):
bounds = list(n)
else:
bounds = [0,n]
for i in range(1, bounds[0]+1):
bounds = [0, n]
for i in range(1, bounds[0] + 1):
Q = self(Q)
orb = [Q]
for i in range(bounds[0]+1, bounds[1]+1):
for i in range(bounds[0] + 1, bounds[1] + 1):
Q = self(Q)
orb.append(Q)
return orb
Expand Down Expand Up @@ -802,7 +802,7 @@
J = self.jacobian()
for i in range(0, n):
R = self(Q)
l = J(tuple(Q))*l #chain rule matrix multiplication
l = J(tuple(Q)) * l # chain rule matrix multiplication
Q = R
return l

Expand Down
2 changes: 1 addition & 1 deletion src/sage/dynamics/arithmetic_dynamics/projective_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def __init__(self, polys, domain):
"""
# Next attribute needed for _fast_eval and _fastpolys
R = polys[0].base_ring()
self._is_prime_finite_field = isinstance(R, FiniteField) and R.is_prime_field()
self._is_prime_finite_field = isinstance(R, FiniteField) and R.degree() == 1
DynamicalSystem.__init__(self, polys, domain)

def __copy__(self):
Expand Down
Loading