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


On Wednesday 13 December 2023 at 12:30:03 pm UTC+11 John H Palmieri wrote:

> Could this be related to https://github.com/sagemath/sage/pull/36529?
>
>
> On Tuesday, December 12, 2023 at 3:50:55 PM UTC-8 Andrew wrote:
>
>> 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
>>
>>
>> On Monday 11 December 2023 at 4:35:59 pm UTC+11 Andrew wrote:
>>
>>> 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, 
>>> <https://doc.sagemath.org/html/en/thematic_tutorials/lie/crystals.html#installing-dot2tex>
>>>  
>>> 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
>>>
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/0d2d733b-430c-46f6-bf8e-6821d51b11f0n%40googlegroups.com.

Reply via email to