Skip to content

Commit ae1412f

Browse files
Merge remote-tracking branch 'upstream/hotfixes' into release
2 parents f50d186 + ad51e11 commit ae1412f

190 files changed

Lines changed: 1606 additions & 1101 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/activities_to_alphabet.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import pm4py
22
from pm4py.objects.log.util import activities_to_alphabet
33
from pm4py.util import constants
4+
import pandas
45

56

67
def execute_script():
7-
dataframe: "pandas.DataFrame" = pm4py.read_xes("../tests/input_data/running-example.xes", return_legacy_log_object=False)
8-
renamed_dataframe: "pandas.DataFrame | tuple[pandas.DataFrame, dict[str, str]]" = activities_to_alphabet.apply(dataframe, parameters={constants.PARAMETER_CONSTANT_ACTIVITY_KEY: "concept:name"})
8+
dataframe: pandas.DataFrame = pm4py.read_xes("../tests/input_data/running-example.xes", return_legacy_log_object=False)
9+
renamed_dataframe: pandas.DataFrame | tuple[pandas.DataFrame, dict[str, str]] = activities_to_alphabet.apply(dataframe, parameters={constants.PARAMETER_CONSTANT_ACTIVITY_KEY: "concept:name"})
910
print(renamed_dataframe)
1011

1112

examples/activity_position.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
from pm4py.util import constants, pandas_utils
33
from pm4py.objects.log.util import dataframe_utils
44
import os
5+
import pandas
56

67

78
def execute_script():
8-
dataframe: "pandas.DataFrame" = pandas_utils.read_csv(os.path.join("..", "tests", "input_data", "receipt.csv"))
9+
dataframe: pandas.DataFrame = pandas_utils.read_csv(os.path.join("..", "tests", "input_data", "receipt.csv"))
910
dataframe = dataframe_utils.convert_timestamp_columns_in_df(dataframe, timest_format=constants.DEFAULT_TIMESTAMP_PARSE_FORMAT, timest_columns=["time:timestamp"])
1011
# prints the summary of the positions of two activities
1112
print(pm4py.get_activity_position_summary(dataframe, "Confirmation of receipt"))

examples/align_approx_pt.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@
55
from pm4py.algo.conformance.alignments.process_tree import algorithm as align_approx
66
from pm4py.objects.petri_net.utils.align_utils import pretty_print_alignments
77
from examples import examples_conf
8+
from pm4py.objects.log.obj import EventLog
9+
from pm4py.objects.process_tree.obj import ProcessTree
10+
from typing import Any
811

912

1013
def execute_script():
11-
log_path: "str" = os.path.join("..", "tests", "input_data", "running-example.xes")
14+
log_path: str = os.path.join("..", "tests", "input_data", "running-example.xes")
1215

13-
log: "EventLog" = xes_importer.apply(log_path)
14-
tree: "ProcessTree" = inductive.apply(log)
16+
log: EventLog = xes_importer.apply(log_path)
17+
tree: ProcessTree = inductive.apply(log)
1518

1619
if importlib.util.find_spec("graphviz"):
1720
from pm4py.visualization.process_tree import visualizer as pt_vis
1821
gviz = pt_vis.apply(tree, parameters={pt_vis.Variants.WO_DECORATION.value.Parameters.FORMAT: examples_conf.TARGET_IMG_FORMAT})
1922
pt_vis.view(gviz)
2023

2124
print("start calculate approximated alignments")
22-
approx_alignments: "dict[str, Any] | list[dict[str, Any]]" = align_approx.apply(log, tree)
25+
approx_alignments: dict[str, Any] | list[dict[str, Any]] = align_approx.apply(log, tree)
2326
pretty_print_alignments(approx_alignments)
2427

2528

examples/align_decomposition_ex_paper.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66

77

