Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
src/sage/categories/enumerated_families.py: New
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Sep 17, 2022
1 parent bfab550 commit 5857d9b
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 18 deletions.
63 changes: 63 additions & 0 deletions src/sage/categories/enumerated_families.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
r"""
Enumerated families
"""

#*****************************************************************************
# Copyright (C) 2022 Matthias Koeppe
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# https://www.gnu.org/licenses/
#*****************************************************************************

from sage.misc.abstract_method import abstract_method
from sage.misc.cachefunc import cached_method
from sage.categories.category_singleton import Category_singleton
from sage.categories.enumerated_sets import EnumeratedSets
from sage.categories.families import Families


class EnumeratedFamilies(Category_singleton):
r"""
The category of enumerated families
An *enumerated family* is a family whose keys are an enumerated set
that induces an enumeration of the family.
- ``F[key]``: the value (element) indexed by ``key``.
The standard methods for a family ``F`` are:
- ``F.keys()``, ``F.values()``, ``F.items()``: methods similar to those of
:class:`dict` (or :class:`collections.abc.Mapping`).
The map is not necessarily injective.
- ``iter(F)``: returns an iterator for the elements (values) of ``F`` as a set
in the same order as ``iter(F.values())``, but with duplicates removed.
EXAMPLES::
sage: from sage.categories.enumerated_families import EnumeratedFamilies
sage: from sage.categories.families import Families
sage: EnumeratedFamilies()
Category of enumerated families
sage: EnumeratedFamilies() == Families() & EnumeratedSets()
False
sage: Families() & EnumeratedSets() # BUG
Category of enumerated families
"""

def super_categories(self):
r"""
EXAMPLES::
sage: from sage.categories.enumerated_families import EnumeratedFamilies
sage: EnumeratedFamilies().super_categories()
[Category of families, Category of enumerated sets]
"""
return [Families(), EnumeratedSets()]
20 changes: 2 additions & 18 deletions src/sage/categories/families.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

from sage.misc.abstract_method import abstract_method
from sage.misc.cachefunc import cached_method
from sage.misc.lazy_import import LazyImport
from sage.categories.category_with_axiom import CategoryWithAxiom
from sage.categories.category_singleton import Category_singleton
from sage.categories.sets_cat import Sets

Expand Down Expand Up @@ -65,24 +67,6 @@ def super_categories(self):
"""
return [Sets()]

## def additional_structure(self):
## r"""
## Return ``self``.

## Indeed, the category of families defines an
## additional structure, namely the map from keys onto it,
## which shall be preserved by morphisms.

## .. SEEALSO:: :meth:`Category.additional_structure`

## EXAMPLES::

## sage: from sage.categories.families import Families
## sage: Families().additional_structure()
## Category of families
## """
## return self

class ParentMethods:

#def __getitem__(self, i):
Expand Down

0 comments on commit 5857d9b

Please sign in to comment.