Ticket #11935: trac11935_share_on_base_category.patch

File trac11935_share_on_base_category.patch, 3.2 KB (added by nthiery, 8 years ago)
  • sage/categories/bimodules.py

    # HG changeset patch
    # User Nicolas M. Thiery <nthiery@users.sf.net>
    # Date 1335967705 -7200
    # Node ID bac3fe47020c4854ae21f0526ae96d2e1b757630
    # Parent  ee1c76488647c6947c8dddc238235e82c6958ed7
    [mq]: trac11935_share_on_base_category.patch
    
    diff --git a/sage/categories/bimodules.py b/sage/categories/bimodules.py
    a b class Bimodules(CategoryWithParameters): 
    4949        self._left_base_ring = left_base
    5050        self._right_base_ring = right_base
    5151
     52    def _make_named_class_key(self, name):
     53        return (self._left_base_ring.category(), self._right_base_ring.category())
     54
    5255    @classmethod
    5356    def an_instance(cls):
    5457        """
  • sage/categories/category.py

    diff --git a/sage/categories/category.py b/sage/categories/category.py
    a b class CategoryWithParameters(Category): 
    17861786        False
    17871787
    17881788    """
    1789     def _make_named_class(self, name, method_provider, cache = "ignore_reduction", **options):
     1789    def _make_named_class(self, name, method_provider, cache = False, **options):
    17901790        """
    17911791        Purpose: Create the parent/element/... class of ``self``.
    17921792
    class CategoryWithParameters(Category): 
    18521852            sage: loads(dumps(PC)) is PC
    18531853            True
    18541854        """
    1855         # Implementation: we use the cache functionality of
    1856         # dynamic_class, and specify that the result depends only on
    1857         # the classes this class is built from
    1858         # (e.g. ``self.ParentMethods`` and ``c.parent_class`` for each
    1859         # super category ``c`` of ``self``) and not on the reduction
    1860         # data (which includes ``self``).
    1861         return Category._make_named_class(self, name, method_provider,
    1862                                           cache=cache, **options)
     1855        cls = self.__class__
     1856        key = (cls, name, self._make_named_class_key(name))
     1857        try:
     1858            return self._make_named_class_cache[key]
     1859        except KeyError:
     1860            pass
     1861        result = Category._make_named_class(self, name, method_provider,
     1862                                            cache=cache, **options)
     1863        self._make_named_class_cache[key] = result
     1864        return result
     1865
     1866
     1867    @abstract_method
     1868    def _make_named_class_key(self, name):
     1869        pass
     1870
     1871    _make_named_class_cache = dict()
    18631872
    18641873    def _subcategory_hook_(self, C):
    18651874        """
    class JoinCategory(CategoryWithParameter 
    19481957            Category.__init__(self)
    19491958        self._super_categories = list(super_categories)
    19501959
     1960    def _make_named_class_key(self, name):
     1961        return tuple(getattr(cat, name) for cat in self._super_categories)
     1962
    19511963    def super_categories(self):
    19521964        """
    19531965        Returns the immediate super categories, as per :meth:`Category.super_categories`.
  • sage/categories/category_types.py

    diff --git a/sage/categories/category_types.py b/sage/categories/category_types.py
    a b class Category_over_base(CategoryWithPar 
    203203        Category.__init__(self, name)
    204204        self.__base = base
    205205
     206    def _make_named_class_key(self, name):
     207        return self.__base.category()
     208
    206209    @classmethod
    207210    def an_instance(cls):
    208211        """