Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
generalizationset.py fixed and tested.
Browse files Browse the repository at this point in the history
  • Loading branch information
pedropaulofb committed Dec 4, 2023
1 parent 2c3f469 commit b3a4431
Show file tree
Hide file tree
Showing 81 changed files with 4,896 additions and 838 deletions.
508 changes: 11 additions & 497 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Classes
:vartype _properties: list[Property]
:ivar is_abstract: Indicates whether the classifier is abstract.
:vartype is_abstract: bool
:cvar model_config: Configuration settings for the Pydantic model.
:vartype model_config: Dict[str, Any]

.. py:property:: properties
:type: list[ontouml_py.classes.concrete_classes.property.Property]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Classes
:ivar is_derived: Indicates whether the element is derived. Derived elements are typically computed or inferred
from other elements.
:vartype is_derived: bool
:cvar model_config: Configuration settings for the Pydantic model.
:vartype model_config: Dict[str, Any]

.. py:attribute:: is_derived
:type: bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Classes
:ivar custom_properties: A set of custom properties associated with the model element. Each property is a tuple
containing a string key and a value of any type.
:vartype custom_properties: Set[Tuple[str, Any]]
:cvar model_config: Configuration settings for the Pydantic model.
:vartype model_config: Dict[str, Any]

.. py:attribute:: custom_properties
:type: set[tuple[str, Any]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Classes
:vartype creators: list[str]
:ivar contributors: A list of URIs represented as strings identifying the contributors to the element.
:vartype contributors: list[str]
:cvar model_config: Configuration settings for the Pydantic model.
:vartype model_config: Dict[str, Any]

.. py:attribute:: names
:type: set[langstring.LangString]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ Classes
:vartype created: datetime
:ivar modified: Timestamp when the element was last modified, can be None if not modified.
:vartype modified: Optional[datetime]
:cvar model_config: Configuration settings for the Pydantic model.
:vartype model_config: Dict[str, Any]

.. py:attribute:: id
:type: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Classes

:ivar in_project: Reference to the Project instance this element belongs to. This is a read-only attribute.
:vartype in_project: Optional[Project]
:cvar model_config: Configuration settings for the Pydantic model.
:vartype model_config: Dict[str, Any]

.. py:property:: in_project
:type: Optional[Project]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@

This module defines classes and functionality for representing and manipulating ontological models.

It includes the definition of the `Class` class, which is a key component in the ontological model,
representing ontological classes with various attributes and behaviors. The module also includes
definitions for handling literals associated with these classes, ensuring that operations on these
classes adhere to certain ontological constraints.
It includes the definition of the `Class` class, which is a key component in the ontological model, representing
ontological classes with various attributes and behaviors. The module also includes definitions for handling literals
associated with these classes, ensuring that operations on these classes adhere to certain ontological constraints.

In this library, a `Class` is initialized as an enumeration by providing a list of literals, which are integral to its
definition. These literals, typically dependent on their classes, represent the finite set of values for enumeration
instances. To enhance object manipulation flexibility, this library allows the creation of 'free' literals,
independent of any class. Users can create these literals separately and later insert them into the appropriate
classes, offering a dynamic approach to class and literal management.
However, if the a Class's instance is created with stereotype=ClassStereotype.ENUMERATION, a set of stereotypes must
be provided at init time. I.e., it is not possible to have an enumeration without literals.

The module is named class_py instead of class due to the fact that class is a reserved keyword in Python.
As reserved keywords cannot be used as module names, class_py was chosen to maintain clarity and consistency with the
Expand Down Expand Up @@ -56,26 +57,10 @@ Classes
:vartype restricted_to: set[OntologicalNature]
:ivar stereotype: The stereotype of the class.
:vartype stereotype: ClassStereotype
:ivar literals: A set of literals associated with the class.
:ivar literals: A set of literals associated with the class. Must be managed internally after init.
:vartype literals: set[Literal]

.. py:property:: literals
:type: set[ontouml_py.classes.concrete_classes.literal.Literal]

Provide a read-only view of the class's literals.

This property is a safeguard to prevent direct modification of the 'literals' set. To add or remove literals,
use the 'add_literal' and 'remove_literal' methods. This design ensures that the integrity of the class's
literals collection is maintained.

:return: A set of Literal objects that are part of the class.
:rtype: set[Literal]


.. py:attribute:: _literals
:type: set[ontouml_py.classes.concrete_classes.literal.Literal]


:cvar model_config: Configuration settings for the Pydantic model.
:vartype model_config: Dict[str, Any]

.. py:attribute:: is_powertype
:type: bool
Expand All @@ -97,43 +82,42 @@ Classes



.. py:attribute:: model_config
.. py:attribute:: literals
:type: set[ontouml_py.classes.concrete_classes.literal.Literal]



.. py:method:: validate_class()
.. py:attribute:: model_config
Validate the class based on its literals and stereotype.
This method checks if the class conforms to the rules based on its stereotype. Specifically,
it ensures that only classes with the Enumeration stereotype can have literals.
.. py:method:: __validate_class()
:raises ValueError: If the class has literals but does not have an Enumeration stereotype.
Validate the class based on its literals and stereotype.

This method performs two checks:
1. It ensures that only classes with the Enumeration stereotype can have literals.
2. It ensures that classes with the Enumeration stereotype must have at least one literal.

.. py:method:: add_literal(new_literal)
:raises ValueError: If the class has literals but does not have an Enumeration stereotype, or if it is an
Enumeration class without any literals.

Add a new literal to the class's collection of literals.

This method ensures that only instances of Literal or its subclasses are added to the class. It also
establishes a bidirectional relationship between the class and the literal.
.. py:method:: add_literal(literal)
:param new_literal: The Literal to be added.
:type new_literal: Literal
:raises TypeError: If the provided new_literal is not an instance of Literal or if a class attempts to add itself.
Add a literal to the class.

:param literal: The literal to be added.
:type literal: Literal
:raises ValueError: If the provided object is not of type Literal.

.. py:method:: remove_literal(old_literal)

Remove an existing content from the class's collection of literals.
.. py:method:: remove_literal(literal)
This method ensures that the content to be removed is actually part of the class. It also updates the
content's 'in_class' attribute to None, effectively breaking the bidirectional relationship.
Remove a literal from the class if it exists.

:param old_literal: The Literal content to be removed.
:type old_literal: Literal
:raises TypeError: If the content is not a valid Literal.
:raises ValueError: If the content is not part of the class.
:param literal: The literal to be removed.
:type literal: Literal



Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Classes
.. py:method:: ensure_irreflexive()
.. py:method:: __ensure_irreflexive()
Validate that the generalization relationship is irreflexive.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,35 @@

.. py:module:: ontouml_py.classes.concrete_classes.generalizationset
.. autoapi-nested-parse::

This module defines the GeneralizationSet class, a key construct in ontological modeling within the ontouml_py library.

The GeneralizationSet class is used to represent a collection of generalizations, encapsulating the notions of
disjointness and completeness in a model. It extends the ModelElement class, inheriting its core properties and
behaviors, and adds specific attributes and methods relevant to the management of generalizations.

A GeneralizationSet is typically used in ontological models to express constraints and relationships between different
classes. It can specify whether the subclasses in the generalization are disjoint (no instances can be shared
among subclasses) and whether they are complete (the superclass is fully covered by the subclasses).

Key Features:
- Represents a set of generalizations in an ontological model.
- Supports disjointness and completeness constraints.
- Allows association with a categorizing class.

The module provides the necessary functionality to create, manipulate, and query GeneralizationSet instances, making
it a vital part of the ontouml_py library's support for advanced ontological modeling.

Classes:
- GeneralizationSet: Represents a set of generalizations with optional disjointness and completeness constraints.

Dependencies:
- ModelElement from ontouml_py.classes.abstract_classes.modelelement
- Class from ontouml_py.classes.concrete_classes.class_py
- Generalization from ontouml_py.classes.concrete_classes.generalization



Module Contents
---------------
Expand All @@ -20,40 +49,57 @@ Classes
.. py:class:: GeneralizationSet(**data)
Bases: :py:obj:`ontouml_py.classes.abstract_classes.namedelement.NamedElement`
Bases: :py:obj:`ontouml_py.classes.abstract_classes.modelelement.ModelElement`

An abstract class representing a named element within an OntoUML model, extending the OntoumlElement class.
Represent a set of generalizations in an ontological model, extending the ModelElement class.

This class provides functionality for managing named elements, including their preferred name, alternative names,
descriptions, editorial notes, as well as lists of creators and contributors.
A GeneralizationSet is a collection of Generalization instances, typically used to represent
disjointness and completeness constraints in a model.

:ivar names: The preferred names of the element, represented as a list of LangStrings.
:vartype names: list[LangString]
:ivar alt_names: A list of alternative names for the element, each represented as a LangString object.
:vartype alt_names: list[LangString]
:ivar description: A LangString object representing the description of the element.
:vartype description: Optional[LangString]
:ivar editorial_notes: A list of LangString objects containing editorial notes associated with the element.
:vartype editorial_notes: list[LangString]
:ivar creators: A list of URIs represented as strings identifying the creators of the element.
:vartype creators: list[str]
:ivar contributors: A list of URIs represented as strings identifying the contributors to the element.
:vartype contributors: list[str]
:ivar is_disjoint: Indicates if the generalizations in the set are disjoint.
:vartype is_disjoint: bool
:ivar is_complete: Indicates if the generalizations in the set are complete.
:vartype is_complete: bool
:ivar generalizations: A set of Generalization instances included in this generalization set.
:vartype generalizations: Set[Generalization]
:ivar categorizer: An optional Class instance that categorizes the generalization set.
:vartype categorizer: Optional[Class]
:cvar model_config: Configuration settings for the Pydantic model.
:vartype model_config: Dict[str, Any]

.. py:attribute:: is_disjoint
:type: bool
:value: False



.. py:attribute:: is_complete
:type: bool
:value: False



.. py:attribute:: generalizations
:type: set[object]



.. py:attribute:: categorizer
:type: Optional[object]



.. py:attribute:: model_config
.. py:method:: __ensure_generalizations_type(checked_set)
:classmethod:


.. py:method:: __ensure_categorizer_type(checked_value)
:classmethod:


.. py:method:: __validate_generalization_set()
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

This module is part of the ontouml_py class and defines the Literal class, a specialized type of ModelElement. The Literal class represents literals in an ontological model, particularly for enumeration classes.

Literals in this library traditionally exist as relational dependents of their classes, particularly in the context of
Literals traditionally exist as relational dependents of their classes, particularly in the context of
enumerations. However, to facilitate more versatile object manipulation, the library supports the creation of 'free'
literals, independent of any class. This feature allows users to define literals without the immediate need to
associate them with a specific class, providing a flexible workflow. These free literals can later be integrated into
Expand Down Expand Up @@ -40,36 +40,8 @@ Classes
:cvar model_config: Configuration settings for the Pydantic model.
:vartype model_config: Dict[str, Any]

.. py:property:: in_class
:type: Optional[Class]

Provide a read-only view of the class this literal is part of.

This property allows access to the class that contains this literal, if any. It is designed to be read-only to
maintain the integrity of the relationship between the literal and its class.

:return: The class containing this literal, if it is part of one.
:rtype: Optional[Class]


.. py:attribute:: _in_class
:type: Optional[Class]



.. py:attribute:: model_config
.. py:method:: __set_in_class(new_class)
Internally set the class this literal is part of.

This method is intended for internal use to establish or update the relationship between this literal and its
containing class. It should not be used directly in client code.

:param new_class: The class to associate with this literal. Pass None to dissociate the literal from any class.
:type new_class: Optional[Class]


Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Classes

:ivar text: The textual content of the note.
:vartype text: LangString
:cvar model_config: Configuration settings for the Pydantic model.
:vartype model_config: Dict[str, Any]

.. py:attribute:: text
:type: langstring.LangString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ Classes
:vartype root_package: Optional[Package]
:ivar representation_style: The style or methodology used for representing the ontologies within the project.
:vartype representation_style: OntologyRepresentationStyle
:cvar model_config: Configuration settings for the Pydantic model.
:vartype model_config: Dict[str, Any]

.. py:property:: elements
:type: set[ontouml_py.classes.abstract_classes.projectelement.ProjectElement]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Classes
:vartype redefined_by: Set[Property]
:ivar property_of: Reference to the Classifier instance that owns this property. This is a private attribute.
:vartype property_of: Optional[Classifier]
:cvar model_config: Configuration settings for the Pydantic model.
:vartype model_config: Dict[str, Any]

.. py:property:: property_of
:type: Optional[object]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ Classes
:vartype is_ordered: bool
:ivar is_unique: Flag indicating if the elements are unique. Defaults to True.
:vartype is_unique: bool
:raises ValueError: If the lower or upper bounds are not valid according to the multiplicity rules.
:cvar model_config: Configuration settings for the Pydantic model.
:vartype model_config: Dict[str, Any]

.. py:attribute:: lower_bound
:type: Optional[Union[str, int]]
Expand Down
1 change: 1 addition & 0 deletions docs/_sources/autoapi/ontouml_py/classes/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ Subpackages
concrete_classes/index.rst
datatypes/index.rst
enumerations/index.rst
utils/index.rst


15 changes: 15 additions & 0 deletions docs/_sources/autoapi/ontouml_py/classes/utils/index.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
:py:mod:`ontouml_py.classes.utils`
==================================

.. py:module:: ontouml_py.classes.utils
Submodules
----------
.. toctree::
:titlesonly:
:maxdepth: 1

nonemptyset/index.rst


Loading

0 comments on commit b3a4431

Please sign in to comment.