Skip to content

Commit d0ddcab

Browse files
committed
rename, describe and test max_exponent
1 parent f878f75 commit d0ddcab

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/sage/combinat/k_regular_sequence.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ def _n_to_index_(self, n):
979979
except OverflowError:
980980
raise ValueError('value {} of index is negative'.format(n)) from None
981981

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):
983983
r"""
984984
Guess a `k`-regular sequence of `(f(n))_{n\geq0}`.
985985
@@ -992,8 +992,8 @@ def guess(self, f, n_max=100, max_dimension=10, sequence=None):
992992
`k`-regular sequence coincides with `f` on the first ``n_max``
993993
terms
994994
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
997997
998998
- ``sequence`` -- (default: ``None``) a `k`-regular sequence used
999999
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):
11481148
2-regular sequence 1, 2, 2, 4, 2, 4, 4, 8, 2, 4, ...
11491149
sage: from itertools import islice
11501150
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
11531153
....: L.append(ps)
11541154
sage: G = Seq2.guess(lambda n: L[n])
11551155
sage: G
@@ -1172,8 +1172,8 @@ def guess(self, f, n_max=100, max_dimension=10, sequence=None):
11721172
3-regular sequence 1, 3, 2, 3, 9, 6, 2, 6, 4, 3, ...
11731173
sage: from itertools import islice
11741174
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
11771177
....: L.append(ps)
11781178
sage: G = Seq3.guess(lambda n: L[n])
11791179
sage: G
@@ -1189,6 +1189,13 @@ def guess(self, f, n_max=100, max_dimension=10, sequence=None):
11891189
(1, 1))
11901190
sage: G == S.partial_sums(include_n=True)
11911191
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
11921199
"""
11931200
import logging
11941201
logger = logging.getLogger(__name__)
@@ -1308,8 +1315,9 @@ def include(line):
13081315
while to_branch:
13091316
line_R = to_branch.pop(0)
13101317
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}')
13131321

13141322
t_L = t_R + 1
13151323
for s_L in srange(k):

0 commit comments

Comments
 (0)