def convert_add()

in src/latex2sympy2_extended/latex2sympy2.py [0:0]


    def convert_add(self, add):
        if add.ADD():
            lh = self.convert_add(add.additive(0))
            rh = self.convert_add(add.additive(1))

            if (hasattr(lh, 'is_Matrix') and lh.is_Matrix) or (hasattr(rh, 'is_Matrix') and rh.is_Matrix):
                return self.mat_add_flat(lh, rh)
            else:
                return self.add_flat(lh, rh)
        elif add.SUB():
            lh = self.convert_add(add.additive(0))
            rh = self.convert_add(add.additive(1))

            if (hasattr(lh, 'is_Matrix') and lh.is_Matrix) or (hasattr(rh, 'is_Matrix') and rh.is_Matrix):
                return self.mat_add_flat(lh, self.mat_mul_flat(-1, rh))
            else:
                # If we want to force ordering for variables this should be:
                # return Sub(lh, rh, evaluate=False)
                if not (hasattr(rh, 'is_Matrix') and rh.is_Matrix) and (hasattr(rh, 'func') and rh.func.is_Number):
                    rh = -rh
                else:
                    rh = self.mul_flat(-1, rh)
                return self.add_flat(lh, rh)
        else:
            return self.convert_mp(add.mp())