88
def execute_script():
9-
net: "PetriNet" = PetriNet("")
10-
start: "PetriNet.Place" = PetriNet.Place("start")
11-
end: "PetriNet.Place" = PetriNet.Place("end")
12-
c1: "PetriNet.Place" = PetriNet.Place("c1")
13-
c2: "PetriNet.Place" = PetriNet.Place("c2")
14-
c3: "PetriNet.Place" = PetriNet.Place("c3")
15-
c4: "PetriNet.Place" = PetriNet.Place("c4")
16-
c5: "PetriNet.Place" = PetriNet.Place("c5")
17-
c6: "PetriNet.Place" = PetriNet.Place("c6")
18-
c7: "PetriNet.Place" = PetriNet.Place("c7")
19-
c8: "PetriNet.Place" = PetriNet.Place("c8")
20-
c9: "PetriNet.Place" = PetriNet.Place("c9")
9+
net: PetriNet = PetriNet("")
10+
start: PetriNet.Place = PetriNet.Place("start")
11+
end: PetriNet.Place = PetriNet.Place("end")
12+
c1: PetriNet.Place = PetriNet.Place("c1")
13+
c2: PetriNet.Place = PetriNet.Place("c2")
14+
c3: PetriNet.Place = PetriNet.Place("c3")
15+
c4: PetriNet.Place = PetriNet.Place("c4")
16+
c5: PetriNet.Place = PetriNet.Place("c5")
17+
c6: PetriNet.Place = PetriNet.Place("c6")
18+
c7: PetriNet.Place = PetriNet.Place("c7")
19+
c8: PetriNet.Place = PetriNet.Place("c8")
20+
c9: PetriNet.Place = PetriNet.Place("c9")
2121
net.places.add(c1)
2222
net.places.add(c2)
2323
net.places.add(c3)
@@ -29,17 +29,17 @@ def execute_script():
2929
net.places.add(c9)
3030
net.places.add(start)
3131
net.places.add(end)
32-
t1: "PetriNet.Transition" = PetriNet.Transition("t1", "a")
33-
t2: "PetriNet.Transition" = PetriNet.Transition("t2", None)
34-
t3: "PetriNet.Transition" = PetriNet.Transition("t3", "b")
35-
t4: "PetriNet.Transition" = PetriNet.Transition("t4", "c")
36-
t5: "PetriNet.Transition" = PetriNet.Transition("t5", "d")
37-
t6: "PetriNet.Transition" = PetriNet.Transition("t6", "e")
38-
t7: "PetriNet.Transition" = PetriNet.Transition("t7", None)
39-
t8: "PetriNet.Transition" = PetriNet.Transition("t8", "f")
40-
t9: "PetriNet.Transition" = PetriNet.Transition("t9", "g")
41-
t10: "PetriNet.Transition" = PetriNet.Transition("t10", "h")
42-
t11: "PetriNet.Transition" = PetriNet.Transition("t11", None)
32+
t1: PetriNet.Transition = PetriNet.Transition("t1", "a")
33+
t2: PetriNet.Transition = PetriNet.Transition("t2", None)
34+
t3: PetriNet.Transition = PetriNet.Transition("t3", "b")
35+
t4: PetriNet.Transition = PetriNet.Transition("t4", "c")
36+
t5: PetriNet.Transition = PetriNet.Transition("t5", "d")
37+
t6: PetriNet.Transition = PetriNet.Transition("t6", "e")
38+
t7: PetriNet.Transition = PetriNet.Transition("t7", None)
39+
t8: PetriNet.Transition = PetriNet.Transition("t8", "f")
40+
t9: PetriNet.Transition = PetriNet.Transition("t9", "g")
41+
t10: PetriNet.Transition = PetriNet.Transition("t10", "h")
42+
t11: PetriNet.Transition = PetriNet.Transition("t11", None)
4343
net.transitions.add(t1)
4444
net.transitions.add(t2)
4545
net.transitions.add(t3)
@@ -78,9 +78,9 @@ def execute_script():
7878
add_arc_from_to(t11, end, net)
7979
add_arc_from_to(c5, t10, net)
8080
add_arc_from_to(t10, end, net)
81-
im: "Marking" = Marking()
81+
im: Marking = Marking()
8282
im[start] = 1
83-
fm: "Marking" = Marking()
83+
fm: Marking = Marking()
8484
fm[end] = 1
8585
decomposed_net = decomposition.decompose(net, im, fm)
8686
gvizs = []

examples/align_decomposition_example.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,25 @@
55
from pm4py.objects.conversion.process_tree import converter as process_tree_converter
66
import os
77
import time
8+
from pm4py.objects.log.obj import EventLog
9+
from pm4py.objects.petri_net.obj import Marking, PetriNet
10+
from pm4py.objects.process_tree.obj import ProcessTree
811

912

1013
def execute_script():
1114
# import the a32f0n00 log
12-
log: "EventLog" = xes_importer.apply(os.path.join("..", "tests", "compressed_input_data", "09_a32f0n00.xes.gz"))
15+
log: EventLog = xes_importer.apply(os.path.join("..", "tests", "compressed_input_data", "09_a32f0n00.xes.gz"))
1316
# discover a model using the inductive miner
14-
process_tree: "ProcessTree" = inductive_miner.apply(log)
15-
net: "PetriNet"
16-
im: "Marking"
17-
fm: "Marking"
17+
process_tree: ProcessTree = inductive_miner.apply(log)
18+
net: PetriNet
19+
im: Marking
20+
fm: Marking
1821
net, im, fm = process_tree_converter.apply(process_tree)
1922
# apply the alignments decomposition with a maximal number of border disagreements set to 5
20-
aa: "float" = time.time()
23+
aa: float = time.time()
2124
aligned_traces = dec_align.apply(log, net, im, fm, parameters={
2225
dec_align.Variants.RECOMPOS_MAXIMAL.value.Parameters.PARAM_THRESHOLD_BORDER_AGREEMENT: 5})
23-
bb: "float" = time.time()
26+
bb: float = time.time()
2427
print(bb-aa)
2528
# print(aligned_traces)
2629
# calculate the fitness over the recomposed alignment (use the classical evaluation)

