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

Commit

Permalink
17160: fixed category for finite set endomaps + minor __init__ refact…
Browse files Browse the repository at this point in the history
…oring
  • Loading branch information
nthiery committed Mar 13, 2015
1 parent cf9b429 commit aff2689
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/sage/sets/finite_set_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
from sage.rings.integer import Integer
from sage.structure.unique_representation import UniqueRepresentation
from sage.categories.sets_cat import Sets, EmptySetError
from sage.categories.finite_monoids import FiniteMonoids
from sage.categories.finite_enumerated_sets import FiniteEnumeratedSets
from sage.categories.monoids import Monoids
from sage.categories.enumerated_sets import EnumeratedSets
from sage.sets.finite_enumerated_set import FiniteEnumeratedSet
from sage.combinat.cartesian_product import CartesianProduct
from sage.sets.integer_range import IntegerRange
Expand Down Expand Up @@ -117,7 +117,7 @@ class FiniteSetMaps(UniqueRepresentation, Parent):
This makes `M` into a monoid::
sage: M.category()
Category of finite monoids
Join of Category of finite monoids and Category of finite enumerated sets
sage: M.one()
map: 1 -> 1, 2 -> 2, 3 -> 3
Expand Down Expand Up @@ -216,7 +216,7 @@ class FiniteSetMaps_MN(FiniteSetMaps):
- ``category`` -- the category in which the sets of maps is
constructed. It must be a sub-category of
``FiniteEnumeratedSets()`` which is the default value.
``EnumeratedSets().Finite()`` which is the default value.
"""

def __init__(self, m, n, category=None):
Expand All @@ -231,7 +231,7 @@ def __init__(self, m, n, category=None):
sage: TestSuite(M).run()
"""
Parent.__init__(self,
category=FiniteEnumeratedSets().or_subcategory(category))
category=EnumeratedSets().Finite().or_subcategory(category))
self._m = Integer(m)
self._n = Integer(n)

Expand Down Expand Up @@ -378,8 +378,8 @@ class FiniteSetMaps_Set(FiniteSetMaps_MN):
- ``codomain`` -- an object in the category ``FiniteSets()``.
- ``category`` -- the category in which the sets of maps is
constructed. It must be a sub-category of ``FiniteEnumeratedSets()``
which is the default value.
constructed. It must be a sub-category of
``EnumeratedSets().Finite`` which is the default value.
"""
def __init__(self, domain, codomain, category=None):
"""
Expand Down Expand Up @@ -488,8 +488,8 @@ class FiniteSetEndoMaps_N(FiniteSetMaps_MN):
- ``n`` -- an integer.
- ``category`` -- the category in which the sets of maps is
constructed. It must be a sub-category of ``FiniteMonoids()``
which is the default value.
constructed. It must be a sub-category of ``Monoids().Finite()``
and ``EnumeratedSets().Finite()`` which is the default value.
"""

def __init__(self, n, action, category=None):
Expand All @@ -498,14 +498,13 @@ def __init__(self, n, action, category=None):
sage: M = FiniteSetMaps(3)
sage: M.category()
Category of finite monoids
Join of Category of finite monoids and Category of finite enumerated sets
sage: M.__class__
<class 'sage.sets.finite_set_maps.FiniteSetEndoMaps_N_with_category'>
sage: TestSuite(M).run()
"""
Parent.__init__(self, category=FiniteMonoids().or_subcategory(category))
self._m = n
self._n = n
category = (EnumeratedSets() & Monoids().Finite()).or_subcategory(category)
FiniteSetMaps_MN.__init__(self, n, n, category=category)
self._action = action

@cached_method
Expand Down Expand Up @@ -554,22 +553,23 @@ class FiniteSetEndoMaps_Set(FiniteSetMaps_Set, FiniteSetEndoMaps_N):
- ``domain`` -- an object in the category ``FiniteSets()``.
- ``category`` -- the category in which the sets of maps is
constructed. It must be a sub-category of ``FiniteMonoids()``
which is the default value.
constructed. It must be a sub-category of ``Monoids().Finite()``
and ``EnumeratedSets().Finite()`` which is the default value.
"""
def __init__(self, domain, action, category=None):
"""
TESTS::
sage: M = FiniteSetMaps(["a", "b", "c"])
sage: M.category()
Category of finite monoids
Join of Category of finite monoids and Category of finite enumerated sets
sage: M.__class__
<class 'sage.sets.finite_set_maps.FiniteSetEndoMaps_Set_with_category'>
sage: TestSuite(M).run()
"""
category = (EnumeratedSets() & Monoids().Finite()).or_subcategory(category)
FiniteSetMaps_MN.__init__(self, domain.cardinality(), domain.cardinality(),
category=FiniteMonoids().or_subcategory(category))
category=category)

self._domain = domain
self._codomain = domain
Expand Down

0 comments on commit aff2689

Please sign in to comment.