Opened 16 months ago

Closed 16 months ago

Last modified 15 months ago

#28865 closed defect (duplicate)

2 doctests failed in smallgraphs.py

Reported by: slabbe Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: graph theory Keywords:
Cc: embray Merged in:
Authors: Reviewers: David Coudert, Erik Bray
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

sage -t --long src/sage/graphs/generators/smallgraphs.py

gives

Using --optional=4ti2,build,cbc,ccache,cryptominisat,dochtml,dot2tex,e_antic,glucose,latte_int,lidia,lrslib,memlimit,normaliz,notedown,openssl,pandoc_attributes,pycosat,pynormaliz,rst2ipynb,sage,sagenb
Doctesting 1 file.
sage -t --long src/sage/graphs/generators/smallgraphs.py
**********************************************************************
File "src/sage/graphs/generators/smallgraphs.py", line 4759, in sage.graphs.generators.smallgraphs.JankoKharaghaniGraph
Failed example:
    g = graphs.JankoKharaghaniGraph(936)   # long time
Exception raised:
    MemoryError

    During handling of the above exception, another exception occurred:

    MemoryError

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/slabbe/GitBox/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 681, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/slabbe/GitBox/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 1123, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.graphs.generators.smallgraphs.JankoKharaghaniGraph[0]>", line 1, in <module>
        g = graphs.JankoKharaghaniGraph(Integer(936))   # long time
      File "/home/slabbe/GitBox/sage/local/lib/python3.7/site-packages/sage/graphs/generators/smallgraphs.py", line 4835, in JankoKharaghaniGraph
        return Graph([e for e,v in six.iteritems(D.dict()) if v == 1],
      File "sage/matrix/matrix0.pyx", line 246, in sage.matrix.matrix0.Matrix.dict (build/cythonized/sage/matrix/matrix0.c:4555)
        return dict(self._dict())
      File "sage/matrix/matrix0.pyx", line 303, in sage.matrix.matrix0.Matrix._dict (build/cythonized/sage/matrix/matrix0.c:4745)
        x = self.get_unsafe(i, j)
    MemoryError
**********************************************************************
File "src/sage/graphs/generators/smallgraphs.py", line 4760, in sage.graphs.generators.smallgraphs.JankoKharaghaniGraph
Failed example:
    g.is_strongly_regular(parameters=True) # long time
Exception raised:
    Traceback (most recent call last):
      File "/home/slabbe/GitBox/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 681, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/slabbe/GitBox/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 1123, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.graphs.generators.smallgraphs.JankoKharaghaniGraph[1]>", line 1, in <module>
        g.is_strongly_regular(parameters=True) # long time
    NameError: name 'g' is not defined
**********************************************************************
1 item had failures:
   2 of   3 in sage.graphs.generators.smallgraphs.JankoKharaghaniGraph
    [565 tests, 2 failures, 18.04 s]
----------------------------------------------------------------------
sage -t --long src/sage/graphs/generators/smallgraphs.py  # 2 doctests failed
----------------------------------------------------------------------

Change History (12)

comment:1 Changed 16 months ago by dcoudert

It's not easy to change this doctest as this generator can generates only 2 graphs, and this one is the smallest.

sage: %time g = graphs.JankoKharaghaniGraph(936)
CPU times: user 1.95 s, sys: 190 ms, total: 2.14 s
Wall time: 2.19 s
sage: g.order(), g.size()
(936, 175500)
sage: %time g = graphs.JankoKharaghaniGraph(1800)
^[[A^[[A
CPU times: user 22.8 s, sys: 1.64 s, total: 24.5 s
Wall time: 24.6 s
sage: g.order(), g.size()
(1800, 926100)

This doctest fails when there is not enough memory. I don't know how to change this doctest.

comment:2 Changed 16 months ago by dcoudert

At least, we need a way to avoid the call to D.dict(). Any expert in matrix module to help here ?

comment:3 Changed 16 months ago by jhpalmieri

Does it help to tag those tests with # optional -- memlimit?

By the way: what is the platform? How much memory? Does it depend on one of the external packages? How can I reproduce this?

comment:4 Changed 16 months ago by dcoudert

It only depends on the available memory (I don't know the limit) and not on external packages. In #28525 we were able to use smaller graphs for the doctests, but here it's not possible (the method creates only 2 graphs and the doctest is for the smallest). Avoiding the creation of D.dict() may help, but I'm not sure.

comment:5 Changed 16 months ago by slabbe

I can reproduce the issue on my laptop and my desktop (both running Ubuntu 16.06 with SageMath version 9.0.beta9, Release Date: 2019-12-08).

Last edited 16 months ago by slabbe (previous) (diff)

comment:6 Changed 16 months ago by slabbe

On my laptop (Ubuntu 16.06), I can not reproduce:

sage -t --long src/sage/graphs/generators/smallgraphs.py

gives

Using --optional=4ti2,build,cbc,ccache,cryptominisat,dochtml,dot2tex,e_antic,glucose,latte_int,lidia,lrslib,memlimit,normaliz,notedown,openssl,pandoc_attributes,pycosat,pynormaliz,python2,rst2ipynb,sage,sagenb
Doctesting 1 file.
sage -t --long --warn-long 69.3 src/sage/graphs/generators/smallgraphs.py
    [565 tests, 30.13 s]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------

On my desktop with the same optional packages (also Ubuntu 16.06), I get the issue and I can reproduce it. Strange.

comment:7 Changed 16 months ago by jhpalmieri

How much RAM do those machines have? And on the machines where it fails, does it help if you tag the doctests with # optional -- memlimit or # high mem? (I'm not sure about the last one, but that's what it says in sage-runtests. I found no instances of doctests tagged with # high mem in the Sage libary.)

comment:8 follow-up: Changed 16 months ago by jhpalmieri

  • Cc embray added

Note that since I can't find "high mem" in the Sage source code, I doubt this is the right syntax. (The doctesting framework has to search for something when matching the tag with the behavior, and git grep "high.*mem" src doesn't return any promising hits.)

@embray, do you know the right syntax for marking a test with a memory cap? # optional - memlimit (as is used in sage/doctest/test.py and a few other places) or # high mem (as it says in sage-runtests) or something else?

comment:9 Changed 16 months ago by dcoudert

This ticket is in fact for the same issue than #25465. I did not remember it.

comment:10 in reply to: ↑ 8 ; follow-up: Changed 16 months ago by embray

  • Milestone changed from sage-9.0 to sage-duplicate/invalid/wontfix
  • Resolution set to duplicate
  • Status changed from new to closed

Replying to jhpalmieri:

Note that since I can't find "high mem" in the Sage source code, I doubt this is the right syntax. (The doctesting framework has to search for something when matching the tag with the behavior, and git grep "high.*mem" src doesn't return any promising hits.)

@embray, do you know the right syntax for marking a test with a memory cap? # optional - memlimit (as is used in sage/doctest/test.py and a few other places) or # high mem (as it says in sage-runtests) or something else?

You can find it if you search the git history instead, but this is from #25907--in an earlier draft it was "high mem" but then during review changed to "optional - memlimit" but that string didn't get updated.

Closing this ticket as a duplicate of #25465.

comment:11 Changed 16 months ago by slelievre

  • Reviewers set to David Coudert, Erik Bray

comment:12 in reply to: ↑ 10 Changed 15 months ago by jhpalmieri

Replying to embray:

Replying to jhpalmieri:

Note that since I can't find "high mem" in the Sage source code, I doubt this is the right syntax. (The doctesting framework has to search for something when matching the tag with the behavior, and git grep "high.*mem" src doesn't return any promising hits.)

@embray, do you know the right syntax for marking a test with a memory cap? # optional - memlimit (as is used in sage/doctest/test.py and a few other places) or # high mem (as it says in sage-runtests) or something else?

You can find it if you search the git history instead, but this is from #25907--in an earlier draft it was "high mem" but then during review changed to "optional - memlimit" but that string didn't get updated.

I opened #28978 to change the few remaining instances of "high mem" to "memlimit".

Note: See TracTickets for help on using tickets.