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 findstat internet tests #34595

Closed
jhpalmieri opened this issue Sep 27, 2022 · 15 comments
Closed

Fix findstat internet tests #34595

jhpalmieri opened this issue Sep 27, 2022 · 15 comments

Comments

@jhpalmieri
Copy link
Member

Tickets #27408 and #22349 broke some "optional - internet" tests in findstat, so let's fix them.

Component: graph theory

Keywords: findstat

Author: John Palmieri

Branch/Commit: 9c44659

Reviewer: David Coudert

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

@jhpalmieri jhpalmieri added this to the sage-9.8 milestone Sep 27, 2022
@jhpalmieri
Copy link
Member Author

Branch: u/jhpalmieri/findstat-internet-tests

@jhpalmieri
Copy link
Member Author

New commits:

9c44659trac 34595: fix internet doctests in findstat.py

@jhpalmieri
Copy link
Member Author

Commit: 9c44659

@dcoudert
Copy link
Contributor

comment:3

When I run ./sage -t --optional=external src/sage/databases/findstat.py, I got many doctests errors (152) like:

sage -t --warn-long 80.2 --random-seed=72649070764419291381942551007802275570 src/sage/databases/findstat.py
**********************************************************************
File "src/sage/databases/findstat.py", line 49, in sage.databases.findstat
Failed example:
    r = findstat([(m, m.number_of_nestings()) for n in range(6) for m in PM(2*n)], depth=1); r # optional -- internet
Exception raised:
    Traceback (most recent call last):
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 695, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 1093, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.databases.findstat[0]>", line 1, in <module>
        r = findstat([(m, m.number_of_nestings()) for n in range(Integer(6)) for m in PM(Integer(2)*n)], depth=Integer(1)); r # optional -- internet
      File "<doctest sage.databases.findstat[0]>", line 1, in <listcomp>
        r = findstat([(m, m.number_of_nestings()) for n in range(Integer(6)) for m in PM(Integer(2)*n)], depth=Integer(1)); r # optional -- internet
    NameError: name 'PM' is not defined
**********************************************************************
File "src/sage/databases/findstat.py", line 83, in sage.databases.findstat
Failed example:
    print(r[1].statistic().description())                                 # optional -- internet
Exception raised:
    Traceback (most recent call last):
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 695, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 1093, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.databases.findstat[1]>", line 1, in <module>
        print(r[Integer(1)].statistic().description())                                 # optional -- internet
    AttributeError: 'RFunction' object has no attribute 'statistic'
**********************************************************************
File "src/sage/databases/findstat.py", line 91, in sage.databases.findstat
Failed example:
    r[1].statistic().references()                                         # optional -- internet
Exception raised:
    Traceback (most recent call last):
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 695, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 1093, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.databases.findstat[2]>", line 1, in <module>
        r[Integer(1)].statistic().references()                                         # optional -- internet
    AttributeError: 'RFunction' object has no attribute 'statistic'
**********************************************************************
File "src/sage/databases/findstat.py", line 104, in sage.databases.findstat
Failed example:
    findstat(data, depth=0)                                               # optional -- internet
Exception raised:
    Traceback (most recent call last):
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 695, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 1093, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.databases.findstat[3]>", line 1, in <module>
        findstat(data, depth=Integer(0))                                               # optional -- internet
    NameError: name 'data' is not defined
**********************************************************************
File "src/sage/databases/findstat.py", line 434, in sage.databases.findstat._get_json
Failed example:
    _get_json(FINDSTAT_API_MAPS + "?xxx=yyy")                         # optional -- internet
Expected:
    Traceback (most recent call last):
    ...
    ValueError: E005: On filtering maps, the following parameters are not allowed: [u'xxx'].
Got:
    <BLANKLINE>
    Traceback (most recent call last):
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 695, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 1093, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.databases.findstat._get_json[0]>", line 1, in <module>
        _get_json(FINDSTAT_API_MAPS + "?xxx=yyy")                         # optional -- internet
    NameError: name '_get_json' is not defined
...

Am I doing something wrong in the way I launch the tests or is it something else ?

@mantepse
Copy link
Collaborator

Changed keywords from none to findstat

@mantepse
Copy link
Collaborator

comment:5

@dcoudert: possibly it should be

./sage -t --optional=sage,external src/sage/databases/findstat.py

@jhpalmieri: I am not sure right now, but I don't think that the sorting is actually necessary. Is there a way to turn off the warning without specifying the sort parameter?

@dcoudert
Copy link
Contributor

Reviewer: David Coudert

@dcoudert
Copy link
Contributor

comment:6

All tests pass with ./sage -t --optional=sage,external src/sage/databases/findstat.py. Thanks.

I set this ticket to positive review.

@mantepse
Copy link
Collaborator

comment:7

@dcoudert: Thank you, but did you see my comment:3?

@dcoudert
Copy link
Contributor

comment:8

it passes tests if we set sort=False, but I don't know if I'm lucky or if sorting is not needed for these tests.

@jhpalmieri
Copy link
Member Author

comment:9

Replying to Martin Rubey:

@jhpalmieri: I am not sure right now, but I don't think that the sorting is actually necessary. Is there a way to turn off the warning without specifying the sort parameter?

Right now, the only way to avoid the deprecation warning is to specify the sort parameter. This was deemed necessary to make the switch from the default being sorted to the default being unsorted. The first change changes sorted(X.edges(...)) to X.edges(sort=True, ...), so that is just repeating the sorting that was already happening. The last change uses X.edges(sort=False), The middle one is a doctest that prints the edges, and to get repeatability of the output, I thought it was safest to sort.

@dcoudert
Copy link
Contributor

comment:10

Let's keep it as is. The extra cost of sorting is rather minimal here and we avoid unexpected behavior.

@mantepse
Copy link
Collaborator

comment:11

I agree!

@jhpalmieri
Copy link
Member Author

comment:12

Great, thank you both!

@vbraun
Copy link
Member

vbraun commented Sep 29, 2022

Changed branch from u/jhpalmieri/findstat-internet-tests to 9c44659

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants