def convert_unary()

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


    def convert_unary(self, unary):
        if hasattr(unary, 'unary'):
            nested_unary = unary.unary()
        else:
            nested_unary = unary.unary_nofunc()
        if hasattr(unary, 'postfix_nofunc'):
            first = unary.postfix()
            tail = unary.postfix_nofunc()
            postfix = [first] + tail
        else:
            postfix = unary.postfix()

        if unary.ADD():
            return self.convert_unary(nested_unary)
        elif unary.SUB():
            tmp_convert_nested_unary = self.convert_unary(nested_unary)
            if (hasattr(tmp_convert_nested_unary, 'is_Matrix') and tmp_convert_nested_unary.is_Matrix):
                return self.mat_mul_flat(-1, tmp_convert_nested_unary)
            else:
                if (hasattr(tmp_convert_nested_unary, 'func') and tmp_convert_nested_unary.func.is_Number):
                    return -tmp_convert_nested_unary
                
                elif hasattr(tmp_convert_nested_unary, 'is_Number') and tmp_convert_nested_unary.is_Number:
                    return -tmp_convert_nested_unary
                else:
                    return self.mul_flat(-1, tmp_convert_nested_unary)
        elif postfix:
            return self.convert_postfix_list(postfix)