Skip to content

Commit

Permalink
sagemathgh-36976: Fix doctests in src/sage/databases/oeis.py
Browse files Browse the repository at this point in the history
    
Fixes sagemath#36966.

<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36976
Reported by: David Coudert
Reviewer(s): David Coudert, Martin Rubey
  • Loading branch information
Release Manager committed Jan 5, 2024
2 parents 3b0daa6 + b798d69 commit cf4afbb
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 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 @@ -898,7 +899,12 @@ def old_IDs(self):
sage: s.old_IDs()
('M9999', 'N9999')
"""
return tuple(self._field('I')[0].split(' '))
s = self._field('I')[0]
# We remove all parts after '#'
s = s.split('#')[0].strip()
if not s:
return ()
return tuple(s.split(' '))

def offsets(self):
r"""
Expand Down Expand Up @@ -1042,11 +1048,11 @@ def natural_object(self):
::
sage: av = oeis('A087778'); av # optional -- internet
A087778: Decimal expansion ... Avogadro...
sage: av = oeis('A322578'); av # optional -- internet
A322578: Decimal expansion ... Avogadro...
sage: av.natural_object() # optional -- internet
6.022141000000000?e23
6.022140760000000?e23
::
Expand Down Expand Up @@ -1111,7 +1117,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

0 comments on commit cf4afbb

Please sign in to comment.