Ticket #8334: 7585_9_1_frac_and_coerce_updates.patch

File 7585_9_1_frac_and_coerce_updates.patch, 2.2 KB (added by David Roe, 13 years ago)
  • sage/rings/morphism.pyx

    # HG changeset patch
    # User David Roe <roed@math.harvard.edu>
    # Date 1266938272 28800
    # Node ID bec14d89cc4cea082c079dcc3b96e2816e81b8dd
    # Parent  909ef48f05e6103e0f566c1bd12cc19f801a6c5f
    #8334: Moved orders in number fields to the new coercion model.  The part of
    7585_9_frac_and_coerce_updates needed for the changes to residue field.
    
    diff -r 909ef48f05e6 -r bec14d89cc4c sage/rings/morphism.pyx
    a b  
    856856            sage: type(f(2))          # indirect doctest
    857857            <type 'sage.rings.rational.Rational'>
    858858        """
    859         return self.codomain()._coerce_(x)
     859        return self.codomain().coerce(x)
    860860
    861861import sage.structure.all
    862862
  • sage/rings/number_field/order.py

    diff -r 909ef48f05e6 -r bec14d89cc4c sage/rings/number_field/order.py
    a b  
    213213            raise ValueError, "ideal must be integral; use fractional_ideal to create a non-integral ideal."
    214214        return I
    215215
     216    def _coerce_map_from_(self, R):
     217        """
     218        Orders currently only have coerce maps from the integers.
     219       
     220        EXAMPLES::
     221
     222            sage: k.<a> = NumberField(x^2 + 5077)
     223            sage: Ok = k.maximal_order()
     224            sage: Ok.has_coerce_map_from(k) #indirect doctest
     225            False
     226            sage: Ok.has_coerce_map_from(ZZ)
     227            True
     228        """
     229        return R is ZZ or R is int or R is long
     230
    216231    def __mul__(self, right):
    217232        """
    218233        Create an ideal in this order using the notation ``Ok*gens``
     
    10131028            if module_rep.rank() != self._K.degree():
    10141029                raise ValueError, "the module must have full rank."
    10151030       
    1016     def __call__(self, x):
     1031    def _element_constructor_(self, x):
    10171032        r"""
    10181033        Coerce ``x`` into this order.
    10191034
     
    13611376        self._absolute_order = absolute_order
    13621377        self._module_rep = absolute_order._module_rep
    13631378
    1364     def __call__(self, x):
     1379    def _element_constructor_(self, x):
    13651380        """
    13661381        Coerce an element into this relative order.
    13671382