examples/alignment_discounted_a_star.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from pm4py.algo.conformance.alignments.petri_net import algorithm as ali
44
from pm4py.objects.log.importer.xes import importer as xes_importer
55
from pm4py.objects.petri_net.importer import importer as petri_importer
6+
from pm4py.objects.log.obj import EventLog
7+
from pm4py.objects.petri_net.obj import PetriNet, Marking
68

79

810
def synchronous_discounted_alignment():
@@ -11,18 +13,18 @@ def synchronous_discounted_alignment():
1113
By using the synchronous product
1214
:return:
1315
'''
14-
log_path: "str" = os.path.join("..", "tests", "input_data", "running-example.xes")
15-
pnml_path: "str" = os.path.join("..", "tests", "input_data", "running-example.pnml")
16-
log: "EventLog" = xes_importer.apply(log_path)
17-
net: "PetriNet"
18-
marking: "Marking"
19-
fmarking: "Marking"
16+
log_path: str = os.path.join("..", "tests", "input_data", "running-example.xes")
17+
pnml_path: str = os.path.join("..", "tests", "input_data", "running-example.pnml")
18+
log: EventLog = xes_importer.apply(log_path)
19+
net: PetriNet
20+
marking: Marking
21+
fmarking: Marking
2022
net, marking, fmarking = petri_importer.apply(pnml_path)
2123

2224
# to see the net :
2325
#vizu(net,marking,fmarking).view()
2426

25-
start: "float"=time.time()
27+
start: float=time.time()
2628

2729
alignments1 = ali.apply(log._list[0], net, marking, fmarking,
2830
variant=ali.VERSION_DISCOUNTED_A_STAR,
@@ -35,15 +37,15 @@ def no_synchronous_discounted_alignment():
3537
This function runs an alignment based on the discounted edit distance
3638
By using the Petri net and petri_net.utils.align_utils.discountedEditDistance function
3739
'''
38-
log_path: "str" = os.path.join("..", "tests", "input_data", "running-example.xes")
39-
pnml_path: "str" = os.path.join("..", "tests", "input_data", "running-example.pnml")
40-
log: "EventLog" = xes_importer.apply(log_path)
41-
net: "PetriNet"
42-
marking: "Marking"
43-
fmarking: "Marking"
40+
log_path: str = os.path.join("..", "tests", "input_data", "running-example.xes")
41+
pnml_path: str = os.path.join("..", "tests", "input_data", "running-example.pnml")
42+
log: EventLog = xes_importer.apply(log_path)
43+
net: PetriNet
44+
marking: Marking
45+
fmarking: Marking
4446
net, marking, fmarking = petri_importer.apply(pnml_path)
4547

46-
start: "float"=time.time()
48+
start: float=time.time()
4749

