Ask Your Question

Revision history [back]

The breakage comes from importing SymPy's Integer.

Indeed, in Sage, the input 16 is preparsed as Integer(16).

Usually Integer means sage.rings.integer.Integer.

However after the line

from sympy import *

this is overridden and Integer now means sympy.core.numbers.Integer.

It seems the CyclotomicField constructor cannot cope with a SymPy Integer.

That should probably be fixed in Sage.

In the meantime, here are some possible workarounds. Each should work separately, no need to combine them.

a. Only import from sympy what you need, rather than *

b. After importing everything from SymPy as you did, restore Sage's Integer.

sage: reset('Integer')

c. Make sure to feed CyclotomicField an appropriate integer.

For instance, either a Python int or a Sage Integer, with one of the following:

sage: CyclotomicField(16r)  # r for raw -> Python int
sage: CyclotomicField(int(16))
sage: CyclotomicField(ZZ(16))
sage: CyclotomicField(sage.rings.integer.Integer(16))