示例#1
0
 def test_distributep4(self):
     eq = Equation("\\partial_{\\mu} \\( A^{\\gamma}B^{\\zeta}\\) ")
     eq.getTree().distributePs(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq),
         "\\( \\partial_{\\mu} A^{\\gamma} B^{\\zeta} + \\partial_{\\mu} B^{\\zeta} A^{\\gamma} \\)",
         '')
示例#2
0
 def test_distributep8(self):
     eq = Equation("\\square \\(A^{\\alpha}B_{\\alpha}\\)")
     eq.getTree().distributePs(eq.getTree().getRoot())
     # self.assertRegex(repr(eq), '\\( \\square A\^\{\\alpha\} B_\{\\alpha\} + \\partial\^\{\\.*\} B_\{\\alpha\} \\partial_\{\\.*\} A\^\{\\alpha\} + \\square B_\{\\\\alpha\} A\^\{\\alpha\} + \\partial\^\{\\\\.*\} A\^\{\\alpha\} \\partial_\{\\.*\} B_\{\\alpha\} \\)', 'product rule with squares')
     # self.assertRegex(repr(eq), '\\\\( \\\\square A\{\\\\alpha} B_{\\\\alpha} \+ \\\\partial\^{\\\\.*} B_{\\\\alpha} \\\\partial_{\\\\.*} A\^{\\\\alpha} \+ \\\\square B_{\\\\alpha} A\^{\\\\alpha} \+ \\\\partial\^{\\\\.*} A\^{\\\\alpha} \\\\partial_{\\\\.*} B_{\\\\alpha} \\\\)', 'product rule with squares')
     self.assertRegex(
         repr(eq),
         '\\\\\( \\\\square A\^\{\\\\alpha\} B_\{\\\\alpha\} \+ \\\\partial\^\{\\\\.*\} B_\{\\\\alpha\} \\\\partial_\{\\\\.*\} A\^\{\\\\alpha\} \+ \\\\square B_\{\\\\alpha\} A\^\{\\\\alpha\} \+ \\\\partial\^\{\\\\.*\} A\^\{\\\\alpha\} \\\\partial_\{\\\\.*\} B_\{\\\\alpha\} \\\\\)',
         'product rule with squares')
示例#3
0
 def test_foil1(self):
     eq = Equation(
         "\\(A^{}\\) \\partial_{\\mu} \\(Y \\partial_{\\nu}h^{\\mu \\nu} + X \\partial^{\\mu} h^{\\nu }_{\\nu}\\)"
     )
     eq.getTree().foil(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq),
         "\\(Y A^{} \\partial_{\\nu} \\partial_{\\mu} h^{\\mu \\nu} +X A^{} \\partial^{\\mu} \\partial_{\\mu} h_{\\nu}^{\\nu} \\)",
         '')
示例#4
0
 def test_distributep3(self):
     eq = Equation(
         "\\partial_{\\mu} \\(5 \\partial_{\\nu}h^{\\mu \\nu} + V \\partial^{\\mu} h^{\\nu }_{\\nu}\\) "
     )
     eq.getTree().distributePs(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq),
         "\\(5 \\partial_{\\nu} \\partial_{\\mu} h^{\\mu \\nu} +V \\partial^{\\mu} \\partial_{\\mu} h_{\\nu}^{\\nu} \\)",
         '')
示例#5
0
 def test_noPmult15(self):
     eq = Equation(
         "\\(A \\eta^{\\gamma \\epsilon} + A5B + 56 \\delta^{\\phi}_{\\xi} \\) \\partial_{\\mu} \\(Y \\partial_{\\nu}h^{\\mu \\nu} + X \\partial^{\\mu} h^{\\nu }_{\\nu}\\)"
     )
     eq.getTree().noPfoil(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq),
         "\\partial_{\\mu} \\(YA \\eta^{\\gamma \\epsilon} \\partial_{\\nu} h^{\\mu \\nu} +5 YAB \\partial_{\\nu} h^{\\mu \\nu} +56 Y \\delta_{\\xi}^{\\phi} \\partial_{\\nu} h^{\\mu \\nu} +XA \\eta^{\\gamma \\epsilon} \\partial^{\\mu} h_{\\nu}^{\\nu} +5 XAB \\partial^{\\mu} h_{\\nu}^{\\nu}  \\\\ \n +56 X \\delta_{\\xi}^{\\phi} \\partial^{\\mu} h_{\\nu}^{\\nu} \\)",
         '')
