-
-
Notifications
You must be signed in to change notification settings - Fork 704
Description
The following is mathematically wrong:
sage: 0 in CyclotomicField(3).ideal(0)
False
It comes from the function contains(self, x) in the class NumberFieldIdeal (file sage/rings/number_field/number_field_ideal.py), which tries to compute the coordinates of the element in a basis (over ZZ) of the ideal. The function coordinates(self, x) fails for the zero ideal, raising a TypeError (in fact when _contains_ is called directly, a TypeError is raised).
A workaround is to replace
def _contains_(self, x):
return self.coordinates(self.number_field()(x)).denominator() == 1
with
def _contains_(self, x):
return x==0 or self.coordinates(self.number_field()(x)).denominator() == 1
but I am not sure if it is the "right" way to do it.
Is it desirable to have the _contains_ function in sage/rings/ideal.py catch the TypeError (silently)?
Apply attachment: 14366_metrod3.patch
Component: number fields
Keywords: sd51
Author: Michiel Kosters
Reviewer: David Loeffler
Merged: sage-5.12.beta3
Issue created by migration from https://trac.sagemath.org/ticket/14366