Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
19552: remove duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
bhutz committed Dec 9, 2015
1 parent ab4c42d commit 1ee5379
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 31 deletions.
14 changes: 3 additions & 11 deletions src/sage/schemes/generic/algebraic_scheme.py
Expand Up @@ -130,7 +130,6 @@
# class AlgebraicScheme_subscheme_affine_toric
# class AlgebraicScheme_quasi

from copy import copy
from sage.categories.number_fields import NumberFields

from sage.rings.all import ZZ
Expand Down Expand Up @@ -2295,7 +2294,7 @@ def orbit(self, f, N):
Orb.append(Q)
return(Orb)

def nth_iterate(self, f, n , **kwds):
def nth_iterate(self, f, n):
r"""
The nth forward image of this scheme by the map ``f``.
Expand Down Expand Up @@ -2354,15 +2353,10 @@ def nth_iterate(self, f, n , **kwds):
...
TypeError: Attempt to coerce non-integral RealNumber to Integer
"""
if not f.is_endomorphism():
raise TypeError("map must be an endomorphism for iteration")
n = ZZ(n)
if n < 0:
raise TypeError("must be a forward orbit")
Q = self
for i in range(n):
Q = f(Q)
return Q
return self.orbit(f,[n,n+1])[0]

def _forward_image(self, f):
"""
Expand Down Expand Up @@ -2574,9 +2568,7 @@ def preimage(self, f):
if self.ambient_space() != codom:
raise TypeError("subscheme must be in ambient space of codomain")
R = codom.coordinate_ring()
dict = {}
for i in range(codom.dimension_relative()+1):
dict.update({R.gen(i): f[i]})
dict = {R.gen(i): f[i] for i in range(codom.dimension_relative()+1)}
return(dom.subscheme([t.subs(dict) for t in self.defining_polynomials()]))

class AlgebraicScheme_subscheme_product_projective(AlgebraicScheme_subscheme_projective):
Expand Down
23 changes: 3 additions & 20 deletions src/sage/schemes/projective/projective_point.py
Expand Up @@ -683,14 +683,10 @@ def nth_iterate(self,f, n, **kwds):
sage: P2.<u,v,w> = ProjectiveSpace(ZZ,2)
sage: H = Hom(P,P2)
sage: f = H([x^2+3*y^2,2*y^2,z^2])
sage: P2(2,7,1).nth_iterate(f,2)
Traceback (most recent call last):
...
TypeError: point is not defined over domain of function
sage: P(2,7,1).nth_iterate(f,2)
Traceback (most recent call last):
...
TypeError: map must be an endomorphism
TypeError: map must be an endomorphism for iteration
::
Expand All @@ -716,23 +712,10 @@ def nth_iterate(self,f, n, **kwds):
.. TODO:: Is there a more efficient way to do this?
"""
if self.codomain() != f.domain():
raise TypeError("point is not defined over domain of function")
if not f.is_endomorphism():
raise TypeError("map must be an endomorphism")
n = ZZ(n)
if n < 0:
raise TypeError("must be a forward orbit")
Q = self
normalize = kwds.pop("normalize", False)
check = kwds.pop("check",True)
if normalize:
Q.normalize_coordinates()
for i in range(n):
Q = f(Q, check)
if normalize:
Q.normalize_coordinates()
return(Q)
return self.orbit(f,[n,n+1],**kwds)[0]

def orbit(self, f, N, **kwds):
r"""
Expand Down Expand Up @@ -849,7 +832,7 @@ def orbit(self, f, N, **kwds):
if N[0] > N[1]:
return([])

Q = copy(self)
Q = self
check = kwds.pop("check",True)
normalize = kwds.pop("normalize",False)

Expand Down

0 comments on commit 1ee5379

Please sign in to comment.