• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

APN-Pucky / pyfeyn2 / 14949175800

10 May 2025 09:12PM UTC coverage: 65.23% (-1.8%) from 67.018%
14949175800

push

github

web-flow
add: root renderer (#319)

* init root renderer

* Update docs folder

* Update readme

* Gallery only TIKZ

* Use warnings deprecated

* bump

* Updates

* Fixes

* fmt2

* fix smpl import

* rename: dir -> sense

* toml -> tomlib

* Fix wanring -> fail unicode

* fallback to tomli

* Fix typo

47 of 155 new or added lines in 9 files covered. (30.32%)

2 existing lines in 1 file now uncovered.

2180 of 3342 relevant lines covered (65.23%)

0.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

21.74
/pyfeyn2/render/root/rootpdfrender.py
1
import tempfile
1✔
2

3
from pylatex import Command
1✔
4
from pylatex.utils import NoEscape
1✔
5

6
from pyfeyn2.render.latex.latex import LatexRender
1✔
7
from pyfeyn2.render.root.rootrender import ROOTRender
1✔
8

9

NEW
10
def root_to_latex(root_canvas) -> str:
×
11
    # create a tmp tex file
NEW
12
    with tempfile.NamedTemporaryFile(
×
13
        suffix=".tex", delete=True, mode="w+"
14
    ) as temp_file:
NEW
15
        root_canvas.SaveAs(temp_file.name)
×
16
        # read the file
NEW
17
        tex_src = temp_file.read()
×
NEW
18
        return tex_src
×
NEW
19
    raise RuntimeError("Failed to create temporary file")
×
20

21

NEW
22
class ROOTPDFRender(LatexRender, ROOTRender):
×
NEW
23
    def __init__(
×
24
        self,
25
        fd=None,
26
        documentclass="standalone",
27
        document_options=None,
28
        *args,
29
        **kwargs,
30
    ):
NEW
31
        if document_options is None:
×
NEW
32
            document_options = ["preview", "crop", "tikz"]
×
NEW
33
        super().__init__(
×
34
            *args,
35
            fd=fd,
36
            documentclass=documentclass,
37
            document_options=document_options,
38
            **kwargs,
39
        )
40
        # self.preamble.append(Command("RequirePackage", "luatex85"))
NEW
41
        self.preamble.append(Command("usepackage", NoEscape("tikz")))
×
NEW
42
        self.preamble.append(Command("usetikzlibrary", NoEscape("patterns")))
×
NEW
43
        self.preamble.append(Command("usetikzlibrary", NoEscape("plotmarks")))
×
44
        # fhout.write("\\usetikzlibrary{patterns}\n")
45
        # fhout.write("\\usetikzlibrary{plotmarks}\n")
46

NEW
47
    def render(
×
48
        self,
49
        file=None,
50
        show=True,
51
        resolution=100,
52
        width=None,
53
        height=None,
54
        clean_up=True,
55
    ):
56
        # First need to convert feynman to ROOT through ROOTRender
NEW
57
        ROOTRender.render(
×
58
            self,
59
            file=None,
60
            show=False,
61
            resolution=resolution,
62
            width=width,
63
            height=height,
64
        )
65
        # Then convert ROOT to LaTeX
NEW
66
        self.set_src_diag(NoEscape(root_to_latex(self.get_src_root())))
×
NEW
67
        LatexRender.render(self, file, show, resolution, width, height, clean_up)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc