From cbcb94f2cf3b54926be73c4eb842df5da0096d73 Mon Sep 17 00:00:00 2001 From: Martin Rubey Date: Sun, 14 Aug 2016 17:52:59 +0200 Subject: [PATCH] quick dirty fix for bug reported by Bill Page, add idea for better type handling --- src/sage/interfaces/fricas.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/sage/interfaces/fricas.py b/src/sage/interfaces/fricas.py index 4f3768999c2..caf91708b6b 100644 --- a/src/sage/interfaces/fricas.py +++ b/src/sage/interfaces/fricas.py @@ -464,6 +464,10 @@ def _get_type_str(self): return m.groups()[0] def _get_type(self): + """ + TODO: use fricas.eval("dom(%s)") instead. Then we can also use + ")set message type off" to get very clean communication! + """ import ast def to_list_of_lists(node): if isinstance(node, ast.Name): @@ -570,6 +574,9 @@ def _sage_(self): sage: _.parent() # optional - fricas Multivariate Polynomial Ring in y, x over Rational Field + sage: a = fricas("1$Polynomial Integer").sage() # optional - fricas + 1 + Rational functions: sage: fricas("x^2 + 1/z").sage() # optional - fricas @@ -637,8 +644,11 @@ def _sage_(self): elif type[0] == "Polynomial": base_ring = self._get_sage_type(type[1]) vars = self.variables()._get_1d_output()[1:-1] - R = PolynomialRing(base_ring, vars) - return R(self._get_1d_output()) + if vars == "": + return base_ring(self._get_1d_output()) + else: + R = PolynomialRing(base_ring, vars) + return R(self._get_1d_output()) elif type[0] == "Expression": if type[1] == "Integer":