Skip to content

Commit

Permalink
Fix vertical formatting to redistinguish classes
Browse files Browse the repository at this point in the history
  • Loading branch information
adamburkegh committed Jan 4, 2025
1 parent 07dda01 commit ab890b9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pmkoalas/models/petrinet.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def verbosecmp(obj1:object,obj2:object) -> str:
+ f" {obj1.__dict__[k]} vs\n {obj2.__dict__[k]}\n"
return result


class Place:
"""
This a hashable and identifable place for a petri net.
Expand Down Expand Up @@ -98,6 +99,7 @@ def __str__(self) -> str:
def __repr__(self) -> str:
return f'Place("{self.name}",pid="{self.pid}")'


class Transition:
"""
This is hashable and identifable transition for a Petri net.
Expand Down Expand Up @@ -156,6 +158,7 @@ def __repr__(self) -> str:
return f'Transition("{self.name}",tid="{self.tid}",weight={self.weight},' \
+ f'silent={self.silent})'


SILENT_TRANSITION_DEFAULT_NAME='tau'
def silent_transition(name=None,tid=None,weight=None):
tn = SILENT_TRANSITION_DEFAULT_NAME
Expand All @@ -169,6 +172,7 @@ def silent_transition(name=None,tid=None,weight=None):
tw = weight
return Transition(name=tn,weight=tw,tid=ttid,silent=True)


class Arc:
"""
This is directed arc, which has no name or idenfitier, for Petri net.
Expand Down Expand Up @@ -203,6 +207,7 @@ def __repr__(self) -> str:
return f'Arc(from_node={self.from_node.__repr__()},' \
+ f'to_node={self.to_node.__repr__()})'


class LabelledPetriNet:
"""
This is a data structure for a class of Petri Nets.
Expand All @@ -212,7 +217,6 @@ class LabelledPetriNet:
labels/names and identifiers. Each instance of this class,
has a name or title for the net.
"""


def __init__(self, places:Iterable[Place], transitions:Iterable[Transition],
arcs:Iterable[Arc],
Expand Down Expand Up @@ -306,6 +310,7 @@ def __str__(self) -> str:
_str += f"\t\t- {a}\n"
return _str


class BuildablePetriNet(LabelledPetriNet):
"""
This class allows for the builder design pattern to be used
Expand Down Expand Up @@ -376,6 +381,7 @@ def __eq__(self,other):
self._arcs == self._arcs
return False


class GuardedTransition(Transition):
"""
An abstraction for a transition with a guard.
Expand Down Expand Up @@ -409,6 +415,7 @@ def __repr__(self) -> str:
return f'GuardedTransition("{self.name}",guard={self.guard.__repr__()}'\
+ f',tid="{self.tid}",silent={self.silent})'


class PetriNetWithData(LabelledPetriNet):
"""
An abstraction for extending a Petri net to one with data. This abstraction
Expand Down

0 comments on commit ab890b9

Please sign in to comment.