@@ -979,7 +979,7 @@ def _n_to_index_(self, n):
979
979
except OverflowError :
980
980
raise ValueError ('value {} of index is negative' .format (n )) from None
981
981
982
- def guess (self , f , n_max = 100 , max_dimension = 10 , sequence = None ):
982
+ def guess (self , f , n_max = 100 , max_exponent = 10 , sequence = None ):
983
983
r"""
984
984
Guess a `k`-regular sequence of `(f(n))_{n\geq0}`.
985
985
@@ -992,8 +992,8 @@ def guess(self, f, n_max=100, max_dimension=10, sequence=None):
992
992
`k`-regular sequence coincides with `f` on the first ``n_max``
993
993
terms
994
994
995
- - ``max_dimension `` -- (default: ``10``) a positive integer specifying
996
- the maximum dimension which is tried when guessing the sequence
995
+ - ``max_exponent `` -- (default: ``10``) a positive integer specifying
996
+ the maximum exponent of `k` which is tried when guessing the sequence
997
997
998
998
- ``sequence`` -- (default: ``None``) a `k`-regular sequence used
999
999
for bootstrapping the guessing by adding information of the
@@ -1148,8 +1148,8 @@ def guess(self, f, n_max=100, max_dimension=10, sequence=None):
1148
1148
2-regular sequence 1, 2, 2, 4, 2, 4, 4, 8, 2, 4, ...
1149
1149
sage: from itertools import islice
1150
1150
sage: L = []; ps = 0
1151
- sage: for s in islice(S, 110):
1152
- ....: ps += s
1151
+ sage: for j in islice(S, 110):
1152
+ ....: ps += j
1153
1153
....: L.append(ps)
1154
1154
sage: G = Seq2.guess(lambda n: L[n])
1155
1155
sage: G
@@ -1172,8 +1172,8 @@ def guess(self, f, n_max=100, max_dimension=10, sequence=None):
1172
1172
3-regular sequence 1, 3, 2, 3, 9, 6, 2, 6, 4, 3, ...
1173
1173
sage: from itertools import islice
1174
1174
sage: L = []; ps = 0
1175
- sage: for s in islice(S, 110):
1176
- ....: ps += s
1175
+ sage: for j in islice(S, 110):
1176
+ ....: ps += j
1177
1177
....: L.append(ps)
1178
1178
sage: G = Seq3.guess(lambda n: L[n])
1179
1179
sage: G
@@ -1189,6 +1189,13 @@ def guess(self, f, n_max=100, max_dimension=10, sequence=None):
1189
1189
(1, 1))
1190
1190
sage: G == S.partial_sums(include_n=True)
1191
1191
True
1192
+
1193
+ ::
1194
+
1195
+ sage: Seq2.guess(s, max_exponent=1)
1196
+ Traceback (most recent call last):
1197
+ ...
1198
+ RuntimeError: aborting as exponents would be larger than max_esponent=1
1192
1199
"""
1193
1200
import logging
1194
1201
logger = logging .getLogger (__name__ )
@@ -1308,8 +1315,9 @@ def include(line):
1308
1315
while to_branch :
1309
1316
line_R = to_branch .pop (0 )
1310
1317
t_R , r_R = line_R
1311
- if t_R >= max_dimension :
1312
- raise RuntimeError
1318
+ if t_R >= max_exponent :
1319
+ raise RuntimeError (f'aborting as exponents would be larger '
1320
+ f'than max_esponent={ max_exponent } ' )
1313
1321
1314
1322
t_L = t_R + 1
1315
1323
for s_L in srange (k ):
0 commit comments