4850
alignments1 = ali.apply(log._list[0], net, marking, fmarking,
4951
variant=ali.VERSION_DISCOUNTED_A_STAR,

examples/alignment_test.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from pm4py.objects.log.importer.xes import importer as xes_importer
88
from pm4py.objects.petri_net.importer import importer as petri_importer
99
from pm4py.objects.petri_net.utils.align_utils import pretty_print_alignments
10+
from pm4py.objects.log.obj import EventLog
11+
from pm4py.objects.petri_net.obj import Marking, PetriNet
1012

1113

1214
def align(trace, net, im, fm, model_cost_function, sync_cost_function):
@@ -21,16 +23,16 @@ def align(trace, net, im, fm, model_cost_function, sync_cost_function):
2123

2224

2325
def execute_script():
24-
log_path: "str" = os.path.join("..", "tests", "input_data", "running-example.xes")
25-
pnml_path: "str" = os.path.join("..", "tests", "input_data", "running-example.pnml")
26+
log_path: str = os.path.join("..", "tests", "input_data", "running-example.xes")
27+
pnml_path: str = os.path.join("..", "tests", "input_data", "running-example.pnml")
2628

2729
# log_path = 'C:/Users/bas/Documents/tue/svn/private/logs/a32_logs/a32f0n05.xes'
2830
# pnml_path = 'C:/Users/bas/Documents/tue/svn/private/logs/a32_logs/a32.pnml'
2931

30-
log: "EventLog" = xes_importer.apply(log_path)
31-
net: "PetriNet"
32-
marking: "Marking"
33-
fmarking: "Marking"
32+
log: EventLog = xes_importer.apply(log_path)
33+
net: PetriNet
34+
marking: Marking
35+
fmarking: Marking
3436
net, marking, fmarking = petri_importer.apply(pnml_path)
3537

3638
model_cost_function = dict()

examples/all_optimal_alignments.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import pm4py
22
from pm4py.algo.conformance.alignments.petri_net.variants import generator_dijkstra_less_memory
33
import os
4+
from pm4py.objects.log.obj import EventLog
5+
from pm4py.objects.petri_net.obj import Marking, PetriNet
46

57

68
def execute_script():
7-
log: "EventLog" = pm4py.read_xes(os.path.join("..", "tests", "input_data", "running-example.xes"), return_legacy_log_object=True)
9+
log: EventLog = pm4py.read_xes(os.path.join("..", "tests", "input_data", "running-example.xes"), return_legacy_log_object=True)
810

9-
net: "PetriNet"
10-
im: "Marking"
11-
fm: "Marking"
11+
net: PetriNet
12+
im: Marking
13+
fm: Marking
1214
net, im, fm = pm4py.discover_petri_net_inductive(log)
1315

1416
for trace in log:

examples/antialignments_and_precision.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@
44
from pm4py.algo.conformance.antialignments.algorithm import Parameters
55
from pm4py.objects.log.importer.xes import importer as xes_importer
66
from pm4py.objects.petri_net.importer import importer as petri_importer
7+
from pm4py.objects.log.obj import EventLog
8+
from pm4py.objects.petri_net.obj import Marking, PetriNet
79

810

911
def execute_script():
10-
log_path: "str" = os.path.join("..", "tests", "input_data", "running-example.xes")
11-
pnml_path: "str" = os.path.join("..", "tests", "input_data", "running-example.pnml")
12-
log: "EventLog" = xes_importer.apply(log_path)
13-
net: "PetriNet"
14-
marking: "Marking"
15-
fmarking: "Marking"
12+
log_path: str = os.path.join("..", "tests", "input_data", "running-example.xes")
13+
pnml_path: str = os.path.join("..", "tests", "input_data", "running-example.pnml")
14+
log: EventLog = xes_importer.apply(log_path)
15+
net: PetriNet
16+
marking: Marking
17+
fmarking: Marking
1618
net, marking, fmarking = petri_importer.apply(pnml_path)
1719

18-
THETA: "float" = 1.5
19-
MU: "int" = 20
20-
EPSILON: "float" = 0.01
20+
THETA: float = 1.5
21+
MU: int = 20
22+
EPSILON: float = 0.01
2123
resAnti = antii(log,net,marking,fmarking, parameters={Parameters.EXPONENT:THETA,
2224
Parameters.EPSILON:EPSILON,
2325
Parameters.MARKING_LIMIT:MU})

examples/backwards_token_replay.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@
33
from pm4py.algo.conformance.tokenreplay import algorithm as tr
44
from pm4py.objects.conversion.process_tree import converter as process_tree_converter
55
import os
6+
from pm4py.objects.log.obj import EventLog
7+
from pm4py.objects.petri_net.obj import Marking, PetriNet
8+
from pm4py.objects.process_tree.obj import ProcessTree
9+
from typing import Any
610

711

812
def execute_script():
9-
log: "EventLog" = xes_importer.apply(os.path.join("..", "tests", "input_data", "running-example.xes"))
10-
process_tree: "ProcessTree" = inductive_miner.apply(log)
11-
net: "PetriNet"
12-
im: "Marking"
13-
fm: "Marking"
13+
log: EventLog = xes_importer.apply(os.path.join("..", "tests", "input_data", "running-example.xes"))
14+
process_tree: ProcessTree = inductive_miner.apply(log)
15+
net: PetriNet
16+
im: Marking
17+
fm: Marking
1418
net, im, fm = process_tree_converter.apply(process_tree)
1519
# perform the backwards token-based replay
16-
replayed_traces: "list[dict[str, Any]]" = tr.apply(log, net, im, fm, variant=tr.Variants.BACKWARDS)
20+
replayed_traces: list[dict[str, Any]] = tr.apply(log, net, im, fm, variant=tr.Variants.BACKWARDS)
1721
print(replayed_traces)
1822

1923

0 commit comments

Comments
 (0)