Exemple #1
0
 def construct(self):
     analysis = Tex(r"Análisis y Modelamiento", color=BLUE).scale(1.4)
     numeric = Tex(r"Numérico I", color=BLUE).scale(1.4).shift(DOWN + LEFT)
     year_name = Tex("2020-1",
                     color=GREEN).scale(1.4).next_to(numeric, RIGHT)
     self.add(analysis, numeric, year_name)
     self.wait(1)
 def create_seed_obj(self, obj):
     seed = obj["general_info"]["seed"]
     seed_text = Tex(seed, color=self.TEXT_COLOR)
     def update(t):
         seed_text.set_width(self.camera_frame.get_width() * 0.2)
         seed_text.next_to([self.camera_frame.get_width() / 2, self.camera_frame.get_height() / 2, 0], direction=LEFT + DOWN, buff=0)
         seed_text.shift(
             LEFT * self.camera_frame.get_width() * 0.05 +
             DOWN * self.camera_frame.get_height() * 0.05
         )
     seed_text.add_updater(update)
     return seed_text
Exemple #3
0
def test_tex_size():
    """Check that the size of a :class:`Tex` string is not changed."""
    text = Tex("what").center()
    vertical = text.get_top() - text.get_bottom()
    horizontal = text.get_right() - text.get_left()
    assert round(vertical[1], 4) == 0.3512
    assert round(horizontal[0], 4) == 1.0420
Exemple #4
0
def test_tex_white_space_and_non_whitespace_args():
    """Check that correct number of submobjects are created per string when mixing characters with whitespace"""
    separator = ", \n . \t\t"
    str_part_1 = "Hello"
    str_part_2 = "world"
    str_part_3 = "It is"
    str_part_4 = "me!"
    tex = Tex(str_part_1, str_part_2, str_part_3, str_part_4, arg_separator=separator)
    assert len(tex) == 4
    assert len(tex[0]) == len("".join((str_part_1 + separator).split()))
    assert len(tex[1]) == len("".join((str_part_2 + separator).split()))
    assert len(tex[2]) == len("".join((str_part_3 + separator).split()))
    assert len(tex[3]) == len("".join(str_part_4.split()))
Exemple #5
0
def test_log_error_no_relevant_context(capsys):
    """Test that an error with no environment context contains no environment context"""
    failing_preamble = r"""\usepackage{fontspec}
    \setmainfont[Ligatures=TeX]{not_a_font}"""

    with pytest.raises(ValueError) as err:
        Tex(
            "The template uses a non-existent font",
            tex_template=TexTemplate(preamble=failing_preamble),
        )

    # validate useless TeX error not logged for user
    assert "Context" not in str(capsys.readouterr().out)
    # validate useful error message raised
    # this won't happen if an error is raised while formatting the message
    assert "See log output above or the log file" in str(err.value)
Exemple #6
0
def test_log_error_context(capsys):
    """Test that the environment context of an error is correctly logged if it exists"""
    invalid_tex = r"""
        some text that is fine

        \begin{unbalanced_braces}{
        not fine
        \end{not_even_the_right_env}
        """

    with pytest.raises(ValueError) as err:
        Tex(invalid_tex)

    # validate useful TeX error logged to user
    assert "unbalanced_braces" in str(capsys.readouterr().out)
    # validate useful error message raised
    assert "See log output above or the log file" in str(err.value)
def test_tex_non_whitespace_arg(using_opengl_renderer):
    """Check that correct number of submobjects are created per string with non_whitespace characters"""
    separator = ","
    str_part_1 = "Hello"
    str_part_2 = "world"
    str_part_3 = "It is"
    str_part_4 = "me!"
    tex = Tex(str_part_1,
              str_part_2,
              str_part_3,
              str_part_4,
              arg_separator=separator)
    assert len(tex) == 4
    assert len(tex[0]) == len("".join((str_part_1 + separator).split()))
    assert len(tex[1]) == len("".join((str_part_2 + separator).split()))
    assert len(tex[2]) == len("".join((str_part_3 + separator).split()))
    assert len(tex[3]) == len("".join(str_part_4.split()))
Exemple #8
0
def test_error_in_nested_context(capsys):
    """Test that displayed error context is not excessively large"""
    invalid_tex = r"""
    \begin{align}
      \begin{tabular}{ c }
        no need to display \\
        this correct text \\
      \end{tabular}
      \notacontrolsequence
    \end{align}
    """

    with pytest.raises(ValueError) as err:
        Tex(invalid_tex)

    stdout = str(capsys.readouterr().out)
    # validate useless context is not included
    assert r"\begin{frame}" not in stdout
Exemple #9
0
def test_tex():
    Tex("The horse does not eat cucumber salad.")
    assert Path(config.media_dir, "Tex", "983949cac5bdd272.svg").exists()
Exemple #10
0
def test_changing_font_size():
    """Test that the font_size property properly scales tex_mobject.py classes."""
    num = Tex("0", font_size=12)
    num.font_size = 48

    assert num.height == Tex("0", font_size=48).height
Exemple #11
0
def mark_tex_caption(node, tex) -> Write:
    nd = Tex(tex)
    nd.scale(0.45)
    nd.next_to(node, aligned_edge=UR)
    return Write(nd)
Exemple #12
0
def test_tex(temp_media_dir):
    Tex("The horse does not eat cucumber salad.")
    assert (temp_media_dir / "Tex" / "983949cac5bdd272.svg").exists()
Exemple #13
0
def test_percent_char_rendering():
    Tex(r"\%")
    assert Path(config.media_dir, "Tex", "ce6e53f2d9c537bb.tex").exists()
Exemple #14
0
 def construct(self):
     tex_template = TexTemplate(preamble=r"\usepackage{notapackage}")
     some_tex = r"\frac{1}{0}"
     my_tex = Tex(some_tex, tex_template=tex_template)
     self.add(my_tex)
Exemple #15
0
 def construct(self):
     self.add(Square())
     self.add(Text("Prepare for unforeseen consequencesλ"))
     self.add(Tex(r"$\lambda$"))
     self.wait(1)