CategorySet Pattern#
- class paspailleur.bip.CategorySetPattern(value: PatternValueType)#
A class representing a set of categories as a pattern.
This class extends ItemSetPattern to include operations specific to category sets, such as handling a universe of categories. But it’s also an inversion of it, meaning for an object to fall under the ItemSetPattern class, it has to fit the the descriptions of all items in the set. On the other hand for an object to fall under the CategorySetPattern, it needs only fit to one item in the set.
Attributes#
- PatternValueType:
The type of the pattern’s value, which is a frozenset.
- Universe: Optional[frozenset]
The set of all possible categories.
Properties#
- atomic_patterns
Return the set of all less precise patterns that cannot be obtained by intersection of other patterns.
- min_pattern
Return the minimal possible pattern for the category set pattern.
- max_pattern
Return the maximal possible pattern for the category set pattern.
- PatternValueType#
alias of
frozenset
- atomise(atoms_configuration: Literal['min', 'max'] = 'min') set[Self] #
Split the pattern into atomic patterns, i.e. CategorySets that exclude just one category from the minimal pattern
- Parameters:
atoms_configuration (Literal['min', 'max']) – Specifically for CategorySetPattern, the value of atoms_configuration parameter does not affect the output of the function.
- Returns:
atomic_patterns – The set of atomic patterns, i.e. the set of unsplittable patterns whose join equals to the pattern.
- Return type:
set[Self]
Notes
Speaking in terms of Ordered Set Theory: We say that every pattern can be represented as the join of a subset of atomic patterns, that are join-irreducible elements of the lattice of all patterns.
Considering the set of atomic patterns as a partially ordered set (where the order follows the order on patterns), every pattern can be represented by an •antichain* of atomic patterns (when atoms_configuration = ‘min’), and by an order ideal of atomic patterns (when atoms_configuration = ‘max’).
- property atomic_patterns: set[Self]#
Return the set of all less precise patterns that cannot be obtained by intersection of other patterns.
For a CategorySetPattern an atomic pattern is a set containing all-but-one categories.
- Returns:
atoms – A set of atomic patterns derived from the universe of categories.
- Return type:
set[Self]
- Raises:
AssertionError – If the min_pattern is not defined.
Examples
>>> p = CategorySetPattern({"A"}) >>> p.atomic_patterns {CategorySetPattern({'B'}), CategorySetPattern({'C'})} # assuming Universe={'A','B','C'}
- classmethod get_min_pattern() Self | None #
Return the minimal possible pattern for the category set pattern, i.e. CategorySet containing all categories
- Returns:
min – The minimal category set pattern or None if undefined.
- Return type:
Optional[Self]
Examples
>>> CategorySetPattern.Universe = {"A", "B", "C"} >>> CategorySetPattern.get_min_pattern() CategorySetPattern({'A', 'B', 'C'})
- classmethod get_max_pattern() Self #
Return the maximal possible pattern for the category set pattern, i.e. empty CategorySet
Empty CategorySet is the maximal possible pattern, because it does not allow for any category. That is, it is so maximal and so precise, that it should never occur in the data.
- Returns:
max – The maximal category set pattern, which is an empty CategorySet
- Return type:
Self
Examples
>>> CategorySetPattern.get_max_pattern() CategorySetPattern(frozenset())