Source code for hets.Comorphism

"""
Description :  Represents `Logic.Comorphism`
Copyright   :  (c) Otto-von-Guericke University of Magdeburg
License     :  GPLv2 or higher, see LICENSE.txt
"""

from .haskell import comorphismName, PyComorphism, targetLogicName, sourceLogicName


[docs] class Comorphism: def __init__(self, hs_comorphism: PyComorphism) -> None: """ A comorphism from one logic to another. :warning: This class should not be instantiated manually. :param hs_comorphism: Haskell object of ``HetsAPI.Python.PyComorphism`` """ self._hs_comorphism = hs_comorphism
[docs] def name(self) -> str: """ Get the name of the comorphism. """ return comorphismName(self._hs_comorphism)
def __eq__(self, other): return isinstance(other, Comorphism) and self.name() == other.name() def __hash__(self): return self.name().__hash__()
[docs] def path_length(self) -> int: """ Calculates the length of the comorphism path. """ return len(self.name().split(";"))
[docs] def source(self) -> str: return sourceLogicName(self._hs_comorphism)
[docs] def target(self) -> str: return targetLogicName(self._hs_comorphism)