# HG changeset patch
# User Nicolas M. Thiery
# 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/sage/categories/graded_modules.py
+++ b/sage/categories/graded_modules.py
@@ -134,6 +134,39 @@ class GradedModules(GradedModulesCategor
sage: TestSuite(GradedModules(ZZ)).run()
"""
+ def extra_super_categories(self):
+ r"""
+ Adds VectorSpaces to the super categories of ``self`` if the base ring is a field
+
+ EXAMPLES::
+
+ sage: Modules(QQ).Graded().extra_super_categories()
+ [Category of vector spaces over Rational Field]
+ sage: Modules(ZZ).Graded().extra_super_categories()
+ []
+
+ This makes sure that ``Modules(QQ).Graded()`` returns an
+ instance of :class:`GradedModules` and not a join category of
+ an instance of this class and of ``VectorSpaces(QQ)``::
+
+ sage: type(Modules(QQ).Graded())
+
+
+ .. TODO::
+
+ Get rid of this workaround once there is a more systematic
+ approach for the alias ``Modules(QQ)`` -> ``VectorSpaces(QQ)``.
+ Probably the later should be a category with axiom, and
+ covariant constructions should play well with axioms.
+ """
+ from sage.categories.modules import Modules
+ from sage.categories.fields import Fields
+ base_ring = self.base_ring()
+ if base_ring in Fields:
+ return [Modules(base_ring)]
+ else:
+ return []
+
class SubcategoryMethods:
@cached_method
diff --git a/sage/misc/c3_controlled.pyx b/sage/misc/c3_controlled.pyx
--- a/sage/misc/c3_controlled.pyx
+++ b/sage/misc/c3_controlled.pyx
@@ -324,7 +324,7 @@ For a typical category, few bases, if an
sage: x.all_bases_len()
83
sage: x.all_bases_controlled_len()
- 92
+ 90
The following can be used to search through the Sage named categories
for any that requires the addition of some bases; currently none!::
@@ -336,8 +336,6 @@ for any that requires the addition of so
Category of fields,
Category of finite dimensional algebras with basis over Rational Field,
Category of finite dimensional hopf algebras with basis over Rational Field,
- Category of graded algebras over Rational Field,
- Category of graded algebras with basis over Rational Field,
Category of graded hopf algebras with basis over Rational Field,
Category of hopf algebras with basis over Rational Field]