Closed videlec closed 3 years ago
When the sage number field does not use x for the variable name of the defining polynomial pyeantic got confused
x
pyeantic
sage: from pyeantic import RealEmbeddedNumberField sage: y = polygen(QQ, 'y') sage: K = NumberField(y**2 - 2, 'b', embedding=sqrt(AA(2))) sage: KK = RealEmbeddedNumberField(K) sage: KK(K.gen()) Traceback (most recent call last): <ipython-input-78-742a653cb9b8> in <module> 2 K = NumberField(y**Integer(2) - Integer(2), 'b', embedding=sqrt(AA(Integer(2)))) 3 KK = RealEmbeddedNumberField(K) ----> 4 KK(K.gen()) ~/miniconda3/envs/flatsurf/lib/python3.9/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9335)() 898 if mor is not None: 899 if no_extra_args: --> 900 return mor._call_(x) 901 else: 902 return mor._call_with_args(x, args, kwds) ~/miniconda3/envs/flatsurf/lib/python3.9/site-packages/sage/categories/map.pyx in sage.categories.map.FormalCompositeMap._call_ (build/cythonized/sage/categories/map.c:11818)() 1692 """ 1693 for f in self.__list: -> 1694 x = f._call_(x) 1695 return x 1696 ~/miniconda3/envs/flatsurf/lib/python3.9/site-packages/pyeantic/real_embedded_number_field.py in _call_(self, x) 665 b 666 """ --> 667 rational_coefficients = [ZZ(str(c.get_str())) / ZZ(str(x.renf_elem.den().get_str())) for c in x.renf_elem.num_vector()] 668 while len(rational_coefficients) < self.domain().number_field.degree(): 669 rational_coefficients.append(QQ.zero()) ~/miniconda3/envs/flatsurf/lib/python3.9/site-packages/sage/structure/element.pyx in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4701)() 491 AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah' 492 """ --> 493 return self.getattr_from_category(name) 494 495 cdef getattr_from_category(self, name): ~/miniconda3/envs/flatsurf/lib/python3.9/site-packages/sage/structure/element.pyx in sage.structure.element.Element.getattr_from_category (build/cythonized/sage/structure/element.c:4813)() 504 else: 505 cls = P._abstract_element_class --> 506 return getattr_from_other_class(self, cls, name) 507 508 def __dir__(self): ~/miniconda3/envs/flatsurf/lib/python3.9/site-packages/sage/cpython/getattr.pyx in sage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:2619)() 370 dummy_error_message.cls = type(self) 371 dummy_error_message.name = name --> 372 raise AttributeError(dummy_error_message) 373 attribute = <object>attr 374 # Check for a descriptor (__get__ in Python) AttributeError: 'sage.rings.number_field.number_field_element_quadratic.NumberFieldElement_quadratic' object has no attribute 'renf_elem'
What's really odd here is that KK(K.gen()) calls a coercion from KK into K (!)
KK(K.gen())
KK
K
Unsurprisingly, that coercion then fails because the element is not actually in KK but in K.
Fixed in #196.
When the sage number field does not use
x
for the variable name of the defining polynomialpyeantic
got confused