Skip to content

Implement QQbar^QQ as action #5574

@burcin

Description

@burcin

This ticket implements powering in QQbar and AA by QQ exponents as an action.

This will fix the following two bugs:

Reported by Alex Raichev on sage-support:

sage: n = SR.var('n'); QQbar(2)^n
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-01e1c4db05c9> in <module>()
----> 1 n = SR.var('n'); QQbar(Integer(2))**n

/usr/local/src/sage-config/local/lib/python2.7/site-packages/sage/rings/qqbar.pyc in __pow__(self, e)
   4106         if self == self.parent().one():
   4107             return self.parent().one()
-> 4108         e = QQ._coerce_(e)
   4109         n = e.numerator()
   4110         d = e.denominator()

/usr/local/src/sage-config/src/sage/structure/parent_old.pyx in sage.structure.parent_old.Parent._coerce_ (build/cythonized/sage/structure/parent_old.c:5673)()
    227     def _coerce_(self, x):            # Call this from Python (do not override!)
    228         if self._element_constructor is not None:
--> 229             return self.coerce(x)
    230         check_old_coerce(self)
    231         return self._coerce_c(x)

/usr/local/src/sage-config/src/sage/structure/parent.pyx in sage.structure.parent.Parent.coerce (build/cythonized/sage/structure/parent.c:10829)()
   1157                 except Exception:
   1158                     _record_exception()
-> 1159             raise TypeError("no canonical coercion from %s to %s" % (parent(x), self))
   1160         else:
   1161             return (<map.Map>mor)._call_(x)

TypeError: no canonical coercion from Symbolic Ring to Rational Field
sage: QQbar(2)^1.0
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-aba7adf5dc93> in <module>()
----> 1 QQbar(Integer(2))**RealNumber('1.0')

/usr/local/src/sage-config/local/lib/python2.7/site-packages/sage/rings/qqbar.pyc in __pow__(self, e)
   4106         if self == self.parent().one():
   4107             return self.parent().one()
-> 4108         e = QQ._coerce_(e)
   4109         n = e.numerator()
   4110         d = e.denominator()

/usr/local/src/sage-config/src/sage/structure/parent_old.pyx in sage.structure.parent_old.Parent._coerce_ (build/cythonized/sage/structure/parent_old.c:5673)()
    227     def _coerce_(self, x):            # Call this from Python (do not override!)
    228         if self._element_constructor is not None:
--> 229             return self.coerce(x)
    230         check_old_coerce(self)
    231         return self._coerce_c(x)

/usr/local/src/sage-config/src/sage/structure/parent.pyx in sage.structure.parent.Parent.coerce (build/cythonized/sage/structure/parent.c:10829)()
   1157                 except Exception:
   1158                     _record_exception()
-> 1159             raise TypeError("no canonical coercion from %s to %s" % (parent(x), self))
   1160         else:
   1161             return (<map.Map>mor)._call_(x)

TypeError: no canonical coercion from Real Field with 53 bits of precision to Rational Field

CC: @videlec

Component: algebra

Author: Jeroen Demeyer

Branch/Commit: f65afd0

Reviewer: Vincent Delecroix

Issue created by migration from https://trac.sagemath.org/ticket/5574

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions