#10963: More functorial constructions
-------------------------------------+-------------------------------------
Reporter: nthiery | Owner: stumpc5
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-5.13
Component: categories | Resolution:
Keywords: | Merged in:
Authors: Nicolas M. Thiéry | Reviewers: Simon King, Frédéric
Report Upstream: N/A | Chapoton
Branch: | Work issues:
Dependencies: #11224, #8327, | Commit:
#10193, #12895, #14516, #14722, | Stopgaps:
#13589, #14471, #15069, #15094, |
#11688 |
-------------------------------------+-------------------------------------
Comment (by SimonKing):
The following did not apply (clearly, because it mentions `weakref`, which
is not used any longer because of #13394).
{{{
#!patch
diff a/src/sage/categories/category.py b/src/sage/categories/category.py
(rejected hunks)
@@ -106,66 +107,13 @@ from sage.structure.sage_object import S
from sage.structure.unique_representation import UniqueRepresentation
from sage.structure.dynamic_class import DynamicMetaclass, dynamic_class
-from weakref import WeakValueDictionary
-_join_cache = WeakValueDictionary()
-
-def _join(categories, as_list):
- """
- This is an auxiliary function for :meth:`Category.join`
-
- INPUT:
-
- - ``categories``: A tuple (no list) of categories.
- - ``as_list`` (boolean): Whether or not the result should be
represented as a list.
-
- EXAMPLES::
-
- sage: Category.join((Groups(), CommutativeAdditiveMonoids())) #
indirect doctest
- Join of Category of groups and Category of commutative additive
monoids
- sage: Category.join((Modules(ZZ), FiniteFields()), as_list=True)
- [Category of finite fields, Category of modules over Integer
Ring]
-
- """
- # Since Objects() is the top category, it is the neutral element of
join
- if len(categories) == 0:
- from objects import Objects
- return Objects()
-
- if not as_list:
- try:
- return _join_cache[categories]
- except KeyError:
- pass
-
- # Ensure associativity by flattening JoinCategory's
- # Invariant: the super categories of a JoinCategory are not
JoinCategories themselves
- categories = sum( (tuple(category._super_categories) if
isinstance(category, JoinCategory) else (category,)
- for category in categories), ())
-
- # canonicalize, by removing redundant categories which are super
- # categories of others, and by sorting
- result = ()
- for category in categories:
- if any(cat.is_subcategory(category) for cat in result):
- continue
- result = tuple( cat for cat in result if not
category.is_subcategory(cat) ) + (category,)
- result = tuple(sorted(result, key = category_sort_key, reverse=True))
- if as_list:
- return list(result)
- if len(result) == 1:
- out = _join_cache[categories] = result[0]
- else:
- out = _join_cache[categories] = JoinCategory(result)
- return out
-
-
class Category(UniqueRepresentation, SageObject):
r"""
The base class for modeling mathematical categories, like for
example:
- - Groups(): the category of groups
- - EuclideanRings(): the category of euclidean rings
- - VectorSpaces(QQ): the category of vector spaces over the field of
rational
+ - ``Groups()``: the category of groups
+ - ``EuclideanDomains()``: the category of euclidean rings
+ - ``VectorSpaces(QQ)``: the category of vector spaces over the field
of rational
See :mod:`sage.categories.primer` for an introduction to
categories in Sage, their relevance, purpose and usage. The
}}}
Do I understand correctly that you want to remove the `_join_cache` weak
value dictionary and the `def _join` function entirely?
--
Ticket URL: <http://trac.sagemath.org/ticket/10963#comment:143>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.