From 827249e944e1500b5651c9dfcba2aa098d78c19f Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Fri, 21 Dec 2018 12:26:11 +0100 Subject: [PATCH] Fix(Core): str, txt and tex methods for MOmonial with -1 in coef --- mapytex/calculus/core/MO/monomial.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/mapytex/calculus/core/MO/monomial.py b/mapytex/calculus/core/MO/monomial.py index a19cdd4..8eba5aa 100644 --- a/mapytex/calculus/core/MO/monomial.py +++ b/mapytex/calculus/core/MO/monomial.py @@ -190,6 +190,27 @@ class MOMonomial(Molecule): Molecule.__init__(self, _tree) + + def __str__(self): + if self._coefficient != -1: + return super(MOMonomial, self).__str__() + else: + return "- " + self.strpower.__str__() + + @property + def __txt__(self): + if self._coefficient != -1: + return super(MOMonomial, self).__txt__ + else: + return "- " + self.strpower.__txt__ + + @property + def __tex__(self): + if self._coefficient != -1: + return super(MOMonomial, self).__tex__ + else: + return "- " + self.strpower.__tex__ + @property def coefficient(self): return self._coefficient