Пример #1
0
    def test_remove_inline_dls(self):
        line_to_sub = r'Test $ f(x)+g(x) = F(x) \mbox{ where $f(x)$ and $g(x)$ are smooth} $'

        subbed_line = r'Test \( f(x)+g(x) = F(x) \mbox{ where \(f(x)\) and \(g(x)\) are smooth} \)'

        line_to_sub_dd = r'$$\im \lim_{x\to\alpha} $$ $$\gamma=\log_a_r \weird{\frac{1}{\{\LL\}}}{a}\alpha d$$'

        subbed_line_dd = r'\[\im \lim_{x\to\alpha} \] \[\gamma=\log_a_r \weird{\frac{1}{\{\LL\}}}{a}\alpha d\]'

        rm = md.Dollars().remove_dollars_from_text_env
        rm_i = md.Dollars().remove_inline_dls
        self.assertEqual(subbed_line, rm_i(rm(line_to_sub),'$'))
        self.assertEqual(subbed_line_dd, rm_i(line_to_sub_dd, '$$'))
        with self.assertRaises(ValueError):
            rm_i('string','££')
Пример #2
0
 def test_detectEnv(self):
     string_test=(r"\begin{tabular} $ \begin{"
                  r"array"
                  r"} \mbox"
                  r"{$ a + b}\end{array}")
     ndls = md.Dollars()
     ndls.remove_dls_new(string_test)
     self.assertEqual(len(ndls.dl_open),2)
Пример #3
0
    def test_count_symbols_in_string(self):
        string = (r"$"
                  r"\begin{tabular}{l}"
                  r"$ \displaystyle (+\ZIN )^{\displaystyle +\ZIN}=+\ZIN $"
                  r"\\"
                  r"$\displaystyle    (+\ZIN)^{-\ZIN} =0$ "
                  r"\end{tabular}"
                  r"$")
        string_dd = (r"$$"
                  r"\begin{tabular}{l}"
                  r"$ \displaystyle (+\ZIN )^{\displaystyle +\ZIN}=+\ZIN $"
                  r"\\"
                  r"$\displaystyle    (+\ZIN)^{-\ZIN} =0$ "
                  r"\end{tabular}"
                  r"$$")

        self.assertEqual(6, md.Dollars().count_symbols_in_string(string, '$'))
        self.assertEqual(2, md.Dollars().count_symbols_in_string(string_dd, '$$'))
        self.assertEqual(0, md.Dollars().count_symbols_in_string(string, '$$'))
Пример #4
0
    def test_remove_dollars_from_text_env(self):
        line_to_sub = r'Test $ f(x)+g(x) = F(x) \mbox{ where $f(x)$ and $g(x)$ are smooth} \begin{array}\mbox{$a+b$}\end{array}$'

        subbed_line = r'Test $ f(x)+g(x) = F(x) \mbox{ where \(f(x)\) and \(g(x)\) are smooth} \begin{array}\mbox{\(a+b\)}\end{array}$'

        line_to_sub_2 = r'k\mapsto n(k) \quad \mbox{ossia la successione$ \{n_k\} $ \`e {\bf strettamente crescente.}}'

        subbed_line_2 = r'k\mapsto n(k) \quad \mbox{ossia la successione\( \{n_k\} \) \`e {\bf strettamente crescente.}}'

        line_3 = r"&&= \frac{A_1}{x-x_0}+\frac{,\mbox{d}}{,\mbox{d} x}\left \{\frac{-A_2}{x-x_0}+\cdots+\frac{A_n}{(1-n)}\frac{1}{(x-x_0)^{n-1}}\right\}\,."
        sub_3 =  r"&&= \frac{A_1}{x-x_0}+\frac{,\mbox{d}}{,\mbox{d} x}\left \{\frac{-A_2}{x-x_0}+\cdots+\frac{A_n}{(1-n)}\frac{1}{(x-x_0)^{n-1}}\right\}\,."
        rm = md.Dollars().remove_dollars_from_text_env

        self.assertEqual(subbed_line, rm(line_to_sub))
        self.assertEqual(subbed_line_2, rm(line_to_sub_2))
        self.assertEqual(sub_3, rm(line_3))
Пример #5
0
 def test_remove_sparse_dl(self):
     string = r"$& $(-\infty)(+\infty)=-\infty=(+\infty)(-\infty)$ \\"
     string_clean = r"\)& \((-\infty)(+\infty)=-\infty=(+\infty)(-\infty)\) \\"
     md.Dollars().dl_open = 1
     self.assertEqual(string_clean, md.Dollars().remove_sparse_dl(string))