21
21
22
22
from collections .abc import Collection
23
23
from sage .categories .fields import Fields
24
- from sage .categories .homset import Hom
25
24
from sage .categories .number_fields import NumberFields
26
25
from sage .categories .semigroups import Semigroups
27
26
from sage .dynamics .arithmetic_dynamics .affine_ds import DynamicalSystem_affine
30
29
from sage .misc .classcall_metaclass import typecall
31
30
from sage .misc .inherit_comparison import InheritComparisonClasscallMetaclass
32
31
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
34
33
from sage .rings .rational_field import QQ
35
34
from sage .structure .parent import Parent
36
35
@@ -525,7 +524,7 @@ def nth_iterate(self, p, n):
525
524
sage: f.nth_iterate(2, 3.5)
526
525
Traceback (most recent call last):
527
526
...
528
- TypeError: 3.50000000000000 must be an integer
527
+ TypeError: Attempt to coerce non-integral RealNumber to Integer
529
528
530
529
::
531
530
@@ -542,9 +541,17 @@ def nth_iterate(self, p, n):
542
541
sage: f = DynamicalSemigroup(([x + y, x - y], [x^2, y^2]))
543
542
sage: f.nth_iterate(3, 2) == (f * f)(3)
544
543
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
+
545
553
"""
546
- if not isinstance (n , Integer ) and not isinstance (n , int ):
547
- raise TypeError (str (n ) + " must be an integer" )
554
+ n = ZZ (n )
548
555
if n < 0 :
549
556
raise ValueError (str (n ) + " must be a nonnegative integer" )
550
557
result = {self .domain ()(p )}
@@ -811,7 +818,7 @@ def __pow__(self, n):
811
818
sage: d^1.5
812
819
Traceback (most recent call last):
813
820
...
814
- TypeError: 1.50000000000000 must be an integer
821
+ TypeError: Attempt to coerce non-integral RealNumber to Integer
815
822
816
823
::
817
824
@@ -823,9 +830,20 @@ def __pow__(self, n):
823
830
Traceback (most recent call last):
824
831
...
825
832
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)
826
845
"""
827
- if not isinstance (n , Integer ) and not isinstance (n , int ):
828
- raise TypeError (str (n ) + " must be an integer" )
846
+ n = ZZ (n )
829
847
if n < 0 :
830
848
raise ValueError (str (n ) + " must be a nonnegative integer" )
831
849
if n == 0 :
@@ -1153,21 +1171,10 @@ def homogenize(self, n):
1153
1171
Dynamical System of Projective Space of dimension 1 over Rational Field
1154
1172
Defn: Defined on coordinates by sending (x0 : x1) to
1155
1173
(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))
1164
1174
"""
1165
1175
new_systems = []
1166
1176
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 ))
1171
1178
return DynamicalSemigroup_projective (new_systems )
1172
1179
1173
1180
class DynamicalSemigroup_affine_field (DynamicalSemigroup_affine ):
0 commit comments