Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix doctests in src/sage/databases/oeis.py #36976

Merged
merged 3 commits into from
Jan 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/sage/databases/oeis.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def _fetch(url):

TESTS::

sage: from sage.databases.oeis import _fetch, oeis_url
sage: from sage.databases.oeis import _fetch, oeis_url # optional -- internet
sage: _fetch(oeis_url + 'hints.html')[-8:-1] # optional -- internet
'</html>'
"""
Expand Down Expand Up @@ -309,12 +309,12 @@ class OEIS:
14930352, 24157817, 39088169, 63245986, 102334155)

sage: fibo.cross_references()[0] # optional -- internet
'A039834'
'A001622'

sage: fibo == oeis(45) # optional -- internet
True

sage: sfibo = oeis('A039834')
sage: sfibo = oeis('A039834') # optional -- internet
sage: sfibo.first_terms() # optional -- internet
(1, 1, 0, 1, -1, 2, -3, 5, -8, 13, -21, 34, -55, 89, -144, 233,
-377, 610, -987, 1597, -2584, 4181, -6765, 10946, -17711, 28657,
Expand Down Expand Up @@ -707,11 +707,12 @@ def online_update(self):

TESTS::

sage: # optional -- internet
sage: s = oeis._imaginary_sequence(ident='A004238')
sage: s
A004238: The characteristic sequence of 42 plus one, starting from 38.
sage: s.online_update() # optional -- internet
sage: s # optional -- internet
sage: s.online_update()
sage: s
A004238: a(n) = 100*log(n) rounded to nearest integer.
"""
options = {'q': self._id, 'n': '1', 'fmt': 'text'}
Expand Down Expand Up @@ -832,7 +833,7 @@ def raw_entry(self):
A000045: Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.

sage: print(f.raw_entry()) # optional -- internet
%I A000045 M0692 N0256
%I A000045 M0692 N0256...
%S A000045 0,1,1,2,3,5,8,13,21,34,55,89,144,...
%T A000045 10946,17711,28657,46368,...
...
Expand Down Expand Up @@ -890,7 +891,7 @@ def old_IDs(self):
A000045: Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.

sage: f.old_IDs() # optional -- internet
('M0692', 'N0256')
('M0692', 'N0256'...)
Copy link
Collaborator

@mantepse mantepse Dec 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that this is the correct fix. Rather, we should probably first strip of the date. For example, f._field("I") currently gives ['M0692 N0256 #2128 Dec 18 2023 00:21:04']. Unfortunately, this is not documented at https://oeis.org/eishelp1.html. Maybe we should ask? In any case, it seems quite clear that everything after the # should be ignored for our purposes.

(I don't know what the 2128 means. Experimentally, we always have #XXX MMM DD YYYY TT:TT:TT)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, we should ask.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sent email to seqfan. I suspect that the number after the #-sign is the version number. In any case, we should strip it off, it appears that it is always there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be ok with ed94024.


TESTS::

Expand Down Expand Up @@ -1111,7 +1112,7 @@ def is_dead(self, warn_only=False):
A warning is triggered if any field of a dead sequence is accessed,
unless :meth:`is_dead` is called before::

sage: s = oeis(17)
sage: s = oeis(17) # optional -- internet
sage: s # optional -- internet
doctest:warning
...
Expand Down Expand Up @@ -1803,6 +1804,7 @@ def show(self):
URL
https://oeis.org/A012345
<BLANKLINE>
...
AUTHOR
Patrick Demichel (patrick.demichel(AT)hp.com)
<BLANKLINE>
Expand Down
Loading