Skip to content

Commit 5f66f5e

Browse files
fixed all changes
1 parent ba7241c commit 5f66f5e

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

src/sage/dynamics/arithmetic_dynamics/dynamical_semigroup.py

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
from collections.abc import Collection
2323
from sage.categories.fields import Fields
24-
from sage.categories.homset import Hom
2524
from sage.categories.number_fields import NumberFields
2625
from sage.categories.semigroups import Semigroups
2726
from sage.dynamics.arithmetic_dynamics.affine_ds import DynamicalSystem_affine
@@ -30,7 +29,7 @@
3029
from sage.misc.classcall_metaclass import typecall
3130
from sage.misc.inherit_comparison import InheritComparisonClasscallMetaclass
3231
from sage.rings.finite_rings.finite_field_base import FiniteField
33-
from sage.rings.integer import Integer
32+
from sage.rings.integer_ring import ZZ
3433
from sage.rings.rational_field import QQ
3534
from sage.structure.parent import Parent
3635

@@ -525,7 +524,7 @@ def nth_iterate(self, p, n):
525524
sage: f.nth_iterate(2, 3.5)
526525
Traceback (most recent call last):
527526
...
528-
TypeError: 3.50000000000000 must be an integer
527+
TypeError: Attempt to coerce non-integral RealNumber to Integer
529528
530529
::
531530
@@ -542,9 +541,17 @@ def nth_iterate(self, p, n):
542541
sage: f = DynamicalSemigroup(([x + y, x - y], [x^2, y^2]))
543542
sage: f.nth_iterate(3, 2) == (f * f)(3)
544543
True
544+
545+
::
546+
547+
sage: P.<x,y> = ProjectiveSpace(QQ, 1)
548+
sage: f = DynamicalSemigroup(([x + y, x - y], [x^2, y^2]))
549+
sage: one = QQ(1)
550+
sage: f.nth_iterate(2, one)
551+
{(3 : 1), (4 : 1)}
552+
545553
"""
546-
if not isinstance(n, Integer) and not isinstance(n, int):
547-
raise TypeError(str(n) + " must be an integer")
554+
n = ZZ(n)
548555
if n < 0:
549556
raise ValueError(str(n) + " must be a nonnegative integer")
550557
result = {self.domain()(p)}
@@ -811,7 +818,7 @@ def __pow__(self, n):
811818
sage: d^1.5
812819
Traceback (most recent call last):
813820
...
814-
TypeError: 1.50000000000000 must be an integer
821+
TypeError: Attempt to coerce non-integral RealNumber to Integer
815822
816823
::
817824
@@ -823,9 +830,20 @@ def __pow__(self, n):
823830
Traceback (most recent call last):
824831
...
825832
ValueError: -1 must be a nonnegative integer
833+
834+
::
835+
836+
sage: A.<x> = AffineSpace(QQ, 1)
837+
sage: f = DynamicalSystem(x^2, A)
838+
sage: d = DynamicalSemigroup(f)
839+
sage: two = RR(2)
840+
sage: d^two
841+
Dynamical semigroup over Affine Space of dimension 1 over Rational Field defined by 1 dynamical system:
842+
Dynamical System of Affine Space of dimension 1 over Rational Field
843+
Defn: Defined on coordinates by sending (x) to
844+
(x^4)
826845
"""
827-
if not isinstance(n, Integer) and not isinstance(n, int):
828-
raise TypeError(str(n) + " must be an integer")
846+
n = ZZ(n)
829847
if n < 0:
830848
raise ValueError(str(n) + " must be a nonnegative integer")
831849
if n == 0:
@@ -1153,21 +1171,10 @@ def homogenize(self, n):
11531171
Dynamical System of Projective Space of dimension 1 over Rational Field
11541172
Defn: Defined on coordinates by sending (x0 : x1) to
11551173
(x1^2 : x0^2)
1156-
1157-
TESTS::
1158-
1159-
sage: A.<x,y,z> = AffineSpace(QQ, 3)
1160-
sage: f = DynamicalSystem([y^2, z^3, x^6], A)
1161-
sage: g = DynamicalSystem([1 + x^7, y + z^2, x + 9], A)
1162-
sage: d = DynamicalSemigroup((f, g))
1163-
sage: d.homogenize((0, 1))
11641174
"""
11651175
new_systems = []
11661176
for ds in self.defining_systems():
1167-
new_system = ds.homogenize(n)
1168-
if not isinstance(new_system, DynamicalSystem_projective):
1169-
raise ValueError(str(new_system) + " is not a `DynamicalSystem_projective` object")
1170-
new_systems.append(new_system)
1177+
new_systems.append(ds.homogenize(n))
11711178
return DynamicalSemigroup_projective(new_systems)
11721179

11731180
class DynamicalSemigroup_affine_field(DynamicalSemigroup_affine):

0 commit comments

Comments
 (0)