8000 fixes for reading .pc planar code files by fchapoton · Pull Request #40068 · sagemath/sage · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fixes for reading .pc planar code files #40068

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

Merged
merged 3 commits into from
May 18, 2025

Conversation

fchapoton
Copy link
Contributor

fixes #40062

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

Copy link
github-actions bot commented May 8, 2025

Documentation preview for this PR (built with commit b7dca49; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@dcoudert
Copy link
Contributor
dcoudert commented May 8, 2025

I tried on a fedora desktop with several optional packages and get plenty of failing doctests. A summary:

Running doctests with ID 2025-05-08-19-24-04-d2bc28d7.
Git branch: blop
Git ref: 10.7.beta2-1-g76c30ff3134
Running with SAGE_LOCAL='/home/dcoudert/sage/local' and SAGE_VENV='/home/dcoudert/sage/local/var/lib/sage/venv-python3.12'
Using --optional=benzene,buckygen,csdp,dot2tex,fedora,glucose,pip,plantri,python_igraph,sage,sage_numerical_backends_cplex,sage_spkg,texttable
Features to be detected: 4ti2,SAGE_SRC,benzene,bliss,buckygen,conway_polynomials,coxeter3,csdp,cvxopt,cvxopt,database_cremona_ellcurve,database_cremona_mini_ellcurve,database_cubic_hecke,database_ellcurves,dat
abase_graphs,database_jones_numfield,database_knotinfo,dot2tex,dvipng,ecm,fpylll,fricas,gap_package_atlasrep,gap_package_design,gap_package_grape,gap_package_guava,gap_package_hap,gap_package_polenta,gap_packa
ge_polycyclic,gap_package_qpa,gap_package_quagroup,gfan,giac,glucose,graphviz,imagemagick,info,ipython,jmol,jupymake,jupyter_sphinx,kenzo,kissat,latte_int,lrcalc_python,lrslib,mathics,matroid_database,mcqd,mea
taxe,meson_editable,mpmath,msolve,nauty,networkx,numpy,palp,pandoc,pdf2svg,pdftocairo,pexpect,phitigra,pillow,plantri,polytopes_db,polytopes_db_4d,pplpy,primecountpy,ptyprocess,pycosat,pycryptosat,pynormaliz,p
yparsing,python_igraph,requests,rpy2,rubiks,sage.combinat,sage.geometry.polyhedron,sage.graphs,sage.groups,sage.libs.braiding,sage.libs.ecl,sage.libs.flint,sage.libs.gap,sage.libs.giac,sage.libs
8000
.homfly,sage.li
bs.linbox,sage.libs.m4ri,sage.libs.ntl,sage.libs.pari,sage.libs.singular,sage.misc.cython,sage.modular,sage.modules,sage.numerical.mip,sage.plot,sage.rings.complex_double,sage.rings.finite_rings,sage.rings.fun
ction_field,sage.rings.number_field,sage.rings.padics,sage.rings.polynomial.pbori,sage.rings.real_double,sage.rings.real_mpfr,sage.sat,sage.schemes,sage.symbolic,sage_numerical_backends_coin,sagemath_doc_html,
scipy,singular,sirocco,sloane_database,sphinx,symengine_py,sympy,tdlib,threejs,topcom
Doctesting 1 file.
sage -t --warn-long 5.0 --random-seed=86598867965644471363315214300576176590 src/sage/graphs/graph_generators.py
**********************************************************************
File "src/sage/graphs/graph_generators.py", line 1644, in sage.graphs.graph_generators.GraphGenerators.fullerenes
Failed example:
    len(list(gen))               # optional - buckygen
Exception raised:
    Traceback (most recent call last):
      File "/home/dcoudert/sage/src/sage/doctest/forker.py", line 730, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/dcoudert/sage/src/sage/doctest/forker.py", line 1154, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.graphs.graph_generators.GraphGenerators.fullerenes[1]>", line 1, in <module>
        len(list(gen))               # optional - buckygen
            ^^^^^^^^^
      File "/home/dcoudert/sage/src/sage/graphs/graph_generators.py", line 1717, in fullerenes
        yield from graphs._read_planar_code(sp.stdout, immutable=immutable)
      File "/home/dcoudert/sage/src/sage/graphs/graph_generators.py", line 1557, in _read_planar_code
        raise TypeError('not a binary file')
    TypeError: not a binary file
**********************************************************************
...
...
**********************************************************************
File "src/sage/graphs/graph_generators.py", line 1754, in sage.graphs.graph_generators.GraphGenerators.fusenes
Failed example:
    len(list(gen))           # optional - benzene
Exception raised:
    Traceback (most recent call last):
      File "/home/dcoudert/sage/src/sage/doctest/forker.py", line 730, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/dcoudert/sage/src/sage/doctest/forker.py", line 1154, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.graphs.graph_generators.GraphGenerators.fusenes[1]>", line 1, in <module>
        len(list(gen))           # optional - benzene
            ^^^^^^^^^
      File "/home/dcoudert/sage/src/sage/graphs/graph_generators.py", line 1808, in fusenes
        yield from graphs._read_planar_code(sp.stdout, immutable=immutable)
      File "/home/dcoudert/sage/src/sage/graphs/graph_generators.py", line 1557, in _read_planar_code
        raise TypeError('not a binary file')
    TypeError: not a binary file
**********************************************************************
...
...
**********************************************************************
File "src/sage/graphs/graph_generators.py", line 1946, in sage.graphs.graph_generators.GraphGenerators.plantri_gen
Failed example:
    next(gen)
Exception raised:
    Traceback (most recent call last):
      File "/home/dcoudert/sage/src/sage/doctest/forker.py", line 730, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/dcoudert/sage/src/sage/doctest/forker.py", line 1154, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.graphs.graph_generators.GraphGenerators.plantri_gen[1]>", line 1, in <module>
        next(gen)
      File "/home/dcoudert/sage/src/sage/graphs/graph_generators.py", line 1997, in plantri_gen
        yield from graphs._read_planar_code(sp.stdout, immutable=immutable)
      File "/home/dcoudert/sage/src/sage/graphs/graph_generators.py", line 1557, in _read_planar_code
        raise TypeError('not a binary file')
    TypeError: not a binary file
**********************************************************************
...

@fchapoton
Copy link
Contributor Author

ok, so we should be more permissive somhow..

@fchapoton
Copy link
Contributor Author

Voila une nouvelle tentative

@maxale
Copy link
Contributor
maxale commented May 8, 2025

I do not understand permissiveness. Allowing files in text mode leads to wrong results as soon as a graph contains 10 or more vertices (when charcode 0x0A appears inside). The failed doctests are better be fixed instead.

@fchapoton fchapoton force-pushed the fixes_for_planar_code_reading branch from 30c0dbe to 41d7b00 Compare May 8, 2025 19:13
Copy link
Contributor
@dcoudert dcoudert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still get a failing doctest.

sage -t --warn-long 5.0 --random-seed=315374832306038895147412932306415972585 src/sage/graphs/graph_generators.py
**********************************************************************
File "src/sage/graphs/graph_generators.py", line 1974, in sage.graphs.graph_generators.GraphGenerators.plantri_gen
Failed example:
    list(graphs.plantri_gen("6 -c=3"))  # optional - plantri
Expected:
    Traceback (most recent call last):
    ...
    AttributeError: invalid options '6 -c=3'
Got:
    <BLANKLINE>
    Traceback (most recent call last):
      File "/home/dcoudert/sage/src/sage/doctest/forker.py", line 730, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/dcoudert/sage/src/sage/doctest/forker.py", line 1154, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.graphs.graph_generators.GraphGenerators.plantri_gen[6]>", line 1, in <module>
        list(graphs.plantri_gen("6 -c=3"))  # optional - plantri
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/dcoudert/sage/src/sage/graphs/graph_generators.py", line 1990, in plantri_gen
        yield from graphs._read_planar_code(sp.stdout, immutable=immutable)
      File "/home/dcoudert/sage/src/sage/graphs/graph_generators.py", line 1561, in _read_planar_code
        raise TypeError('file has no valid planar code header')
    TypeError: file has no valid planar code header
**********************************************************************
1 item had failures:
   1 of   8 in sage.graphs.graph_generators.GraphGenerators.plantri_gen
    [213 tests, 1 failure, 4.23s wall]
----------------------------------------------------------------------
sage -t --warn-long 5.0 --random-seed=315374832306038895147412932306415972585 src/sage/graphs/graph_generators.py  # 1 doctest failed

Copy link
Contributor
@dcoudert dcoudert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Note that I cannot reproduce the failing doctests of the CI Conda (macOS, Python 3.11, all):
https://github.com/sagemath/sage/actions/runs/14927882186/job/41936763451?pr=40068#step:12:1989 and
https://github.com/sagemath/sage/actions/runs/14927882186/job/41936763451?pr=40068#step:12:8357.
I tried on both macOS and fedora with Python 3.12. These errors seems independent from this PR.

vbraun pushed a commit to vbraun/sage that referenced this pull request May 11, 2025
sagemathgh-40068: fixes for reading .pc planar code files
    
fixes sagemath#40062

### 📝 Checklist

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.
    
URL: sagemath#40068
Reported by: Frédéric Chapoton
Reviewer(s): David Coudert
@vbraun vbraun merged commit 873b7ee into sagemath:develop May 18, 2025
20 of 22 checks passed
@fchapoton fchapoton deleted the fixes_for_planar_code_reading branch May 18, 2025 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

_read_planar_code() incorrectly treats Plantri format as text rather than binary
4 participants
0