Finite Enumerated Sets

class sage.categories.finite_enumerated_sets.FiniteEnumeratedSets(s=None)

Bases: sage.categories.category.Category

The category of finite enumerated sets

EXAMPLES:

sage: FiniteEnumeratedSets()
Category of finite enumerated sets
sage: FiniteEnumeratedSets().super_categories()
[Category of enumerated sets]
sage: FiniteEnumeratedSets().all_super_categories()
[Category of finite enumerated sets,
 Category of enumerated sets,
 Category of sets,
 Category of sets with partial maps,
 Category of objects]

TESTS:

sage: C = FiniteEnumeratedSets()
sage: TestSuite(C).run()
class IsomorphicObjects(category, *args)

Bases: sage.categories.isomorphic_objects.IsomorphicObjectsCategory

ParentMethods
alias of IsomorphicObjects.ParentMethods
example()

Returns an example of isomorphic object of a finite enumerated set, as per Category.example.

EXAMPLES:

sage: FiniteEnumeratedSets().IsomorphicObjects().example()
The image by some isomorphism of An example of a finite enumerated set: {1,2,3}
class FiniteEnumeratedSets.ParentMethods
cardinality()

The cardinality of self.

self.cardinality() returns the cardinality of the set self as a sage Integer or as +Infinity.

This is the default (brute force) implementation from the category FiniteEnumeratedSet(). It iterates through the elements of self to count them.

EXAMPLES:

sage: C = FiniteEnumeratedSets().example()
sage: C.cardinality() # indirect doctest
3
is_finite()

Returns True since self is finite.

EXAMPLES:

sage: C = FiniteEnumeratedSets().example()
sage: C.is_finite()
True
last(*args, **kwds)

The last element of self.

self.last() returns the last element of self.

This is the default (brute force) implementation from the category FiniteEnumeratedSet() which can be used when the method __iter__ is provided. Its complexity is O(n) where n is the size of self.

EXAMPLES:

sage: C = FiniteEnumeratedSets().example()
sage: C.last()
3
sage: C._last_from_iterator()
3
list()

The list of elements self.

self.list() returns the list of the element of the set self. This is the default implementation from the category EnumeratedSet() which builds the list from the iterator.

EXAMPLES:

sage: C = FiniteEnumeratedSets().example()
sage: C._list_from_iterator()
[1, 2, 3]
sage: C.list() # indirect doctest
[1, 2, 3]
random_element()

A random element in self.

self.random_element() returns a random element in self with uniform probability.

This is the default implementation from the category EnumeratedSet() which uses the method unrank.

EXAMPLES:

sage: C = FiniteEnumeratedSets().example()
sage: C.random_element()
1
sage: C._random_element_from_unrank()
2

TODO: implement _test_random which checks uniformness

FiniteEnumeratedSets.super_categories(*args, **kwds)

EXAMPLES:

sage: FiniteEnumeratedSets().super_categories()
[Category of enumerated sets]

Previous topic

FiniteDimensionalModulesWithBasis

Next topic

Finite Fields

This Page