Skip to content

Commit 6bc37d7

Browse files
committed
fetch b-file when number=oo, rather than when number=True
1 parent 40ad287 commit 6bc37d7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/sage/databases/oeis.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
from sage.misc.verbose import verbose
155155
from sage.repl.preparse import preparse
156156
from sage.rings.integer import Integer
157+
from sage.rings.infinity import infinity
157158
from sage.structure.sage_object import SageObject
158159
from sage.structure.unique_representation import UniqueRepresentation
159160

@@ -1210,10 +1211,11 @@ def first_terms(self, number=None):
12101211
12111212
INPUT:
12121213
1213-
- ``number`` -- integer, ``True`` or ``None`` (default); the
1214-
number of terms returned (if less than the number of
1215-
available terms). When set to ``True``, fetches the
1216-
b-file. When set to ``None``, returns all the known terms.
1214+
- ``number`` -- integer, ``infinity`` or ``None`` (default);
1215+
the number of terms returned. When set to ``None``,
1216+
returns all the known terms. When set to an integer larger
1217+
than the number of terms in the internal format, or to
1218+
``infinity``, the b-file is fetched.
12171219
12181220
OUTPUT: tuple of integers
12191221
@@ -1238,6 +1240,10 @@ def first_terms(self, number=None):
12381240
sage: s.first_terms(5)
12391241
(1, 1, 1, 1, 2)
12401242
1243+
sage: len(oeis(45).first_terms()) # optional -- internet
1244+
41
1245+
sage: len(oeis(45).first_terms(oo)) # optional -- internet
1246+
2001
12411247
"""
12421248
def fetch_b_file():
12431249
url = oeis_url + f"b{self.id(format='int')}.txt"
@@ -1255,7 +1261,7 @@ def fetch_b_file():
12551261
self._first_terms = True, first_terms
12561262

12571263
# self._first_terms is a pair (all?, first_terms)
1258-
if number is True:
1264+
if number is infinity:
12591265
if not hasattr(self, "_first_terms") or not self._first_terms[0]:
12601266
fetch_b_file()
12611267
return self._first_terms[1]

0 commit comments

Comments
 (0)