Ticket #9944: 9944-poly-cat.patch

File 9944-poly-cat.patch, 3.0 KB (added by robertwb, 9 years ago)
  • sage/categories/principal_ideal_domains.py

    # HG changeset patch
    # User Robert Bradshaw <robertwb@math.washington.edu>
    # Date 1284849691 25200
    # Node ID eec399f88e2219466677cb7502950eaf982a102c
    # Parent  117000f776a9b985d9a3e3254d75fe1807918e8e
    #9944 - Categories for polynomial rings.
    
    diff -r 117000f776a9 -r eec399f88e22 sage/categories/principal_ideal_domains.py
    a b  
    99#******************************************************************************
    1010
    1111from sage.categories.category import Category
    12 from sage.categories.basic import GcdDomains
    1312from sage.misc.cachefunc import cached_method
    1413
    1514class PrincipalIdealDomains(Category):
     
    2726      sage: PrincipalIdealDomains()
    2827      Category of principal ideal domains
    2928      sage: PrincipalIdealDomains().super_categories()
    30       [Category of gcd domains]
     29      [Category of unique factorization domains]
    3130
    3231    See also: http://en.wikipedia.org/wiki/Principal_ideal_domain
    3332
     
    4241        EXAMPLES::
    4342
    4443            sage: PrincipalIdealDomains().super_categories()
    45             [Category of gcd domains]
     44            [Category of unique factorization domains]
    4645        """
    47         return [GcdDomains()]
     46        from sage.categories.basic import UniqueFactorizationDomains
     47        return [UniqueFactorizationDomains()]
    4848
    4949    class ParentMethods:
    5050        pass
  • sage/rings/polynomial/polynomial_ring.py

    diff -r 117000f776a9 -r eec399f88e22 sage/rings/polynomial/polynomial_ring.py
    a b  
    9494
    9595from sage.structure.element import Element
    9696import sage.algebras.algebra
     97import sage.categories.basic as categories
    9798import sage.rings.commutative_ring as commutative_ring
    9899import sage.rings.commutative_algebra as commutative_algebra
    99100import sage.rings.ring as ring
     
    183184            0
    184185            sage: (x - 2/3)*(x^2 - 8*x + 16)
    185186            x^3 - 26/3*x^2 + 64/3*x - 32/3
     187           
     188            sage: category(ZZ['x'])
     189            Category of unique factorization domains
     190            sage: category(GF(7)['x'])
     191            Category of euclidean domains
    186192        """
    187         sage.algebras.algebra.Algebra.__init__(self, base_ring, names=name, normalize=True)
     193        R_cat = base_ring.category()
     194        if R_cat.is_subcategory(categories.Fields()):
     195            category = categories.EuclideanDomains()
     196        elif R_cat.is_subcategory(categories.UniqueFactorizationDomains()):
     197            category = categories.UniqueFactorizationDomains()
     198        elif R_cat.is_subcategory(categories.IntegralDomains()):
     199            category = categories.IntegralDomains()
     200        else:
     201            category = categories.CommutativeRings()
     202        sage.algebras.algebra.Algebra.__init__(self, base_ring, names=name, normalize=True, category=category)
    188203        self.__is_sparse = sparse
    189204        if element_class:
    190205            self._polynomial_class = element_class