#14982: When a parent is equipped with an embedding, consider coercions that 
don't
go through the embedding
-------------------------------------+-------------------------------------
       Reporter:  mmezzarobba        |        Owner:
           Type:  defect             |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.4
      Component:  coercion           |   Resolution:
       Keywords:  embedding          |    Merged in:
        Authors:  Marc Mezzarobba    |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/mmezzarobba/14982-coerce_embeddings|  
f32b52f4176684d57e4e6b83f80c2c553ffcc8eb
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by vdelecroix):

 Hello,

 In this comment
 {{{
 +            # As a consequence, a value of __an_element with the wrong
 class
 +            # is cached during the call to has_coerce_map_from. We reset
 the
 +            # cache afterwards.
 }}}
 you refer to `__an_element`. But you changed the attribute's name to
 `_cache_an_element`.

 The hack for quadratic number field is horrible... At least could we
 replace
 {{{#!diff
 diff --git
 a/src/sage/rings/number_field/number_field_element_quadratic.pyx
 b/src/sage/rings/number_field/number_field_element_quadratic.pyx
 index 32e1acc..692bae1 100644
 --- a/src/sage/rings/number_field/number_field_element_quadratic.pyx
 +++ b/src/sage/rings/number_field/number_field_element_quadratic.pyx
 @@ -210,21 +210,8 @@ cdef class
 NumberFieldElement_quadratic(NumberFieldElement_absolute):
              self._reduce_c_()

          # set the attribute standard embedding which is used in the
 method
 -        # __cmp__
 -        try:
 -            self.standard_embedding = parent._standard_embedding
 -        except AttributeError:
 -            emb = parent.coerce_embedding()
 -            if emb is None:
 -                self.standard_embedding = True
 -                try:
 -                    parent._standard_embedding = True
 -                except AttributeError:
 -                    pass
 -            else:
 -                raise ValueError("A parent of
 NumberFieldElement_quadratic with "
 -                                 "a canonical embedding should have an
 attribute "
 -                                 "_standard_embedding (used for
 comparisons of elements)")
 +        # __cmp__, sign, real, imag, floor, ceil, ...
 +        self.standard_embedding = parent._standard_embedding
 }}}

 Vincent

--
Ticket URL: <http://trac.sagemath.org/ticket/14982#comment:43>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to