Concepts¶
The galactic.concepts
module contains several classes for exploring lattices
using context:
Concept
class is used to represent collections of objects that share a set of predicates;Descriptors
class is used to represent descriptors of a concept;Individuals
is used to represent the individuals that belong to a concept;
-
class
galactic.concepts.
Descriptors
(values: Optional[Mapping[galactic.descriptions.main.Description, Iterable[galactic.descriptions.main.Predicate]]] = None)¶ Bases:
collections.abc.Mapping
The
Descriptors
class is used to represent each description by a collection of predicates.-
__init__
(values: Optional[Mapping[galactic.descriptions.main.Description, Iterable[galactic.descriptions.main.Predicate]]] = None)¶ Initialise a
Descriptors
instance.
-
predicates
() → Iterator[galactic.descriptions.main.Predicate]¶ Get an iterator over the predicates.
- Returns
- Return type
-
-
class
galactic.concepts.
Individuals
(concept: galactic.concepts.main.Concept)¶ Bases:
collections.abc.Mapping
The
Individuals
class is used to represent the individuals hold by a concept.-
__init__
(concept: galactic.concepts.main.Concept)¶ Initialise an
Individuals
instance.
-
-
class
galactic.concepts.
Concept
(population: Optional[galactic.population.main.Population] = None, descriptions: Optional[Iterable[galactic.descriptions.main.Description]] = None)¶ Bases:
galactic.algebras.lattice.lattices.Element
The
Concept
class is used to represent a collection of individuals that verify anIterable
ofPredicate
instances.-
__init__
(population: Optional[galactic.population.main.Population] = None, descriptions: Optional[Iterable[galactic.descriptions.main.Description]] = None)¶ Initialise a
Concept
instance.- Keyword Arguments
population (
Population
) – The context populationdescriptions (
Iterable[Description]
) – An iterable ofDescription
instances.
- Raises
-
optimize
() → galactic.concepts.main.Concept¶ The
optimize()
method optimize a concept by only keeping a set of necessary predicates.- Returns
self for chaining
- Return type
-
compare
(other: galactic.concepts.main.Concept, keys: Optional[Collection[Any]] = None) → Any¶ Compare the concept to the other using a collection of individuals.
- Returns
int
–Concept.EQUAL
(0b00) if the concepts are equal.Concept.INF
(0b01) if the concept is lesser than the otherConcept.SUP
(0b10) if the concept is greater than the otherConcept.INCOMPARABLE
(0b11) if the concept is not comparable to the other
NotImplementedType
– If the comparison is not implemented
-
is_comparable
(other: Any) → Any¶ Test if this element is comparable to the other.
-
__and__
(other: Any) → galactic.concepts.main.Concept¶ Return the meet of this element and the other.
- Parameters
other (
Concept
) – the other element- Returns
Concept
– the meet of this element and the otherNotImplementedType
–NotImplemented
if the other concept is either not a concept or either not constructed with the same population.
-
__or__
(other: Any) → galactic.concepts.main.Concept¶ Return the join of this element and the other.
- Parameters
other (
Concept
) – the other element- Returns
Concept
– the join of this element and the otherNotImplementedType
–NotImplemented
if the other concept is either not a concept or either not constructed with the same population.
-
predicates
() → Iterator[galactic.descriptions.main.Predicate]¶ Get the predicates.
- Returns
The predicates.
- Return type
-
selectors
() → Iterator[galactic.descriptions.main.Predicate]¶ Get the selectors.
- Returns
The selectors.
- Return type
-
descriptors
() → galactic.concepts.main.Descriptors¶ Get the descriptors.
- Returns
The descriptors.
- Return type
-
individuals
() → galactic.concepts.main.Individuals¶ Get the individuals.
- Returns
The individuals.
- Return type
-
population
() → galactic.population.main.Population¶ Get the population.
- Returns
The population.
- Return type
Population
-
-
class
galactic.concepts.
ConceptRenderer
(fill_color: str = '#ffffff', anonymous_color: str = '#d3d3d3', generator_color: str = '#fcaf3e', pseudo_color: str = '#729fcf', prototype_color: str = '#8ae234', show_predicates: bool = False, show_individuals: bool = False, compact_mode: bool = True, width: int = 40)¶ Bases:
galactic.algebras.poset.collections.GraphvizRenderer
,galactic.algebras.context.main.ContextRenderer
The
ConceptRenderer
class renders graphviz node and edge attributes forConcept
instances.-
header
(concept: galactic.concepts.main.Concept, context: galactic.algebras.context.main.Context) → str¶ Render an attribute into the header.
-
row
(concept: galactic.concepts.main.Concept, _context: galactic.algebras.context.main.Context) → str¶ Render an object into the header.
-
node_attributes
(node: galactic.concepts.main.Concept, poset: galactic.algebras.poset.collections.PartiallyOrderedSet) → Dict[str, str]¶ Returns a dictionnary of graphviz attributes for a node.
- Parameters
node (
PartiallyOrdered
) – The node to rendercount (
int
) – The node ordersuccessors (
List[PartiallyOrdered]
) – The successors of the nodepredecessors (
List[PartiallyOrdered]
) – The predecessors of the node
- Returns
A dictionnary of graphviz attributes
- Return type
-