Skip to content

Commit

Permalink
Refactor TexTemplate (#3520)
Browse files Browse the repository at this point in the history
* Refactor `TexTemplate`

* Add tests, refactor some things

* Fixed Some tests

* Move typing imports

* Fix remaining tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: JasonGrace2282 <[email protected]>
Co-authored-by: Jason Grace <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Jan 15, 2024
1 parent a57fb69 commit 68bd790
Show file tree
Hide file tree
Showing 6 changed files with 263 additions and 217 deletions.
12 changes: 6 additions & 6 deletions manim/_config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from manim import constants
from manim.constants import RendererType
from manim.utils.color import ManimColor
from manim.utils.tex import TexTemplate, TexTemplateFromFile
from manim.utils.tex import TexTemplate

if TYPE_CHECKING:
from enum import EnumMeta
Expand Down Expand Up @@ -833,7 +833,7 @@ def digest_args(self, args: argparse.Namespace) -> Self:

# Handle --tex_template
if args.tex_template:
self.tex_template = TexTemplateFromFile(tex_filename=args.tex_template)
self.tex_template = TexTemplate.from_file(args.tex_template)

if (
self.renderer == RendererType.OPENGL
Expand Down Expand Up @@ -1756,19 +1756,19 @@ def tex_template(self) -> TexTemplate:
if not hasattr(self, "_tex_template") or not self._tex_template:
fn = self._d["tex_template_file"]
if fn:
self._tex_template = TexTemplateFromFile(tex_filename=fn)
self._tex_template = TexTemplate.from_file(fn)
else:
self._tex_template = TexTemplate()
return self._tex_template

@tex_template.setter
def tex_template(self, val: TexTemplateFromFile | TexTemplate) -> None:
if isinstance(val, (TexTemplateFromFile, TexTemplate)):
def tex_template(self, val: TexTemplate) -> None:
if isinstance(val, TexTemplate):
self._tex_template = val

@property
def tex_template_file(self) -> Path:
"""File to read Tex template from (no flag). See :class:`.TexTemplateFromFile`."""
"""File to read Tex template from (no flag). See :class:`.TexTemplate`."""
return self._d["tex_template_file"]

@tex_template_file.setter
Expand Down
Loading

0 comments on commit 68bd790

Please sign in to comment.