Problems viewing crystals from sage

74 views
Skip to first unread message

Andrew

unread,
Dec 11, 2023, 12:35:59 AM12/11/23
to sage-support
I am trying to view crystal graphs from inside sage, and I am going a little nuts. Sometimes view(...) works as I expect but most of the time it doesn't, and I see the error message:

The document “sage.pdf” could not be opened. The file doesn’t exist.

(my emphasis). I compiled sage from source and I am running:

SageMath version 10.3.beta1
Release Date: 2023-12-10        
Using Python 3.11.6.

on a 2022 macbook pro (M1 max), running Sonoma 14.1.2. I installed dot2tex using:
    sage -i dot2tex, which
which installed without errors. Running
    sage: from sage.graphs.graph_latex import check_tkz_graph
    sage: check_tkz_graph()
does not report any problems with my set up.

I get the error message above using the the sage commands:

sage: L=RootSystem(['A',4]).weight_space().basis()
sage: G=crystals.LSPaths(['A',4], L[1])
sage: G
The crystal of LS paths of type ['A', 4] and weight Lambda[2]
sage: view(G)

I get the same error if I try the examples from the "Classical crystals" thematic tutorial, such as:

sage: B = crystals.Tableaux(['A',2], shape=[2,1])
sage: view(B, tightpage=True)

When it does work, a nice tikz generated pdf file pops up. Am I missing some steps? Can anyone tell me what I am doing wrong?

Andrew


Andrew

unread,
Dec 12, 2023, 6:50:55 PM12/12/23
to sage-support
Playing around with this a little more, I think that this is a bug/timing issue in sage.misc.latex.py (or in subprocess.run, or a mac oddity since it only started happening recently). 

What seems to be happening is that the generated PDF file, output_file, is being deleted before the viewer is able to open it. Specifically, if I add time.sleep(2) before the tmp.cleanup  then the viewer opens as expected.

    def run_viewer():
        run([viewer, output_file], capture_output=True)
        time.sleep(1)    ## adding this, together with import time, fixes the problem
        tmp.cleanup()

(This around line 1957 of latex.py.) Certainly this explains my experience of the command working sometimes and failing at other times. On the other hand, it is a little strange because subprocess.run is supposed to wait for the process to finish. A shorter example that exhibits the problem, at least on the two macs that I have available, is

    sage: view(crystals.LSPaths( RootSystem(['A',4]).weight_space().basis()[1] ) )

If people agree that this is a bug then I am happy to post a fix.

Andrew


Message has been deleted

John H Palmieri

unread,
Dec 12, 2023, 8:30:03 PM12/12/23
to sage-support

Andrew

unread,
Dec 12, 2023, 9:15:31 PM12/12/23
to sage-support
Thanks John. 

Yes, I think you are right because this PR is about exactly this issue and, more importantly, it adds the code that I want to brutalise. I missed this when used git blame to look for recent changes to sage.misc.latex. This fits as view() was working without issues for me a month or so ago and this was only merged at the end of October.

Since https://github.com/sagemath/sage/pull/36529 is already merged is it too late to add a comment on the ticket?

Andrew

John H Palmieri

unread,
Dec 12, 2023, 10:36:52 PM12/12/23
to sage-support
Please add comments to that ticket.
Reply all
Reply to author
Forward
0 new messages