From 517bbcd21d79eb4b23ab4f8d2e7d1dc545d0ba83 Mon Sep 17 00:00:00 2001 From: dcoudert Date: Wed, 27 Dec 2023 14:35:12 +0100 Subject: [PATCH 1/3] fix doctests in src/sage/databases/oeis.py --- src/sage/databases/oeis.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/sage/databases/oeis.py b/src/sage/databases/oeis.py index e40ebc7c539..dabbc576e96 100644 --- a/src/sage/databases/oeis.py +++ b/src/sage/databases/oeis.py @@ -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 '' """ @@ -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, @@ -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'} @@ -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,... ... @@ -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'...) TESTS:: @@ -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 ... @@ -1803,6 +1804,7 @@ def show(self): URL https://oeis.org/A012345 + ... AUTHOR Patrick Demichel (patrick.demichel(AT)hp.com) From ed9402464d834ad8f8b5f1fd6aff7db8bb814093 Mon Sep 17 00:00:00 2001 From: dcoudert Date: Wed, 27 Dec 2023 19:52:36 +0100 Subject: [PATCH 2/3] fix some doctests --- src/sage/databases/oeis.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/databases/oeis.py b/src/sage/databases/oeis.py index dabbc576e96..8de495b44f5 100644 --- a/src/sage/databases/oeis.py +++ b/src/sage/databases/oeis.py @@ -1043,11 +1043,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 :: From b798d690a688081dfd4dfd8420cc2f5cb96927cd Mon Sep 17 00:00:00 2001 From: dcoudert Date: Fri, 29 Dec 2023 10:39:29 +0100 Subject: [PATCH 3/3] strip text after #-sign --- src/sage/databases/oeis.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/sage/databases/oeis.py b/src/sage/databases/oeis.py index 8de495b44f5..09eb4bd8ce2 100644 --- a/src/sage/databases/oeis.py +++ b/src/sage/databases/oeis.py @@ -891,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') TESTS:: @@ -899,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""" @@ -1804,7 +1809,6 @@ def show(self): URL https://oeis.org/A012345 - ... AUTHOR Patrick Demichel (patrick.demichel(AT)hp.com)