# HG changeset patch
# User Nicolas M. Thiery <nthiery@users.sf.net>
# Date 1383074059 3600
# Tue Oct 29 20:14:19 2013 +0100
# Node ID e374533eb4a23dfff21146ffe4834ae93ca70769
# Parent 599ab9a6bd8d8015fb6c6247fcfbd27912c9f0d3
#10963: More functorial constructions (fix graded modules with basis)
diff git a/sage/categories/graded_modules.py b/sage/categories/graded_modules.py
a

b

class GradedModules(GradedModulesCategor 
134  134  sage: TestSuite(GradedModules(ZZ)).run() 
135  135  """ 
136  136  
 137  def extra_super_categories(self): 
 138  r""" 
 139  Adds VectorSpaces to the super categories of ``self`` if the base ring is a field 
 140  
 141  EXAMPLES:: 
 142  
 143  sage: Modules(QQ).Graded().extra_super_categories() 
 144  [Category of vector spaces over Rational Field] 
 145  sage: Modules(ZZ).Graded().extra_super_categories() 
 146  [] 
 147  
 148  This makes sure that ``Modules(QQ).Graded()`` returns an 
 149  instance of :class:`GradedModules` and not a join category of 
 150  an instance of this class and of ``VectorSpaces(QQ)``:: 
 151  
 152  sage: type(Modules(QQ).Graded()) 
 153  <class 'sage.categories.graded_modules.GradedModules_with_category'> 
 154  
 155  .. TODO:: 
 156  
 157  Get rid of this workaround once there is a more systematic 
 158  approach for the alias ``Modules(QQ)`` > ``VectorSpaces(QQ)``. 
 159  Probably the later should be a category with axiom, and 
 160  covariant constructions should play well with axioms. 
 161  """ 
 162  from sage.categories.modules import Modules 
 163  from sage.categories.fields import Fields 
 164  base_ring = self.base_ring() 
 165  if base_ring in Fields: 
 166  return [Modules(base_ring)] 
 167  else: 
 168  return [] 
 169  
137  170  class SubcategoryMethods: 
138  171  
139  172  @cached_method 
diff git a/sage/misc/c3_controlled.pyx b/sage/misc/c3_controlled.pyx
a

b

For a typical category, few bases, if an 
324  324  sage: x.all_bases_len() 
325  325  83 
326  326  sage: x.all_bases_controlled_len() 
327   92 
 327  90 
328  328  
329  329  The following can be used to search through the Sage named categories 
330  330  for any that requires the addition of some bases; currently none!:: 
… 
… 
for any that requires the addition of so 
336  336  Category of fields, 
337  337  Category of finite dimensional algebras with basis over Rational Field, 
338  338  Category of finite dimensional hopf algebras with basis over Rational Field, 
339   Category of graded algebras over Rational Field, 
340   Category of graded algebras with basis over Rational Field, 
341  339  Category of graded hopf algebras with basis over Rational Field, 
342  340  Category of hopf algebras with basis over Rational Field] 
343  341  