示例#6
0
 def test_noPmult17(self):
     eq = Equation(
         "H \\(A^{\\epsilon} + B^{\\gamma} \\) \\( \\partial_{\\mu}X^{\\mu} + M^{\\nu \\zeta}_{\\gamma} \\) \\( X + Y\\) "
     )
     eq.getTree().noPfoil(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq),
         "\\(HX A^{\\epsilon} \\partial_{\\mu} X^{\\mu} +HY A^{\\epsilon} \\partial_{\\mu} X^{\\mu} +HX A^{\\epsilon} M_{\\gamma}^{\\nu \\zeta} +HY A^{\\epsilon} M_{\\gamma}^{\\nu \\zeta} +HX B^{\\gamma} \\partial_{\\mu} X^{\\mu} +HY B^{\\gamma} \\partial_{\\mu} X^{\\mu}  \\\\ \n +HX B^{\\gamma} M_{\\gamma}^{\\nu \\zeta} +HY B^{\\gamma} M_{\\gamma}^{\\nu \\zeta} \\)",
         '')
示例#7
0
 def test_noPmult14(self):
     eq = Equation(
         "\\delta^{\\gamma}_{\\zeta} \\eta^{\\nu \\alpha} \\partial_{\\mu} \\(Y \\partial_{\\nu}h^{\\mu \\zeta} + X \\partial^{\\mu} h^{\\zeta }_{\\nu}\\)"
     )
     eq.getTree().noPfoil(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq),
         "\\partial_{\\mu} \\(Y \\delta_{\\zeta}^{\\gamma} \\eta^{\\nu \\alpha} \\partial_{\\nu} h^{\\mu \\zeta} +X \\delta_{\\zeta}^{\\gamma} \\eta^{\\nu \\alpha} \\partial^{\\mu} h_{\\nu}^{\\zeta} \\)",
         '')
示例#8
0
 def test_noPmult13(self):
     eq = Equation(
         "\\(A + 5B + CD \\) \\partial_{\\mu} \\(Y \\partial_{\\nu}h^{\\mu \\nu} + X \\partial^{\\mu} h^{\\nu }_{\\nu}\\) "
     )
     eq.getTree().noPfoil(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq),
         "\\partial_{\\mu} \\(YA \\partial_{\\nu} h^{\\mu \\nu} +5 YB \\partial_{\\nu} h^{\\mu \\nu} +YCD \\partial_{\\nu} h^{\\mu \\nu} +XA \\partial^{\\mu} h_{\\nu}^{\\nu} +5 XB \\partial^{\\mu} h_{\\nu}^{\\nu} +XCD \\partial^{\\mu} h_{\\nu}^{\\nu} \\)",
         '')
示例#9
0
 def test_noPmult12(self):
     eq = Equation(
         "4 \\partial_{\\mu}  \\(Y \\partial_{\\nu}h^{\\mu \\nu} + X \\partial^{\\mu} h^{\\nu }_{\\nu}\\)"
     )
     eq.getTree().noPfoil(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq),
         "\\partial_{\\mu} \\(4 Y \\partial_{\\nu} h^{\\mu \\nu} +4 X \\partial^{\\mu} h_{\\nu}^{\\nu} \\)",
         '')
示例#10
0
 def test_noPmult9(self):
     eq = Equation(
         "A^{\\epsilon} \\partial_{\\mu}  \\(Y \\partial_{\\nu}h^{\\mu \\nu} + X \\partial^{\\mu} h^{\\nu }_{\\nu}\\) - B^{\\epsilon}   "
     )
     eq.getTree().noPfoil(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq),
         "A^{\\epsilon} \\partial_{\\mu} \\(Y \\partial_{\\nu} h^{\\mu \\nu} +X \\partial^{\\mu} h_{\\nu}^{\\nu} \\)- B^{\\epsilon}",
         '')
示例#11
0
 def test_noPmult7(self):
     eq = Equation(
         " \\partial_{\\mu} \\(Y \\partial_{\\nu}h^{\\mu \\nu} + X \\partial^{\\mu} h^{\\nu }_{\\nu}\\) +  T^{\\gamma} \\(A_{\\gamma} + B_{\\gamma}\\)"
     )
     eq.getTree().noPfoil(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq),
         "\\partial_{\\mu} \\(Y \\partial_{\\nu} h^{\\mu \\nu} +X \\partial^{\\mu} h_{\\nu}^{\\nu} \\)+\\( T^{\\gamma} A_{\\gamma} + T^{\\gamma} B_{\\gamma} \\)",
         '')
示例#12
0
 def test_combineLikeTerms7(self):
     eq = Equation("3CA^{\\gamma} + \\frac{5}{7} DB^{\\gamma}")
     eq.combineLikeTerms(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq), "\\(3C A^{\\gamma} +\\frac{5}{7}D B^{\\gamma} \\)",
         'error in combining like terms differing by any (numerical or symbolic) factor'
     )
示例#13
0
 def test_factor_gcf9(self):
     eq = Equation(
         "\\(X \\partial_{\\nu}h^{\\mu \\nu} + \\partial_{\\nu} h^{\\mu \\nu}\\)"
     )
     eq.factorGCF(eq.getTree().getRoot())
     self.assertEqual(repr(eq),
                      "\\partial_{\\nu} h^{\\mu \\nu} \\(X +1 \\)", '')
示例#14
0
 def test_combineLikeTermsNum1(self):
     eq = Equation("3A^{\\gamma} + \\frac{5}{7} A^{\\gamma} ")
     eq.combineLikeTermsWithoutSymCo(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq), "\\(\\frac{26}{7} A^{\\gamma} \\)",
         'error in combining like terms differing only by a numerical factor'
     )
示例#15
0
 def test_combineLikeTermsNum9(self):
     eq = Equation("A^{\\beta} + A^{\\alpha}")
     eq.combineLikeTermsWithoutSymCo(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq), "\\( A^{\\beta} + A^{\\alpha} \\)",
         'error in combining like terms differing only by a numerical factor'
     )
示例#16
0
 def test_combineLikeTerms8(self):
     eq = Equation("XA^{\\beta} + A^{\\alpha}")
     eq.combineLikeTerms(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq), "\\(X A^{\\beta} + A^{\\alpha} \\)",
         'error in combining like terms differing by any (numerical or symbolic) factor'
     )
示例#17
0
 def test_contract_etas5(self):
     eq = Equation(
         "\\eta^{\\nu \\alpha} \\partial_{\\mu} d^{\\mu}_{\\ \\zeta \\alpha}  "
     )
     eq.contract(eq.getTree().getRoot(), 'eta')
     self.assertEqual(repr(eq),
                      "\\partial_{\\mu} d_{\\ \\zeta \\ }^{\\mu \\ \\nu}",
                      '')
示例#18
0
 def test_factor_gcf1(self):
     eq = Equation(
         "\\(3Y \\partial_{\\nu}h^{\\mu \\nu} + Y \\partial^{\\mu} h^{\\nu }_{\\nu}\\)"
     )
     eq.factorGCF(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq),
         "Y \\(3 \\partial_{\\nu} h^{\\mu \\nu} + \\partial^{\\mu} h_{\\nu}^{\\nu} \\)",
         '')
示例#19
0
 def test_factor_gcf8(self):
     eq = Equation(
         "\\(\\frac{1}{2} \\partial_{\\gamma} h^{\\mu \\gamma} + \\frac{1}{4}  h^{\\gamma \\nu}\\) "
     )
     eq.factorGCF(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq),
         "\\frac{1}{4} \\(2 \\partial_{\\gamma} h^{\\mu \\gamma} + h^{\\gamma \\nu} \\)",
         '')
示例#20
0
 def test_factor_gcf6(self):
     eq = Equation(
         "\\(X \\partial_{\\gamma}h^{\\mu \\gamma} A^{\\alpha}_{\\alpha} + Y \\partial_{\\nu} h^{\\mu \\nu}\\)"
     )
     eq.factorGCF(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq),
         "\\partial_{\\gamma} h^{\\mu \\gamma} \\(X A_{\\alpha}^{\\alpha} +Y \\)",
         '')
示例#21
0
 def test_contract_both(self):
     eq = Equation(
         "\\delta^{\\gamma}_{\\beta} \\eta^{\\nu \\alpha} \\partial_{\\mu} h^{\\mu}_{\\alpha}\\partial_{\\nu} h^{\\beta}_{\\gamma}",
         "h")
     eq.contract(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq),
         "\\partial_{\\mu} h^{\\mu \\nu} \\partial_{\\nu} h_{\\gamma}^{\\gamma}",
         '')
示例#22
0
 def test_combineLikeTerms6(self):
     eq = Equation(
         "3B \\partial_{\\gamma}A^{\\gamma} + \\frac{5}{7} V^{\\alpha}_{\\alpha} \\partial_{\\beta}A^{\\beta}"
     )
     eq.combineLikeTerms(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq),
         "\\(3B \\partial_{\\gamma} A^{\\gamma} +\\frac{5}{7} V_{\\alpha}^{\\alpha} \\partial_{\\beta} A^{\\beta} \\)",
         'error in combining like terms differing by any (numerical or symbolic) factor'
     )
示例#23
0
 def test_combineLikeTermsNum10(self):
     eq = Equation(
         "3\\partial_{\\gamma}A^{\\gamma}_{\\nu} + 7 \\partial_{\\beta}\\partial^{\\zeta}A^{\\beta}_{\\nu \\zeta}"
     )
     eq.combineLikeTermsWithoutSymCo(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq),
         "\\(3 \\partial_{\\gamma} A_{\\nu}^{\\gamma} +7 \\partial_{\\beta} \\partial^{\\zeta} A_{\\nu \\zeta}^{\\beta} \\)",
         'error in combining like terms differing only by a numerical factor'
     )
示例#24
0
 def test_combineLikeTerms11(self):
     eq = Equation(
         "3V\\partial_{\\gamma}\\partial^{\\mu}A^{\\gamma}_{\\nu \\mu} + 7L \\partial_{\\beta}\\partial^{\\zeta}A^{\\beta}_{\\zeta \\nu}",
         "A")
     eq.combineLikeTerms(eq.getTree().getRoot())
     self.assertEqual(
         repr(eq),
         "\\(\\(3V+7L\\) \\partial_{\\gamma} \\partial^{\\mu} A_{\\nu \\mu}^{\\gamma} \\)",
         'error in combining like terms differing by any (numerical or symbolic) factor'
     )
示例#25
0
 def test_factor_gcf4(self):
     eq = Equation("X A^{\\alpha}_{\\alpha} + Y A^{\\alpha}_{\\alpha}")
     eq.factorGCF(eq.getTree().getRoot())
     self.assertEqual(repr(eq), "A_{\\alpha}^{\\alpha} \\(X +Y \\)", '')
示例#26
0
    def compute(self):
        try:
            base_equation = Equation(self.latex_text_input.text,
                                     self.symmetric_tensors_str.text)
            self.latex_text_output.text = ""
            if base_equation.getCov():
                self.open_pop("../Kivy/images/cov_warning.png")
                self.latex_text_output.text += "MAY CONTAIN LOGIC ERRORS DUE TO THE USE OF COVARIANT DERIVATIVES: PROCEED WITH CAUTION \n \n"
            if self.initial_eq:
                if self.text_statements:
                    self.latex_text_output.text += "Starting with the equation \n"
                self.latex_text_output.text += repr(base_equation)
                self.latex_text_output.text += "\n" + "\n"
            if self.foil:
                base_equation.getTree().foil(base_equation.getTree().getRoot())
                if self.text_statements:
                    self.latex_text_output.text += "multiplying out terms and distributing partial derivatives using the product rule \n"
                self.latex_text_output.text += repr(base_equation)
                self.latex_text_output.text += "\n" + "\n"
            if self.dist_part:
                base_equation.getTree().distributePs(
                    base_equation.getTree().getRoot())
                if self.text_statements:
                    self.latex_text_output.text += "using the calculus product rule to distribute partial derivatives \n"
                self.latex_text_output.text += repr(base_equation)
                self.latex_text_output.text += "\n" + "\n"
            if self.foil_no_dist:
                base_equation.getTree().noPfoil(
                    base_equation.getTree().getRoot())
                if self.text_statements:
                    self.latex_text_output.text += "multiplying out terms not under a partial derivative \n"
                self.latex_text_output.text += repr(base_equation)
                self.latex_text_output.text += "\n" + "\n"
            if self.contract_both:
                base_equation.contract(base_equation.getTree().getRoot())
                if self.text_statements:
                    self.latex_text_output.text += "contracting etas and deltas "
                self.latex_text_output.text += repr(base_equation)
                self.latex_text_output.text += "\n" + "\n"
            if self.etas:
                base_equation.contract(base_equation.getTree().getRoot(),
                                       'eta')
                if self.text_statements:
                    self.latex_text_output.text += "contracting etas \n"
                self.latex_text_output.text += repr(base_equation)
                self.latex_text_output.text += "\n" + "\n"
            if self.deltas:
                base_equation.contract(base_equation.getTree().getRoot(),
                                       'delta')
                if self.text_statements:
                    self.latex_text_output.text += "contracting deltas \n"
                self.latex_text_output.text += repr(base_equation)
                self.latex_text_output.text += "\n" + "\n"
            if self.factor_gcf:
                base_equation.factorGCF(base_equation.getTree().getRoot())
                if self.text_statements:
                    self.latex_text_output.text += "factoring out the greatest common factor \n"
                self.latex_text_output.text += repr(base_equation)
                self.latex_text_output.text += "\n" + "\n"
            if self.factor_term:
                base_equation.factorUserInputTree(
                    base_equation.getTree().getRoot(),
                    self.term_to_factor_str.text)
                if self.text_statements:
                    self.latex_text_output.text += "factoring out $ " + self.term_to_factor_str.text + " $ \n"
                self.latex_text_output.text += repr(base_equation)
                self.latex_text_output.text += "\n" + "\n"

            if self.replace_indices:
                base_equation.replaceIndices(self.indices_to_replace_str.text,
                                             self.replacement_indices_str.text)
                if self.text_statements:
                    self.latex_text_output.text += "replacing indices $ " + self.indices_to_replace_str.text + " $ with indices $ " + self.replacement_indices_str.text + " $ \n"
                self.latex_text_output.text += repr(base_equation)
                self.latex_text_output.text += "\n" + "\n"

            if self.replace_terms:
                base_equation.replaceTerms(self.term_to_replace_str.text,
                                           self.replacement_term_str.text)
                if self.text_statements:
                    self.latex_text_output.text += "replacing $ " + self.term_to_replace_str.text + " $ with $ " + self.replacement_term_str.text + " $ \n"
                self.latex_text_output.text += repr(base_equation)
                self.latex_text_output.text += "\n" + "\n"

            if self.combine_like_terms_num:
                base_equation.combineLikeTermsWithoutSymCo(
                    base_equation.getTree().getRoot())
                if self.text_statements:
                    self.latex_text_output.text += "combining like terms \n"
                self.latex_text_output.text += repr(base_equation)
                self.latex_text_output.text += "\n" + "\n"
            if self.combine_like_terms:
                base_equation.combineLikeTerms(
                    base_equation.getTree().getRoot())
                if self.text_statements:
                    self.latex_text_output.text += "combine like terms differing by any (numerical or symbolic) coefficient \n"
                self.latex_text_output.text += repr(base_equation)
                self.latex_text_output.text += "\n" + "\n"

            if self.sort_each:
                base_equation.sortEach()
                if self.text_statements:
                    self.latex_text_output.text += "organizing the tensors in each term from least to greatest number of partials \n"
                self.latex_text_output.text += repr(base_equation)
                self.latex_text_output.text += "\n" + "\n"

            if self.sort_terms:
                base_equation.sortTerms()
                if self.text_statements:
                    self.latex_text_output.text += "organizing each term from least to greatest number of partials \n"
                self.latex_text_output.text += repr(base_equation)
                self.latex_text_output.text += "\n" + "\n"
        except Exception as exceptObj:
            self.exception_str = str(exceptObj)
            #tb = sys.exc_info()[-1]
            #stk = traceback.extract_tb(tb, 1)
            #fname = stk[0][2]
            #self.exception_str += " method that produced error: " + fname
            self.open_except_pop("../Kivy/images/error_popup.png")
示例#27
0
 def test_combineLikeTermsNum(self):
     eq = Equation("\\partial_{\\mu} \\partial_{\\nu}h^{\\mu \\nu} + \\partial_{\\alpha}\\partial_{\\beta} h^{\\alpha \\beta} ")
     eq.combineLikeTermsWithoutSymCo(eq.getTree().getRoot())
     self.assertEqual(repr(eq), "\\(2 \\partial_{\\mu} \\partial_{\\nu} h^{\\mu \\nu} \\)",
     'error in combining like terms differing only by a numerical factor')
示例#28
0
 def test_combineLikeTerms(self):
     eq = Equation(" Z \\partial_{\\mu} \\partial_{\\nu}h^{\\mu \\nu} + X \\partial_{\\alpha}\\partial_{\\beta} h^{\\alpha \\beta} ")
     eq.combineLikeTerms(eq.getTree().getRoot())
     self.assertEqual(repr(eq), "\\(\\(Z+X\\) \\partial_{\\mu} \\partial_{\\nu} h^{\\mu \\nu} \\)",
     'error in combining like terms differing by any (numerical or symbolic) coefficient')
示例#29
0
    def compute(self):
        try:
            base_equation = Equation(self.equation, self.symmetric_tensors)
            # base_equation.getTree().printTreeAsTree(base_equation.getTree().traverse())
            print(base_equation.getTree().traverse())
            self.output_equation = ""
            if base_equation.getCov():
                # self.open_pop("../Kivy/images/cov_warning.png")
                self.output_equation += "MAY CONTAIN LOGIC ERRORS DUE TO THE USE OF COVARIANT DERIVATIVES: PROCEED WITH CAUTION \n \n"
            if self.initial_eq:
                if self.text_statements:
                    self.output_equation += "Starting with the equation \n"
                self.output_equation += repr(base_equation)
                self.output_equation += "\n" + "\n"
            if self.foil:
                base_equation.getTree().foil(base_equation.getTree().getRoot())
                if self.text_statements:
                    self.output_equation += "multiplying out terms and distributing partial derivatives using the product rule \n"
                self.output_equation += repr(base_equation)
                self.output_equation += "\n" + "\n"
            if self.distribute_partials:
                base_equation.getTree().distributePs(base_equation.getTree().getRoot())
                if self.text_statements:
                    self.output_equation += "using the calculus product rule to distribute partial derivatives \n"
                self.output_equation += repr(base_equation)
                self.output_equation += "\n" + "\n"
            if self.foil_no_distribute:
                base_equation.getTree().noPfoil(base_equation.getTree().getRoot())
                if self.text_statements:
                    self.output_equation += "multiplying out terms not under a partial derivative \n"
                self.output_equation += repr(base_equation)
                self.output_equation += "\n" + "\n"
        # CONTRACT
            if self.contract_both:
                base_equation.contract(base_equation.getTree().getRoot())
                if self.text_statements:
                    self.output_equation += "contracting Minkowski metrics and Kronecker deltas \n"
                self.output_equation += repr(base_equation)
                self.output_equation += "\n" + "\n"
            if self.contract_etas:
                base_equation.contract(base_equation.getTree().getRoot(), 'eta')
                if self.text_statements:
                    self.output_equation += "contracting Minkowski metrics \n"
                self.output_equation += repr(base_equation)
                self.output_equation += "\n" + "\n"
            if self.contract_deltas:
                base_equation.contract(base_equation.getTree().getRoot(), 'delta')
                if self.text_statements:
                    self.output_equation += "contracting Kronecker deltas \n"
                self.output_equation += repr(base_equation)
                self.output_equation += "\n" + "\n"
        # FACTOR
            if self.factor_gcf:
                base_equation.factorGCF(base_equation.getTree().getRoot())
                if self.text_statements:
                    self.output_equation += "factoring out the greatest common factor \n"
                self.output_equation += repr(base_equation)
                self.output_equation += "\n" + "\n"
            if self.factor_term:
                base_equation.factorUserInputTree(base_equation.getTree().getRoot(), self.term_to_factor)
                if self.text_statements:
                    self.output_equation += "factoring out $ " + self.term_to_factor + " $ \n"
                self.output_equation += repr(base_equation)
                self.output_equation += "\n" + "\n"
        # REPLACE
            if self.replace_indices:
                base_equation.replaceIndices(self.indices_to_replace, self.replacement_indices)
                if self.text_statements:
                    self.output_equation += "replacing indices $ " + self.indices_to_replace + " $ with indices $ " + self.replacement_indices + " $ \n"
                self.output_equation += repr(base_equation)
                self.output_equation += "\n" + "\n"

            if self.replace_terms:
                base_equation.replaceTerms(self.term_to_replace, self.replacement_term)
                if self.text_statements:
                    self.output_equation += "replacing $ " + self.term_to_replace + " $ with $ " + self.replacement_term + " $ \n"
                self.output_equation += repr(base_equation)
                self.output_equation += "\n" + "\n"
        # SORT
            if self.combine_like_terms_num:
                base_equation.combineLikeTermsWithoutSymCo(base_equation.getTree().getRoot())
                if self.text_statements:
                    self.output_equation += "combining like terms \n"
                self.output_equation += repr(base_equation)
                self.output_equation += "\n" + "\n"
            if self.combine_like_terms:
                base_equation.combineLikeTerms(base_equation.getTree().getRoot())
                if self.text_statements:
                    self.output_equation += "combine like terms differing by any (numerical or symbolic) coefficient \n"
                self.output_equation += repr(base_equation)
                self.output_equation += "\n" + "\n"

            if self.sort_each:
                base_equation.sortEach()
                if self.text_statements:
                    self.output_equation += "organizing the tensors in each term from least to greatest number of partials \n"
                self.output_equation += repr(base_equation)
                self.output_equation += "\n" + "\n"

            if self.sort_terms:
                base_equation.sortTerms()
                if self.text_statements:
                    self.output_equation += "organizing each term from least to greatest number of partials \n"
                self.output_equation += repr(base_equation)
                self.output_equation += "\n" + "\n"
        except Exception as exceptObj:
            self.output_equation = str(exceptObj) + "\n\nPlease email [email protected] for if you think this is a bug"
            traceback.print_tb(exceptObj.__traceback__)
            # self.exception_str = str(exceptObj)
            #tb = sys.exc_info()[-1]
            #stk = traceback.extract_tb(tb, 1)
            #fname = stk[0][2]
            #self.exception_str += " method that produced error: " + fname
            # self.open_except_pop("../Kivy/images/error_popup.png")