Skip to content

Commit

Permalink
Fix a few things
Browse files Browse the repository at this point in the history
  • Loading branch information
user202729 committed Dec 19, 2024
1 parent df6293f commit c6b3b55
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
22 changes: 21 additions & 1 deletion src/sage/categories/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,20 @@ def all_super_categories(self, proper=False):
appropriate. Simply because lazy attributes are much
faster than any method.
.. NOTE::
This is not the same as the concept of super category in mathematics.
In fact, this is not even the opposite relation of :meth:`is_subcategory`::
sage: A = VectorSpaces(QQ); A
Category of vector spaces over Rational Field
sage: B = VectorSpaces(QQ.category()); B
Category of vector spaces over (number fields and quotient fields and metric spaces)
sage: A.is_subcategory(B)
True
sage: B in A.all_super_categories()
False
EXAMPLES::
sage: C = Rings(); C
Expand Down Expand Up @@ -1757,7 +1771,7 @@ def required_methods(self):
# Operations on the lattice of categories
def is_subcategory(self, c):
"""
Return ``True`` if ``self`` is naturally embedded as a subcategory of `c`.
Return ``True`` if there is a natural forgetful functor from ``self`` to `c`.
EXAMPLES::
Expand Down Expand Up @@ -2810,6 +2824,12 @@ def _make_named_class(self, name, method_provider, cache=False, **options):
pass
result = Category._make_named_class(self, name, method_provider,
cache=cache, **options)
# the object in the parameter may have had its category refined, which modifies the key, needs to recompute
# (problem with mutable objects)
key = (cls, name, self._make_named_class_key(name))
if key in self._make_named_class_cache:
# throw result away and use cached value
return self._make_named_class_cache[key]
self._make_named_class_cache[key] = result
return result

Expand Down
11 changes: 9 additions & 2 deletions src/sage/categories/filtered_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,14 @@ def _make_named_class_key(self, name):
<class 'sage.categories.vector_spaces.VectorSpaces.Filtered.parent_class'>
sage: ModulesQQ.Filtered().parent_class
<class 'sage.categories.filtered_modules.FilteredModules.parent_class'>
Nevertheless, as explained in :meth:`.Category_over_base._make_named_class_key`,
``Modules(QQ).Filtered()`` and ``Modules(QQ.category()).Filtered()`` must have
the same parent class::
sage: Modules(QQ).Filtered().parent_class == Modules(QQ.category()).Filtered().parent_class

Check failure on line 113 in src/sage/categories/filtered_modules.py

View workflow job for this annotation

GitHub Actions / test-new

Failed example:

Failed example:: Got: True
"""
return self._base_category
return (type(self._base_category).__base__, super()._make_named_class_key(name))


class FilteredModules(FilteredModulesCategory):
Expand Down Expand Up @@ -163,8 +169,9 @@ def extra_super_categories(self):
"""
from sage.categories.modules import Modules
from sage.categories.fields import Fields
from sage.categories.category import Category
base_ring = self.base_ring()
if base_ring in Fields():
if base_ring in Fields() or (isinstance(base_ring, Category) and base_ring.is_subcategory(Fields())):
return [Modules(base_ring)]
else:
return []
Expand Down

0 comments on commit c6b3b55

Please sign in to comment.