sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.37k stars 466 forks source link

New interface with OEIS #10358

Closed williamstein closed 10 years ago

williamstein commented 13 years ago

The sloane_find command, which parses output of a webpage, is broken for years due to the Sloane sequence webpage being rewritten. It silently always finds nothing.

sage: sloane_find([1,1,2,3,5,8,13,21], nresults=1)
[]

The aim of this ticket is to propose a new interface with OEIS http://oeis.org/

Apply:

Depends on #15245

CC: @sagetrac-sage-combinat @williamstein @kini @jpflori @sagetrac-chrisjamesberg @VivianePons

Component: combinatorics

Keywords: Cernay2012 days49

Author: Thierry Monteil

Reviewer: Nathann Cohen

Merged: sage-5.13.beta2

Issue created by migration from https://trac.sagemath.org/ticket/10358

jdemeyer commented 10 years ago

Dependencies: #15245

jdemeyer commented 10 years ago
comment:53

This needs to be rebased to #15245.

edd8e884-f507-429a-b577-5d554626c0fe commented 10 years ago

rebased after #15245

edd8e884-f507-429a-b577-5d554626c0fe commented 10 years ago

Description changed:

--- 
+++ 
@@ -8,7 +8,7 @@
 The aim of this ticket is to propose a new interface with OEIS http://oeis.org/

 Apply: 
-* [attachment: trac_10358-oeis-tm.patch](https://github.com/sagemath/sage-prod/files/10651534/trac_10358-oeis-tm.patch.gz)
+* [attachment: trac_10358-oeis-tm_rebase.patch](https://github.com/sagemath/sage-prod/files/10651539/trac_10358-oeis-tm_rebase.patch.gz)
 * [attachment: trac_10358-oeis-review_1-tm.patch](https://github.com/sagemath/sage-prod/files/10651535/trac_10358-oeis-review_1-tm.patch.gz)
 * [attachment: trac_10358-oeis-review_2-tm.patch](https://github.com/sagemath/sage-prod/files/10651536/trac_10358-oeis-review_2-tm.patch.gz)
 * [attachment: trac_10358-oeis-review_3-nc-tm.patch​](https://github.com/sagemath/sage/files/ticket10358/67d8b96f8e3df0fd19199ab7e76eeaa4.gz)
edd8e884-f507-429a-b577-5d554626c0fe commented 10 years ago
comment:54

Attachment: trac_10358-oeis-tm_rebase.patch.gz

The rebase is a shift in sage/matrix/matrix2.pyx

apply trac_10358-oeis-tm_rebase.patch trac_10358-oeis-review_1-tm.patch trac_10358-oeis-review_2-tm.patch trac_10358-oeis-review_3-nc-tm.patch

jdemeyer commented 10 years ago
comment:55

The patches apply now.

jdemeyer commented 10 years ago

Merged: sage-5.13.beta2

nthiery commented 10 years ago
comment:57

Joy, joy, joy is all around us!

Hail to Thierry, Hail to Nathann!

zimmermann6 commented 6 years ago
comment:58

I use this closed ticket to touch the interested people. In March 2017 I got:

  sage: oeis([1,1,2,5,14])
  0: A000108: Catalan numbers: C(n) = binomial(2n,n)/(n+1) = (2n)!/(n!(n+1)!). \
Also called Segner numbers.
  1: A120588: G.f. satisfies: 3*A(x) = 2 + x + A(x)^2, with a(0) = 1.
  2: A080937: Number of Catalan paths (nonnegative, starting and ending at 0, s\
tep +/-1) of 2*n steps with all values <= 5.

and now I get with Sage 8.3:

sage: oeis([1,1,2,5,14])

0: A000108: Catalan numbers: C(n) = binomial(2n,n)/(n+1) = (2n)!/(n!(n+1)!). Also called Segner numbers.
1: A120588: G.f. satisfies: 3*A(x) = 2 + x + A(x)^2, with a(0) = 1.
2: A000679: Number of groups of order 2^n.

I have two questions:

1) why did the output change?

2) why do we get only 3 answers (I checked with len(oeis(...)) that there are only 3 answers, and it is not only 3 answers that are printed), whereas the OEIS official site gives 209 answers?

edd8e884-f507-429a-b577-5d554626c0fe commented 6 years ago
comment:59

Replying to @zimmermann6:

I use this closed ticket to touch the interested people. In March 2017 I got:

  sage: oeis([1,1,2,5,14])
  0: A000108: Catalan numbers: C(n) = binomial(2n,n)/(n+1) = (2n)!/(n!(n+1)!). \
Also called Segner numbers.
  1: A120588: G.f. satisfies: 3*A(x) = 2 + x + A(x)^2, with a(0) = 1.
  2: A080937: Number of Catalan paths (nonnegative, starting and ending at 0, s\
tep +/-1) of 2*n steps with all values <= 5.

and now I get with Sage 8.3:

sage: oeis([1,1,2,5,14])

0: A000108: Catalan numbers: C(n) = binomial(2n,n)/(n+1) = (2n)!/(n!(n+1)!). Also called Segner numbers.
1: A120588: G.f. satisfies: 3*A(x) = 2 + x + A(x)^2, with a(0) = 1.
2: A000679: Number of groups of order 2^n.

I have two questions:

1) why did the output change?

The oeis module connects to an on-line database, which is subject to changes. The output depends on the ordering provided by OEIS, which depends on various criteria (i do not know the details, but if the sequence has keywords interesting or important it will appear earlier).

2) why do we get only 3 answers (I checked with len(oeis(...)) that there are only 3 answers, and it is not only 3 answers that are printed), whereas the OEIS official site gives 209 answers?

You can get help about oeis as follows:

sage: oeis?

You can see that there is a max_results option, which is set by default to 3 to avoid the outout being flooded. Maybe this could be extended to, say, 10.

Also, OEIS will only send the 100 first results even if you do:

sage: oeis([1,1,2,5,14], max_results=2000)

This is why there is a first_result option, to be able to access the next ones.

zimmermann6 commented 6 years ago
comment:60

Thierry, thank you for your answer.

Of course I had tried oeis?, and in Sage 8.3 I get:

   * "max_results" - (integer, default: 30) the maximum number of
     results to return, they are sorted according to their relevance.
     In any cases, the OEIS website will never provide more than 100
     results.

thus the documentation seems to differ from the code. Should I open a new ticket for that?