Ticket #3738: 3738-2-new_parent_fixes.patch

File 3738-2-new_parent_fixes.patch, 52.2 KB (added by robertwb, 11 years ago)
  • sage/all.py

    # HG changeset patch
    # User Robert Bradshaw <robertwb@math.washington.edu>
    # Date 1217319873 25200
    # Node ID fa73e421367165f2d59f2c74485bcfc1a7648f8c
    # Parent  19b2ada8a98311c0b133eb4b9e7c51a8c7761979
    Sage builds and all tests pass with new Parent.
    
    diff -r 19b2ada8a983 -r fa73e4213671 sage/all.py
    a b import sage.finance.all as finance 
    118118
    119119from copy import copy, deepcopy
    120120
     121# The code executed here uses a large amount of Sage components
     122from sage.rings.qqbar import _init_qqbar
     123_init_qqbar()
     124
    121125       
    122126###########################################################
    123127#### WARNING:
  • sage/categories/homset.py

    diff -r 19b2ada8a983 -r fa73e4213671 sage/categories/homset.py
    a b import weakref 
    2626
    2727import category
    2828import morphism
    29 from sage.structure.parent import Set_generic
    30 from sage.structure.parent_base import ParentWithBase
     29from sage.structure.parent import Parent, Set_generic
    3130
    3231_cache = {}
    3332def Hom(X, Y, cat=None):
    def Hom(X, Y, cat=None): 
    145144        H = SchemeHomset(X, Y)
    146145       
    147146    else:  # default
    148         if isinstance(X, ParentWithBase):
     147        if hasattr(X, '_base') and X._base is not X and X._base is not None:
    149148            H = HomsetWithBase(X, Y, cat)
    150149        else:
    151150            H = Homset(X, Y, cat)
    def end(X, f): 
    217216    """
    218217    return End(X)(f)
    219218
    220 # We have to use ParentWithBase here, otherwise
    221 # we can't create elements of this Homset as
    222 # Element._parent has been changed to ParentWithBase.
    223 class Homset(ParentWithBase, Set_generic):
     219class Homset(Set_generic):
    224220    """
    225221    The class for collections of morphisms in a category.
    226222
    class Homset(ParentWithBase, Set_generic 
    361357        reversed.
    362358        """
    363359        return Homset(self._codomain, self._domain, self.__category)
     360       
     361    ############### For compatability with old coercion model #######################
     362   
     363    def get_action_c(self, R, op, self_on_left):
     364        return None
     365       
     366    def coerce_map_from_c(self, R):
     367        return None
    364368
    365 # class HomsetWithBase(ParentWithBase, Homset): # redundant, see above
    366369class HomsetWithBase(Homset):
    367370    def __init__(self, X, Y, cat=None, check=True, base=None):
    368371        Homset.__init__(self, X, Y, cat, check)
    369372        if base is None:
    370             ParentWithBase.__init__(self, X.base_ring())
     373            Parent.__init__(self, X.base_ring())
    371374        else:
    372             ParentWithBase.__init__(self, base)
     375            Parent.__init__(self, base)
    373376       
    374377def is_Homset(x):
    375378    """
  • sage/combinat/sf/classical.py

    diff -r 19b2ada8a983 -r fa73e4213671 sage/combinat/sf/classical.py
    a b class SymmetricFunctionAlgebra_classical 
    274274        elif isinstance(x, orthotriang.SymmetricFunctionAlgebraElement_orthotriang):
    275275            #Convert to its base and then to self
    276276            xp = x.parent()
    277             if self is xp._base:
    278                 return xp._base._from_cache(x, xp._base_cache, xp._self_to_base_cache)
     277            if self is xp._sf_base:
     278                return xp._sf_base._from_cache(x, xp._base_cache, xp._self_to_base_cache)
    279279            else:
    280                 return self( xp._base(x) )
     280                return self( xp._sf_base(x) )
    281281
    282282        ###################
    283283        # Skew Partitions #
  • sage/combinat/sf/orthotriang.py

    diff -r 19b2ada8a983 -r fa73e4213671 sage/combinat/sf/orthotriang.py
    a b class SymmetricFunctionAlgebra_orthotria 
    5656        """
    5757        self._combinatorial_class = sage.combinat.partition.Partitions()
    5858        self._one = sage.combinat.partition.Partition_class([])
    59         self._base = base
     59        self._sf_base = base
    6060        self._element_class = SymmetricFunctionAlgebraElement_orthotriang
    6161        self._scalar = scalar
    6262        self._prefix = prefix
    class SymmetricFunctionAlgebra_orthotria 
    8080            -2*s[1, 1, 1] + s[2, 1]
    8181        """
    8282        if isinstance(x, sfa.SymmetricFunctionAlgebraElement_generic):
    83             x = self._base(x)
     83            x = self._sf_base(x)
    8484            return self._from_cache(x, self._base_cache, self._base_to_self_cache)
    8585        else:
    8686            raise TypeError
    class SymmetricFunctionAlgebra_orthotria 
    107107        else:
    108108            self._self_to_base_cache[n] = {}
    109109           
    110         self._gram_schmidt(n, self._base, self._scalar, self._self_to_base_cache,\
     110        self._gram_schmidt(n, self._sf_base, self._scalar, self._self_to_base_cache,\
    111111                           leading_coeff=self._leading_coeff, upper_triangular=True)
    112112        self._invert_morphism(n, self.base_ring(), self._self_to_base_cache, \
    113113                              self._base_to_self_cache, to_other_function = self._to_base)
    class SymmetricFunctionAlgebra_orthotria 
    149149            sage: s([1])*s([2,1]) #indirect doctest
    150150            s[2, 1, 1] + s[2, 2] + s[3, 1]
    151151        """
    152         return self( self._base(left)*self._base(right) )
     152        return self( self._sf_base(left)*self._sf_base(right) )
    153153
    154154
    155155class SymmetricFunctionAlgebraElement_orthotriang(sfa.SymmetricFunctionAlgebraElement_generic):
  • sage/crypto/cryptosystem.py

    diff -r 19b2ada8a983 -r fa73e4213671 sage/crypto/cryptosystem.py
    a b Cryptosystems. 
    1010#                  http://www.gnu.org/licenses/
    1111#*****************************************************************************
    1212
     13import sage.structure.parent_old as parent_old
    1314from sage.sets.set import Set_generic
    1415
    15 class Cryptosystem(Set_generic):
     16class Cryptosystem(parent_old.Parent, Set_generic):
    1617      r"""
    1718      A cryptosystem is a pair of maps
    1819      $$
  • sage/crypto/stream.py

    diff -r 19b2ada8a983 -r fa73e4213671 sage/crypto/stream.py
    a b class LFSRCryptosystem(SymmetricKeyCrypt 
    3838
    3939        TESTS:
    4040            sage: E = LFSRCryptosystem(FiniteField(2))
    41             sage: E == loads(dumps(E))
     41            sage: E == loads(dumps(E))
    4242            True
    4343
    4444
  • sage/rings/complex_double.pyx

    diff -r 19b2ada8a983 -r fa73e4213671 sage/rings/complex_double.pyx
    a b cdef class ComplexDoubleField_class(sage 
    284284        else:
    285285            return ComplexDoubleElement(x, im)
    286286
    287     cdef coerce_map_from_c(self, S):
     287    cpdef coerce_map_from_c(self, S):
    288288        from integer_ring import ZZ
    289289        from rational_field import QQ
    290290        import real_mpfr
  • sage/rings/polynomial/pbori.pyx

    diff -r 19b2ada8a983 -r fa73e4213671 sage/rings/polynomial/pbori.pyx
    a b cdef class BooleanMonomial(MonoidElement 
    14881488            if d.has_key(i):
    14891489                res *= d[i]
    14901490            else:
    1491                 res *= self._parent.gen(i)
     1491                res *= (<object>self._parent).gen(i)
    14921492        return res
    14931493
    14941494
  • sage/rings/qqbar.py

    diff -r 19b2ada8a983 -r fa73e4213671 sage/rings/qqbar.py
    a b ax = QQbarPoly.gen() 
    47324732#     return x, y
    47334733# # heptadecagon2()   
    47344734
    4735 
    4736 RR_1_10 = RR(ZZ(1)/10)
    4737 QQ_0 = QQ(0)
    4738 QQ_1 = QQ(1)
    4739 QQ_1_2 = QQ(1)/2
    4740 QQ_1_4 = QQ(1)/4
    4741 
    4742 AA_0 = AA(0)
    4743 
    4744 QQbar_I_nf = QuadraticField(-1, 'I')
    4745 # XXX change ANRoot to ANRootOfUnity below
    4746 QQbar_I_generator = AlgebraicGenerator(QQbar_I_nf, ANRoot(AAPoly.gen()**2 + 1, CIF(0, 1)))
    4747 QQbar_I = AlgebraicNumber(ANExtensionElement(QQbar_I_generator, QQbar_I_nf.gen()))
    4748 _cyclotomic_gen_cache[4] = QQbar_I_generator
    4749 QQbar_I_generator.set_cyclotomic(4)
    4750 
    4751 AA_hash_offset = AA(~ZZ(123456789))
    4752 
    4753 QQbar_hash_offset = AlgebraicNumber(ANExtensionElement(QQbar_I_generator, ~ZZ(123456789) + QQbar_I_nf.gen()/ZZ(987654321)))
    4754 
    4755 ZZX_x = ZZ['x'].gen()
     4735def _init_qqbar():
     4736    """
     4737    This code indirectly uses a huge amount of sage, dispite the fact
     4738    that qqbar is imported rather early on in the sage loading. This function
     4739    is called at the end of sage.all.
     4740    """
     4741    global ZZX_x, AA_0, QQbar_I, AA_hash_offset, QQbar_hash_offset, QQbar_I_generator, QQbar_I_nf
     4742    global QQ_0, QQ_1, QQ_1_2, QQ_1_4, RR_1_10
     4743   
     4744    RR_1_10 = RR(1)/10
     4745    QQ_0 = QQ(0)
     4746    QQ_1 = QQ(1)
     4747    QQ_1_2 = QQ(1)/2
     4748    QQ_1_4 = QQ(1)/4
     4749
     4750    AA_0 = AA(0)
     4751
     4752    QQbar_I_nf = QuadraticField(-1, 'I')
     4753    # XXX change ANRoot to ANRootOfUnity below
     4754    QQbar_I_generator = AlgebraicGenerator(QQbar_I_nf, ANRoot(AAPoly.gen()**2 + 1, CIF(0, 1)))
     4755    QQbar_I = AlgebraicNumber(ANExtensionElement(QQbar_I_generator, QQbar_I_nf.gen()))
     4756    _cyclotomic_gen_cache[4] = QQbar_I_generator
     4757    QQbar_I_generator.set_cyclotomic(4)
     4758
     4759    AA_hash_offset = AA(~ZZ(123456789))
     4760
     4761    QQbar_hash_offset = AlgebraicNumber(ANExtensionElement(QQbar_I_generator, ~ZZ(123456789) + QQbar_I_nf.gen()/ZZ(987654321)))
     4762
     4763    ZZX_x = ZZ['x'].gen()
    47564764
    47574765# This is used in the _algebraic_ method of the golden_ratio constant,
    47584766# in sage/functions/constants.py
  • sage/rings/real_double.pyx

    diff -r 19b2ada8a983 -r fa73e4213671 sage/rings/real_double.pyx
    a b cdef class RealDoubleField_class(Field): 
    172172        from sage.rings.complex_double import CDF
    173173        return CDF
    174174
    175     cdef coerce_map_from_c(self, S):
     175    cpdef coerce_map_from_c(self, S):
    176176        from integer_ring import ZZ
    177177        from rational_field import QQ
    178178        import real_mpfr
  • sage/schemes/generic/homset.py

    diff -r 19b2ada8a983 -r fa73e4213671 sage/schemes/generic/homset.py
    a b def enum_affine_finite_field(X): 
    141141#                  http://www.gnu.org/licenses/
    142142#*****************************************************************************
    143143
     144import sage.structure.parent_old as parent_old
     145
    144146from sage.categories.all import HomsetWithBase, Schemes
    145147from sage.rings.all      import (
    146148    is_FiniteField, is_RationalField, is_RingHomomorphism, ZZ)
    def SchemeHomset(R, S, cat=None, check=T 
    159161    else:
    160162        return SchemeHomset_generic(R, S, cat=cat, check=check)
    161163
    162 class SchemeHomset_generic(HomsetWithBase):
     164class SchemeHomset_generic(parent_old.Parent, HomsetWithBase):
    163165    def __init__(self, X, Y, cat=None, check=True, base=ZZ):
    164166        HomsetWithBase.__init__(self, X, Y, cat=cat, check=check, base=base)
    165167
  • sage/structure/category_object.pxd

    diff -r 19b2ada8a983 -r fa73e4213671 sage/structure/category_object.pxd
    a b cdef class CategoryObject(sage_object.Sa 
    1717cdef class CategoryObject(sage_object.SageObject):
    1818
    1919    cdef _generators
    20     cdef _categories
    21     cdef readonly _base
     20    cdef _category
     21    cdef public _base
    2222    cdef public _cdata
    2323    cdef public _names # will be _printer
    2424    cdef public _factory_data
    2525    cdef object __weakref__
    2626   
    27     cpdef Generators gens(self, category = *)
    28     cpdef gen(self, index = *, category = *)
    29     cpdef ngens(self, category = *)
    30     cpdef base(self, category = *)
    31     cpdef base_extend(self, other, category = *)
     27#    cpdef Generators gens(self, category = *)
     28#    cpdef gen(self, index = *, category = *)
     29#    cpdef ngens(self, category = *)
     30#    cpdef base(self, category = *)
     31#    cpdef base_extend(self, other, category = *)
  • sage/structure/category_object.pyx

    diff -r 19b2ada8a983 -r fa73e4213671 sage/structure/category_object.pyx
    a b cdef class CategoryObject(sage_object.Sa 
    7575    """
    7676    An object in some category.
    7777    """
    78     def __init__(self, categories, base = None):
     78    def __init__(self, category, base = None):
    7979        """
    8080        Initializes an object in a category
    8181
    8282        INPUT:
    83         categories - a list of leaf categories that this object belongs to
    84                      (eg you do not need to list AbelianGroups if you specify
    85                      Rings because there is a forgetful functor from AbelianGroups to Rings)
     83        category - The category this object belongs to. If this object belongs to multiple categories,
     84                   pass in a join category.
    8685        base - If this object has another object that should be considered a base in its primary category,
    8786               you can include that base here.
    8887        gens_with_names - if this object has generators, there are a number of ways of specifying them.
    cdef class CategoryObject(sage_object.Sa 
    9089        """
    9190        if base is not None:
    9291            self._base = base
    93         if len(categories) == 0:
     92        if category is None:
    9493            if bad_parent_warnings:
    95                 print "No categories for %s" % type(self)
    96             categories = [guess_category(self)] # so generators don't crash
    97         self._categories = list(categories)
     94                print "No category for %s" % type(self)
     95            category = guess_category(self) # so generators don't crash
     96        self._category = category
    9897        self._generators = {}
    9998       
    10099    def category(self):
    101         cat = self._categories[0]
    102         if cat is None:
     100        if self._category is None:
    103101            # COERCE TODO: we shouldn't need this
    104102            from sage.categories.all import Objects
    105             cat = Objects()
    106         return cat
     103            self._category = Objects()
     104        return self._category
    107105
    108106
    109107    ##############################################################################
    cdef class CategoryObject(sage_object.Sa 
    114112        if self._generators.has_key(category):
    115113            raise ValueError, "Generators cannot be changed after object creation."
    116114        if category is None:
    117             category = self._categories[0]
     115            category = self._category
    118116        from sage.structure.sequence import Sequence
    119117        if gens is None:
    120118            n = self._ngens_()
    cdef class CategoryObject(sage_object.Sa 
    132130        else:
    133131            gens = generators.Generators_list(self, [gens], category)
    134132        self._generators[category] = gens
    135         if category == self._categories[0]:
     133        if category == self._category:
    136134            if names is not None and self._names is None:
    137135                self._assign_names(names, ngens=gens.count(), normalize=normalize)
    138136            self._generators[category] = gens
    139137
    140     cpdef Generators gens(self, category=None):
    141         if category is None:
    142             category = self._categories[0]
    143         try:
    144             return self._generators[category]
    145         except KeyError:
    146             if category == self._categories[0]:
    147                 n = self._ngens_()
    148                 from sage.rings.infinity import infinity
    149                 if n is infinity:
    150                     gens = generators.Generators_naturals(self, category)
    151                 else:
    152                     gens = generators.Generators_finite(self, self._ngens_(), None, category)
    153             else:
    154                 gens = self._compute_generators_(category)
    155             self._generators[category] = gens
    156             return gens
    157            
    158     cpdef gen(self, index=0, category=None):
    159         return self.gens(category)[index]
    160 
    161     cpdef ngens(self, category=None):
    162         return self.gens(category).count()
     138#    cpdef Generators gens(self, category=None):
     139#        if category is None:
     140#            category = self._categories[0]
     141#        try:
     142#            return self._generators[category]
     143#        except KeyError:
     144#            if category == self._categories[0]:
     145#                n = self._ngens_()
     146#                from sage.rings.infinity import infinity
     147#                if n is infinity:
     148#                    gens = generators.Generators_naturals(self, category)
     149#                else:
     150#                    gens = generators.Generators_finite(self, self._ngens_(), None, category)
     151#            else:
     152#                gens = self._compute_generators_(category)
     153#            self._generators[category] = gens
     154#            return gens
     155#           
     156#    cpdef gen(self, index=0, category=None):
     157#        return self.gens(category)[index]
     158#
     159#    cpdef ngens(self, category=None):
     160#        return self.gens(category).count()
    163161
    164162    def _ngens_(self):
    165163        return 0
    cdef class CategoryObject(sage_object.Sa 
    362360    # Bases
    363361    #################################################################################################
    364362
    365     cpdef base(self, category=None):
    366         if category is None:
    367             return self._base
    368         else:
    369             return category._obj_base(self)
     363#    cpdef base(self, category=None):
     364#        if category is None:
     365#            return self._base
     366#        else:
     367#            return category._obj_base(self)
    370368
    371369    def has_base(self, category=None):
    372370        if category is None:
    cdef class CategoryObject(sage_object.Sa 
    374372        else:
    375373            return category._obj_base(self) is not None
    376374
    377     cpdef base_extend(self, other, category=None):
    378         """
    379         EXAMPLES:
    380             sage: QQ.base_extend(GF(7))
    381             Traceback (most recent call last):
    382             ...
    383             TypeError: base extension not defined for Rational Field
    384             sage: ZZ.base_extend(GF(7))
    385             Finite Field of size 7
    386         """
    387         try:
    388             if category is None:
    389                 method = self._categories[0].get_object_method("base_extend") # , self._categories[1:])
    390             else:
    391                 method = category.get_object_method("base_extend")
    392             return method(self)
    393         except AttributeError:
    394             raise TypeError, "base extension not defined for %s" % self
     375#    cpdef base_extend(self, other, category=None):
     376#        """
     377#        EXAMPLES:
     378#            sage: QQ.base_extend(GF(7))
     379#            Traceback (most recent call last):
     380#            ...
     381#            TypeError: base extension not defined for Rational Field
     382#            sage: ZZ.base_extend(GF(7))
     383#            Finite Field of size 7
     384#        """
     385#        try:
     386#            if category is None:
     387#                method = self._category.get_object_method("base_extend") # , self._categories[1:])
     388#            else:
     389#                method = category.get_object_method("base_extend")
     390#            return method(self)
     391#        except AttributeError:
     392#            raise TypeError, "base extension not defined for %s" % self
    395393           
    396394    def base_ring(self):
    397395        # COERCE TODO: When everything has a category, move this to the category level.
    398396        return self._base
    399    
     397       
    400398    #################################################################################################
    401399    # Automatic lookup of methods on the category.
    402400    #################################################################################################
    403401
    404     def __getattr__(self, name):
    405         """
    406         Overriding the __getattr__ method allows one to define methods for objects in a particular
    407         category by writing a correpsonding method on the category.
    408 
    409         In order to write a method called FOO that's automatically attached to a category object,
    410         write a method object_FOO on one of that object's categories.
    411 
    412         EXAMPLES:
    413         sage: G = DirichletGroup(18); G
    414         Group of Dirichlet characters of modulus 18 over Cyclotomic Field of order 6 and degree 2
    415         sage: G.generator_orders()
    416         [1, 6]
    417         sage: G.category().object_generator_orders(G)
    418         [1, 6]
    419         """
    420         if self._categories is not None:
    421             if self._categories[0] is None:
    422                 # COERCE TODO: something went wrong earlier
    423                 return object.__getattribute__(self, name)
    424             for C in self._categories:
    425                 attr = C.get_object_method(name)
    426                 if attr is not None:
    427                     if callable(attr):
    428                         return FillFirstArg(attr, self)
    429                     else:
    430                         return attr
    431         return object.__getattribute__(self, name)
     402#    def __getattr__(self, name):
     403#        """
     404#        Overriding the __getattr__ method allows one to define methods for objects in a particular
     405#        category by writing a correpsonding method on the category.
     406#
     407#        In order to write a method called FOO that's automatically attached to a category object,
     408#        write a method object_FOO on one of that object's categories.
     409#
     410#        EXAMPLES:
     411#        sage: G = DirichletGroup(18); G
     412#        Group of Dirichlet characters of modulus 18 over Cyclotomic Field of order 6 and degree 2
     413#        sage: G.generator_orders()
     414#        [1, 6]
     415#        sage: G.category().object_generator_orders(G)
     416#        [1, 6]
     417#        """
     418#        if self._category is not None:
     419#            attr = self._category.get_object_method(name)
     420#            if attr is not None:
     421#                if callable(attr):
     422#                    return FillFirstArg(attr, self)
     423#                else:
     424#                    return attr
     425#        return object.__getattribute__(self, name)
    432426
    433427    ############################################################################
    434428    # Homomorphism --
    cdef class CategoryObject(sage_object.Sa 
    511505            pass
    512506        d = dict(d)
    513507        d['_generators'] = self._generators
    514         d['_categories'] = self._categories
     508        d['_category'] = self._category
    515509        d['_base'] = self._base
    516510        d['_cdata'] = self._cdata
    517511        d['_names'] = self._names
    cdef class CategoryObject(sage_object.Sa 
    536530        try:
    537531            if version == 1:
    538532                self._generators = d['_generators']
    539                 self._categories = d['_categories']
     533                self._category = d['_category']
    540534                self._base = d['_base']
    541535                self._cdata = d['_cdata']
    542536                self._names = d['_names']
  • sage/structure/coerce.pxd

    diff -r 19b2ada8a983 -r fa73e4213671 sage/structure/coerce.pxd
    a b from element cimport Element, RingElemen 
    22from element cimport Element, RingElement, ModuleElement, CoercionModel
    33
    44from parent cimport Parent
    5 from parent_base cimport ParentWithBase
    65from sage.categories.action cimport Action
    76from sage.categories.morphism cimport Morphism
    87
  • sage/structure/coerce.pyx

    diff -r 19b2ada8a983 -r fa73e4213671 sage/structure/coerce.pyx
    a b Original elements %r (parent %s) and %r  
    525525            return self._action_maps.get(R, S, op)
    526526        except KeyError:
    527527            action = self.discover_action_c(R, S, op)
    528             action = self.verify_action(action, R, S, op)
     528            #action = self.verify_action(action, R, S, op)
    529529            self._action_maps.set(R, S, op, action)
    530530            return action
    531531           
  • sage/structure/element.pxd

    diff -r 19b2ada8a983 -r fa73e4213671 sage/structure/element.pxd
    a b  
    44# from other directories will fail.
    55
    66cimport sage.structure.sage_object
    7 from sage.structure.parent_base cimport ParentWithBase
     7from sage.structure.parent cimport Parent
    88
    99cimport sage_object
    1010import  sage_object
    1111
    1212cdef class Element(sage_object.SageObject):
    13     # TODO: If all elements have ParentWithBase, this makes
    14     #       Parent rather redundant, as one can't even construct
    15     #       elements with parent Parent.
    16     #       On the other hand, many parents don't have a "base."
    17     cdef ParentWithBase _parent
     13    cdef Parent _parent
    1814    cdef _richcmp_c_impl(left, Element right, int op)
    1915    cdef int _cmp_c_impl(left, Element right) except -2
    2016    cdef public _richcmp(self, right, int op)
    2117    cdef public _cmp(self, right)
    22     cdef _set_parent_c(self, ParentWithBase parent)
    23     cdef base_extend_c(self, ParentWithBase R)       # do *NOT* override, but OK to call directly
    24     cdef base_extend_c_impl(self, ParentWithBase R)  # OK to override, but do NOT call
    25     cdef base_extend_recursive_c(self, ParentWithBase R) # DO NOT OVERRIDE
    26     cdef base_extend_canonical_c(self, ParentWithBase R) # DO NOT OVERRIDE
    27     cdef base_extend_canonical_sym_c(self, ParentWithBase R) # DO NOT OVERRIDE
    28     cdef base_base_extend_canonical_sym_c(self, ParentWithBase R) # DO NOT OVERRIDE
     18    cdef _set_parent_c(self, Parent parent)
     19    cdef base_extend_c(self, Parent R)       # do *NOT* override, but OK to call directly
     20    cdef base_extend_c_impl(self, Parent R)  # OK to override, but do NOT call
     21    cdef base_extend_recursive_c(self, Parent R) # DO NOT OVERRIDE
     22    cdef base_extend_canonical_c(self, Parent R) # DO NOT OVERRIDE
     23    cdef base_extend_canonical_sym_c(self, Parent R) # DO NOT OVERRIDE
     24    cdef base_base_extend_canonical_sym_c(self, Parent R) # DO NOT OVERRIDE
    2925    cdef _rich_to_bool(self, int op, int r)
    3026   
    3127   
  • sage/structure/element.pyx

    diff -r 19b2ada8a983 -r fa73e4213671 sage/structure/element.pyx
    a b from types import MethodType 
    211211from types import MethodType
    212212
    213213from sage.structure.parent      cimport Parent
    214 from sage.structure.parent_base cimport ParentWithBase
    215 from sage.structure.parent_gens import is_ParentWithGens
    216214
    217215# This classes uses element.pxd.  To add data members, you
    218216# must change that file.
    cdef class Element(sage_object.SageObjec 
    281279        """
    282280        self._parent = parent
    283281
    284     cdef _set_parent_c(self, ParentWithBase parent):
     282    cdef _set_parent_c(self, Parent parent):
    285283        self._parent = parent
    286284
    287     def _make_new_with_parent_c(self, ParentWithBase parent):
     285    def _make_new_with_parent_c(self, Parent parent):
    288286        self._parent = parent
    289287        return self
    290288   
    cdef class Element(sage_object.SageObjec 
    305303        """
    306304        raise NotImplementedError
    307305           
    308     cdef base_extend_c(self, ParentWithBase R):
     306    cdef base_extend_c(self, Parent R):
    309307        if HAS_DICTIONARY(self):
    310308            return self.base_extend(R)
    311309        else:
    312310            return self.base_extend_c_impl(R)
    313311       
    314     cdef base_extend_c_impl(self, ParentWithBase R):
    315         cdef ParentWithBase V
     312    cdef base_extend_c_impl(self, Parent R):
     313        cdef Parent V
    316314        V = self._parent.base_extend(R)
    317315        return (<Parent>V)._coerce_c(self)
    318316
    cdef class Element(sage_object.SageObjec 
    322320    def base_base_extend(self, R):
    323321        return self.base_extend_c_impl(self.base_ring().base_extend(R))
    324322
    325     cdef base_extend_recursive_c(self, ParentWithBase R):
    326         cdef ParentWithBase V
    327         # Don't call _c function so we check for ParentWithBase
     323    cdef base_extend_recursive_c(self, Parent R):
     324        cdef Parent V
     325        # Don't call _c function so we check for Parent
    328326        V = self._parent.base_extend_recursive(R)
    329327        return (<Parent>V)._coerce_c(self)
    330328
    331329    def base_extend_recursive(self, R):
    332330        return self.base_extend_recursive_c(R)
    333331
    334     cdef base_extend_canonical_c(self, ParentWithBase R):
    335         cdef ParentWithBase V
     332    cdef base_extend_canonical_c(self, Parent R):
     333        cdef Parent V
    336334        V = self._parent.base_extend_canonical(R)
    337335        return (<Parent>V)._coerce_c(self)
    338336
    339337    def base_extend_canonical(self, R):
    340338        return self.base_extend_canonical_c(R)
    341339
    342     cdef base_extend_canonical_sym_c(self, ParentWithBase R):
    343         cdef ParentWithBase V
    344         # Don't call _c function so we check for ParentWithBase
     340    cdef base_extend_canonical_sym_c(self, Parent R):
     341        cdef Parent V
     342        # Don't call _c function so we check for Parent
    345343        V = self._parent.base_extend_canonical_sym(R)
    346344        return (<Parent>V)._coerce_c(self)
    347345
    348346    def base_extend_canonical_sym(self, R):
    349347        return self.base_extend_canonical_sym_c(R)
    350348
    351     cdef base_base_extend_canonical_sym_c(self, ParentWithBase R):
    352         cdef ParentWithBase V
    353         # Don't call _c function so we check for ParentWithBase
     349    cdef base_base_extend_canonical_sym_c(self, Parent R):
     350        cdef Parent V
     351        # Don't call _c function so we check for Parent
    354352        V = self.base_ring().base_extend_canonical_sym(R)
    355353        return self.base_extend(V)
    356354
    cdef class Element(sage_object.SageObjec 
    409407        if not hasattr(self,'__call__'):
    410408            return self
    411409        parent=self._parent
     410        from sage.structure.parent_gens import is_ParentWithGens
    412411        if not is_ParentWithGens(parent):
    413412            return self
    414413        variables=[]
    cdef class ModuleElement(Element): 
    873872        """
    874873        # default implementation is to try multiplying by -1.
    875874        global coercion_model
    876         return coercion_model.bin_op_c(self._parent._base(-1), self, mul)
     875        if self._parent._base is None:
     876            return coercion_model.bin_op_c(-1, self, mul)
     877        else:
     878            return coercion_model.bin_op_c(self._parent._base(-1), self, mul)
    877879       
    878880
    879881    def _neg_(ModuleElement self):
  • sage/structure/parent.pxd

    diff -r 19b2ada8a983 -r fa73e4213671 sage/structure/parent.pxd
    a b cimport sage.structure.category_object 
    1212
    1313cdef class Parent(category_object.CategoryObject):
    1414
    15     cdef public _element_class
     15    cdef public _element_constructor
    1616    cdef public _convert_method_name
    1717    cdef public bint _element_init_pass_parent
    1818    cdef public _initial_coerce_list
  • sage/structure/parent.pyx

    diff -r 19b2ada8a983 -r fa73e4213671 sage/structure/parent.pyx
    a b cdef class Parent(category_object.Catego 
    116116    in computer science.
    117117    """
    118118   
    119     def __init__(self, base=None, *, categories=[], element_class=None, gens=None, names=None, normalize=True, **kwds):
     119    def __init__(self, base=None, *, categories=[], element_constructor=None, gens=None, names=None, normalize=True, **kwds):
    120120        CategoryObject.__init__(self, categories, base)
    121121        if len(kwds) > 0:
    122122            if bad_parent_warnings:
    123123                print "Illegal keywords for %s: %s" % (type(self), kwds)
    124124        # TODO: many classes don't call this at all, but __new__ crashes SAGE
    125125        if bad_parent_warnings:
    126             if element_class is None:
    127                 print "coerce BUG: No element_class provided", type(self)
    128             elif not callable(element_class):
    129                 print "coerce BUG: Bad element_class provided", type(self), type(element_class), element_class
     126            if element_constructor is None:
     127                element_constructor = self._element_constructor_
     128            elif not callable(element_constructor):
     129                print "coerce BUG: Bad element_constructor provided", type(self), type(element_constructor), element_constructor
    130130        if gens is not None:
    131131            self._populate_generators_(gens, names, normalize)
    132132        elif names is not None:
    133133            self._assign_names(names, normalize)
    134         self._element_class = element_class
    135         if hasattr(element_class, 'init_no_parent'):
    136             self._element_init_pass_parent = not element_class.init_no_parent
    137         elif PY_TYPE_CHECK(element_class, types.MethodType):
     134        self._element_constructor = element_constructor
     135        if hasattr(element_constructor, 'init_no_parent'):
     136            self._element_init_pass_parent = not element_constructor.init_no_parent
     137        elif PY_TYPE_CHECK(element_constructor, types.MethodType):
    138138            self._element_init_pass_parent = False
    139         elif PY_TYPE_CHECK(element_class, BuiltinMethodType):
    140             self._element_init_pass_parent = element_class.__self__ is not self
     139        elif PY_TYPE_CHECK(element_constructor, BuiltinMethodType):
     140            self._element_init_pass_parent = element_constructor.__self__ is not self
    141141        else:
    142142            self._element_init_pass_parent = True
    143143        self._coerce_from_list = []
    cdef class Parent(category_object.Catego 
    192192        #print self._introspect_coerce()
    193193        d = CategoryObject.__getstate__(self)
    194194        d['_embedding'] = self._embedding
    195         d['_element_class'] = self._element_class
     195        d['_element_constructor'] = self._element_constructor
    196196        d['_convert_method_name'] = self._convert_method_name
    197197        d['_element_init_pass_parent'] = self._element_init_pass_parent
    198198        d['_initial_coerce_list'] = self._initial_coerce_list
    cdef class Parent(category_object.Catego 
    207207        except KeyError:
    208208            version = 0
    209209        if version == 1:
    210             self._element_class = d['_element_class']
     210            self._element_constructor = d['_element_constructor']
    211211            self.init_coerce(False) # Really, do we want to init this with the same initial data as before?
    212             self._populate_coercion_lists_(coerce_list=d['_initial_coerce_list'],
    213                                            action_list=d['_initial_action_list'],
    214                                            convert_list=d['_initial_convert_list'],
     212            self._populate_coercion_lists_(coerce_list=d['_initial_coerce_list'] or [],
     213                                           action_list=d['_initial_action_list'] or [],
     214                                           convert_list=d['_initial_convert_list'] or [],
    215215                                           embedding=d['_embedding'],
    216216                                           convert_method_name=d['_convert_method_name'],
    217217                                           init_no_parent=not d['_element_init_pass_parent'])
    cdef class Parent(category_object.Catego 
    316316                return self._list
    317317            except AttributeError:
    318318                return list(self.__iter__())
     319               
     320    def __nonzero__(self):
     321        return True
    319322
    320323    def __len__(self):
    321324        return len(self.list())
    cdef class Parent(category_object.Catego 
    437440            convert_method_name -- a name to look for that other elements
    438441                            can implement to create elements of self (e.g. _integer_)
    439442            init_no_parent -- if True omit passing self in as the first
    440                               argument of element_class for conversion. This is
    441                               useful if parents are unique, or element_class is
     443                              argument of element_constructor for conversion. This is
     444                              useful if parents are unique, or element_constructor is
    442445                              a bound method.
    443446        """
    444447        if not PY_TYPE_CHECK(coerce_list, list):
    cdef class Parent(category_object.Catego 
    516519        if self._convert_method_name is not None:
    517520            # handle methods like _integer_
    518521            if PY_TYPE_CHECK(S, type):
    519                 element_class = S
     522                element_constructor = S
    520523            elif PY_TYPE_CHECK(S, Parent):
    521                 element_class = (<Parent>S)._element_class
    522                 if not PY_TYPE_CHECK(element_class, type):
    523                     # if element_class is not an actual class, get the element class
    524                     element_class = type(S.an_element())
     524                element_constructor = (<Parent>S)._element_constructor
     525                if not PY_TYPE_CHECK(element_constructor, type):
     526                    # if element_constructor is not an actual class, get the element class
     527                    element_constructor = type(S.an_element())
    525528            else:
    526                 element_class = None
    527             if element_class is not None and hasattr(element_class, self._convert_method_name):
     529                element_constructor = None
     530            if element_constructor is not None and hasattr(element_constructor, self._convert_method_name):
    528531                return coerce_maps.NamedConvertMorphism(S, self, self._convert_method_name)
    529532           
    530533        if self._element_init_pass_parent:
    cdef class Parent(category_object.Catego 
    950953        """
    951954        return True
    952955
    953     cpdef base_extend(self, other, category=None):
    954         """
    955         EXAMPLES:
    956             sage: QQ.base_extend(GF(7))
    957             Traceback (most recent call last):
    958             ...
    959             TypeError: base extension not defined for Rational Field
    960             sage: ZZ.base_extend(GF(7))
    961             Finite Field of size 7
    962         """
    963         # Use the coerce map if a base extend is not defined in the category.
    964         # this is the default implementation.
    965         try:
    966             if category is None:
    967                 method = self._categories[0].get_object_method("base_extend") # , self._categories[1:])
    968             else:
    969                 method = category.get_object_method("base_extend")
    970             if method is not None:
    971                 return method(self)
    972             elif other.has_coerce_map_from(self):
    973                 return other
    974             else:
    975                 raise TypeError, "base extension not defined for %s" % self
    976         except AttributeError:
    977             raise TypeError, "base extension not defined for %s" % self
     956#    cpdef base_extend(self, other, category=None):
     957#        """
     958#        EXAMPLES:
     959#            sage: QQ.base_extend(GF(7))
     960#            Traceback (most recent call last):
     961#            ...
     962#            TypeError: base extension not defined for Rational Field
     963#            sage: ZZ.base_extend(GF(7))
     964#            Finite Field of size 7
     965#        """
     966#        # Use the coerce map if a base extend is not defined in the category.
     967#        # this is the default implementation.
     968#        try:
     969#            if category is None:
     970#                method = self._categories[0].get_object_method("base_extend") # , self._categories[1:])
     971#            else:
     972#                method = category.get_object_method("base_extend")
     973#            if method is not None:
     974#                return method(self)
     975#            elif other.has_coerce_map_from(self):
     976#                return other
     977#            else:
     978#                raise TypeError, "base extension not defined for %s" % self
     979#        except AttributeError:
     980#            raise TypeError, "base extension not defined for %s" % self
    978981
    979982############################################################################
    980983# Set baseclass --
    cdef class Set_generic(Parent): # Cannot 
    9991002
    10001003    def object(self):
    10011004        return self
     1005       
     1006    def __nonzero__(self):
     1007        return len(self) != 0
    10021008
    10031009
    10041010
    cdef class Set_PythonType_class(Set_gene 
    10321038
    10331039    def __init__(self, theType):
    10341040        from sage.categories.category_types import Sets
    1035         Set_generic.__init__(self, element_class=theType, categories=[Sets()])
     1041        Set_generic.__init__(self, element_constructor=theType, categories=[Sets()])
    10361042        self._type = theType
    10371043
    10381044    def __call__(self, x):
  • sage/structure/parent_base.pxd

    diff -r 19b2ada8a983 -r fa73e4213671 sage/structure/parent_base.pxd
    a b cimport parent_old 
    99cimport parent_old
    1010
    1111cdef class ParentWithBase(parent_old.Parent):
    12     cdef parent_old.Parent _base
    1312    # DO NOT OVERRIDE ANY OF THE FOLLOWING
    1413    cdef base_extend_recursive_c(self, ParentWithBase X)
    1514    cdef base_extend_canonical_c(self, ParentWithBase X)
  • sage/structure/parent_base.pyx

    diff -r 19b2ada8a983 -r fa73e4213671 sage/structure/parent_base.pyx
    a b cdef class ParentWithBase(parent_old.Par 
    4747#            coerce_from.append(base)
    4848        parent_old.Parent.__init__(self, coerce_from=coerce_from, actions=actions, embeddings=embeddings)
    4949        self._base = base
     50       
     51    def _richcmp(left, right, int op):
     52        return (<parent_old.Parent>left)._richcmp(right, op) # the cdef method
     53
    5054       
    5155    cdef _coerce_c_impl(self,x):
    5256       if not self._base is self:
  • sage/structure/parent_old.pxd

    diff -r 19b2ada8a983 -r fa73e4213671 sage/structure/parent_old.pxd
    a b  
    88
    99cimport parent
    1010cdef class Parent(parent.Parent):
    11 
    12     # List consisting of Morphisms (from anything to self)
    13     # and Parents for which the __call__ method of self
    14     # results in natural coercion.
    15     # Initalized at ring creation.
    16     cdef _coerce_from_list
    17     # Hashtable of everything we've (possibliy recursively) discovered so far.
    18     cdef _coerce_from_hash
    19    
    20     # List consisting of Actions (either by or on self)
    21     # and Parents for which self._rmul_ and/or self._lmul_
    22     # do the correct thing.
    23     # Initalized at ring creation.
    24     cdef _action_list
    25     # Hashtable of everything we've (possibliy recursively) discovered so far.
    26     cdef _action_hash
    2711   
    2812    # returns a Morphism from S to self, or None
    29     cdef coerce_map_from_c(self, S)
     13    cpdef coerce_map_from_c(self, S)
    3014    cdef coerce_map_from_c_impl(self, S)
    3115   
    3216    # returns the Action by/on self on/by S
    3317    # corresponding to op and self_on_left
    34     cdef get_action_c(self, S, op, bint self_on_left)
     18    cpdef get_action_c(self, S, op, bint self_on_left)
    3519    cdef get_action_c_impl(self, S, op, bint self_on_left)
    3620   
    3721   
    cdef class Parent(parent.Parent): 
    4024
    4125    #########################################
    4226    # Canonical Coercion Methods
    43     cdef has_coerce_map_from_c(self, S)
     27    cpdef has_coerce_map_from_c(self, S)
    4428    cdef has_coerce_map_from_c_impl(self, S)
    45     cdef _coerce_c(self, x)
     29    cpdef _coerce_c(self, x)
    4630    cdef _coerce_c_impl(self, x)
    4731    cdef _coerce_self_c(self, x)
    48     cdef public object __an_element
     32
    4933    cdef _an_element_c_impl(self)
    50     cdef _an_element_c(self)
     34    cpdef _an_element_c(self)
    5135
    5236    ################################################
    5337    # Comparison of parent objects
    5438    cdef _richcmp(left, right, int op)
    55     cdef int _cmp_c_impl(left, Parent right) except -2
     39    cdef int _cmp_c_impl(left, parent.Parent right) except -2
    5640
    5741
    5842
  • sage/structure/parent_old.pyx

    diff -r 19b2ada8a983 -r fa73e4213671 sage/structure/parent_old.pyx
    a b cdef class Parent(parent.Parent): 
    8484        # old
    8585        self._has_coerce_map_from = {}
    8686       
    87     def init_coerce(self):
     87    def init_coerce(self, dummy=True):
    8888        if self._coerce_from_hash is None:
    8989#            print "init_coerce() for ", type(self)
    9090            self._coerce_from_list = []
    cdef class Parent(parent.Parent): 
    133133    def coerce_map_from(self, S):
    134134        return self.coerce_map_from_c(S)
    135135   
    136     cdef coerce_map_from_c(self, S):
     136    cpdef coerce_map_from_c(self, S):
    137137        if S is self:
    138138            from sage.categories.homset import Hom
    139139            return Hom(self, self).identity()
    cdef class Parent(parent.Parent): 
    202202    def get_action(self, S, op=operator.mul, self_on_left=True):
    203203        return self.get_action_c(S, op, self_on_left)
    204204       
    205     cdef get_action_c(self, S, op, bint self_on_left):
     205    cpdef get_action_c(self, S, op, bint self_on_left):
    206206        try:
    207207            if self._action_hash is None: # this is because parent.__init__() does not always get called
    208208                self.init_coerce()
    cdef class Parent(parent.Parent): 
    351351    def _coerce_(self, x):            # Call this from Python (do not override!)
    352352        return self._coerce_c(x)
    353353   
    354     cdef _coerce_c(self, x):          # DO NOT OVERRIDE THIS (call it)
     354    cpdef _coerce_c(self, x):          # DO NOT OVERRIDE THIS (call it)
    355355        try:
    356356            P = x.parent()   # todo -- optimize
    357357            if P is self:
    cdef class Parent(parent.Parent): 
    421421    def has_coerce_map_from(self, S):
    422422        return self.has_coerce_map_from_c(S)
    423423
    424     cdef has_coerce_map_from_c(self, S):
     424    cpdef has_coerce_map_from_c(self, S):
    425425        """
    426426        Return True if there is a natural map from S to self.
    427427        Otherwise, return False.
    cdef class Parent(parent.Parent): 
    467467        """
    468468        return self._an_element_c_impl()
    469469
    470     cdef _an_element_c_impl(self):  # override this in SageX
     470    cpdef _an_element_c_impl(self):  # override this in SageX
    471471        """
    472472        Returns an element of self. Want it in sufficent generality
    473473        that poorly-written functions won't work when they're not
    cdef class Parent(parent.Parent): 
    487487        for x in ['_an_element_', 'pi', 1.2, 2, 1, 0, infinity]:
    488488            try:
    489489                return self(x)
    490             except (TypeError, NameError, NotImplementedError):
     490            except (TypeError, NameError, NotImplementedError, AttributeError, ValueError):
    491491                pass
    492492               
    493493        raise NotImplementedError, "please implement _an_element_c_impl or _an_element_impl for %s"%self
    cdef class Parent(parent.Parent): 
    495495    def _an_element(self):        # do not override this (call from Python)
    496496        return self._an_element_c()
    497497       
    498     cdef _an_element_c(self):     # do not override this (call from SageX)
     498    cpdef _an_element_c(self):     # do not override this (call from SageX)
    499499        if not self.__an_element is None:
    500500            return self.__an_element
    501501        if HAS_DICTIONARY(self):
    cdef class Parent(parent.Parent): 
    562562##             _dict = None
    563563##         return (make_parent_v0, (self.__class__, _dict, self._has_coerce_map_from))
    564564
    565     cdef int _cmp_c_impl(left, Parent right) except -2:
     565    cdef int _cmp_c_impl(left, parent.Parent right) except -2:
    566566        pass
    567567        # this would be nice to do, but we can't since
    568568        # it leads to infinite recurssions -- and is slow -- and this
  • sage/structure/wrapper_parent.pxd

    diff -r 19b2ada8a983 -r fa73e4213671 sage/structure/wrapper_parent.pxd
    a b from sage.structure.parent_base cimport  
    1 from sage.structure.parent_base cimport ParentWithBase
     1from sage.structure.parent cimport Parent
    22from sage.categories.morphism cimport Morphism
    33from sage.structure.element cimport AlgebraElement, Element, ModuleElement, RingElement
    44
    55cdef class StealMorphism(Morphism):
    66    cdef Element _call_c_impl(self, Element x)
    77
    8 cdef class WrapperParent_model0(ParentWithBase):
    9     cdef ParentWithBase R
     8cdef class WrapperParent_model0(Parent):
     9    cdef Parent R
    1010
    11 cdef class WrapperParent_model1(ParentWithBase):
    12     cdef ParentWithBase R
     11cdef class WrapperParent_model1(Parent):
     12    cdef Parent R
    1313
    1414cdef class WrapperElement(AlgebraElement):
    1515    cdef Element val
    1616    cdef _richcmp_c_impl(left, Element right, int op)
    1717    cdef int _cmp_c_impl(left, Element right) except -2
    18     cdef base_extend_c_impl(self, ParentWithBase R)
     18    cdef base_extend_c_impl(self, Parent R)
    1919    cdef ModuleElement _add_c_impl(self, ModuleElement right)
    2020    cdef ModuleElement _sub_c_impl(self, ModuleElement right)
    2121    cdef ModuleElement _neg_c_impl(self)                   
  • sage/structure/wrapper_parent.pyx

    diff -r 19b2ada8a983 -r fa73e4213671 sage/structure/wrapper_parent.pyx
    a b cdef class StealMorphism(Morphism): 
    6868        y = copy.copy(x)
    6969        return (<Element>y)._make_new_with_parent_c(self.codomain())
    7070
    71 cdef class WrapperParent_model0(ParentWithBase):
     71cdef class WrapperParent_model0(Parent):
    7272    """
    7373    This class is designed to wrap around unique parents to provide facility for different coercions, actions and embeddings.
    7474
    cdef class WrapperParent_model0(ParentWi 
    8181        stealS = StealMorphism(Hom(R, self, cat))
    8282        stealR = StealMorphism(Hom(self, R, cat))
    8383        # need to modify actions
    84         ParentWithBase.__init__(self, R.base(), [stealS * f for f in coerce_from], actions, [f * stealR for f in embeddings])
     84        Parent.__init__(self, R.base(), [stealS * f for f in coerce_from], actions, [f * stealR for f in embeddings])
    8585
    8686    def __call__(self, x):
    8787        """
    cdef class WrapperParent_model0(ParentWi 
    104104        try:
    105105            return self.R.__getattribute__(name)
    106106        except AttributeError:
    107             return ParentWithBase.__getattribute__(name)
     107            return Parent.__getattribute__(name)
    108108
    109 cdef class WrapperParent_model1(ParentWithBase):
     109cdef class WrapperParent_model1(Parent):
    110110    """
    111111    """
    112112    def __init__(self, R, cat = None, coerce_from = [], actions = [], embeddings = []):
    cdef class WrapperParent_model1(ParentWi 
    116116        stealS = CallMorphism(Hom(R, self, cat))
    117117        stealR = CallMorphism(Hom(self, R, cat))
    118118        # need to modify actions
    119         ParentWithBase.__init__(self, R.base(), [stealS * f for f in coerce_from], actions, [f * stealR for f in embeddings])
     119        Parent.__init__(self, R.base(), [stealS * f for f in coerce_from], actions, [f * stealR for f in embeddings])
    120120
    121121    def __call__(self, x):
    122122        """
    cdef class WrapperParent_model1(ParentWi 
    141141        try:
    142142            return self.R.__getattribute__(name)
    143143        except AttributeError:
    144             return ParentWithBase.__getattribute__(name)
     144            return Parent.__getattribute__(name)
    145145
    146146cdef class WrapperElement(AlgebraElement):
    147147    """
    cdef class WrapperElement(AlgebraElement 
    172172        return (<Element>left.val)._richcmp_c(right, op)
    173173    cdef int _cmp_c_impl(left, Element right):
    174174        return (<Element>left.val)._cmp_c(right)
    175     cdef base_extend_c_impl(self, ParentWithBase R):
     175    cdef base_extend_c_impl(self, Parent R):
    176176        return (<Element>self.val).base_extend_c(R)
    177177    cdef ModuleElement _add_c_impl(self, ModuleElement right):
    178178        return self.val + (<WrapperElement>right).val
  • setup.py

    diff -r 19b2ada8a983 -r fa73e4213671 setup.py
    a b ext_modules = [ \ 
    500500    Extension('sage.structure.generators',
    501501              sources = ['sage/structure/generators.pyx']), \
    502502
     503    Extension('sage.structure.coerce',
     504              sources = ['sage/structure/coerce.pyx']), \
     505
     506    Extension('sage.structure.coerce_dict',
     507              sources = ['sage/structure/coerce_dict.pyx']), \
     508
     509    Extension('sage.structure.element',
     510              sources = ['sage/structure/element.pyx']), \
     511
     512    Extension('sage.categories.morphism',
     513              sources = ['sage/categories/morphism.pyx']), \
     514             
    503515    free_module_element,
    504516   
    505517    complex_double_vector,
    ext_modules = [ \ 
    631643              sources = ['sage/ext/multi_modular.pyx'],
    632644              libraries=['gmp']), \
    633645
    634     Extension('sage.structure.coerce',
    635               sources = ['sage/structure/coerce.pyx']), \
    636 
    637     Extension('sage.structure.coerce_dict',
    638               sources = ['sage/structure/coerce_dict.pyx']), \
    639 
    640646    Extension('sage.modular.congroup_pyx',
    641647              sources = ['sage/modular/congroup_pyx.pyx', \
    642648                         'sage/ext/arith.pyx']), \
    643649
    644     Extension('sage.structure.element',
    645               sources = ['sage/structure/element.pyx']), \
    646 
    647     Extension('sage.categories.morphism',
    648               sources = ['sage/categories/morphism.pyx']), \
    649              
    650650    Extension('sage.categories.functor',
    651651              sources = ['sage/categories/functor.pyx']), \
    652652             
    def need_to_build(deps, f, outfile): 
    12631263    if is_newer(f, outfile):
    12641264        print '\nBuilding %s because it depends on %s.' % (outfile, f)
    12651265        return True
    1266     else:
    1267         return False
    12681266    try:
    12691267        this_deps = deps[f]
    12701268    except KeyError: