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

Support for tachyon >= 0.99.2 #34995

Merged
merged 2 commits into from
Mar 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/sage/interfaces/tachyon.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,12 +683,14 @@
#*****************************************************************************

import os
import re

from sage.cpython.string import bytes_to_str
from sage.misc.pager import pager
from sage.misc.superseded import deprecation
from sage.misc.temporary_file import tmp_filename
from sage.structure.sage_object import SageObject
from sage.misc.cachefunc import cached_method


class TachyonRT(SageObject):
Expand Down Expand Up @@ -799,6 +801,11 @@ def __call__(self, model, outfile='sage.png', verbose=1, extra_opts=''):
Parser failed due to an input file syntax error.
Aborting render.
"""
if self.version() >= '0.99.2':
# this keyword was changed in 0.99.2
model = model.replace(
" focallength ",
" focaldist ")
modelfile = tmp_filename(ext='.dat')
with open(modelfile, 'w') as file:
file.write(model)
Expand Down Expand Up @@ -851,6 +858,25 @@ def usage(self, use_pager=True):
else:
print(r)

@cached_method
def version(self):
"""
Returns the version of the Tachyon raytracer being used.

TESTS::

sage: tachyon_rt.version() # random
0.98.9
sage: tachyon_rt.version() >= '0.98.9'
True
"""
with os.popen('tachyon') as f:
r = f.readline()
res = re.search(r"Version ([\d.]*)", r)
# debian patches tachyon so it won't report the version
# we hardcode '0.99' since that's indeed the version they ship
return res[1] if res else '0.99'

def help(self, use_pager=True):
"""
Deprecated: type 'sage.interfaces.tachyon?' for help
Expand Down