Skip to content

Commit b086376

Browse files
Merge remote-tracking branch 'upstream/hotfixes' into release
2 parents d9dd102 + a78b716 commit b086376

File tree

3 files changed

+25
-30
lines changed

3 files changed

+25
-30
lines changed

pm4py/meta.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,5 @@
1-
'''
2-
PM4Py – A Process Mining Library for Python
3-
Copyright (C) 2024 Process Intelligence Solutions UG (haftungsbeschränkt)
4-
5-
This program is free software: you can redistribute it and/or modify
6-
it under the terms of the GNU Affero General Public License as
7-
published by the Free Software Foundation, either version 3 of the
8-
License, or any later version.
9-
10-
This program is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
GNU Affero General Public License for more details.
14-
15-
You should have received a copy of the GNU Affero General Public License
16-
along with this program. If not, see this software project's root or
17-
visit <https://www.gnu.org/licenses/>.
18-
19-
Website: https://processintelligence.solutions
20-
Contact: info@processintelligence.solutions
21-
'''
22-
23-
__name__ = 'pm4py'
24-
VERSION = '2.7.17'
1+
__name__ = "pm4py"
2+
VERSION = "2.7.17"
253
__version__ = VERSION
264
__doc__ = "Process mining for Python"
275
__author__ = "Process Intelligence Solutions (PIS)"

pm4py/objects/ocel/importer/jsonocel/variants/classic.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,35 @@ def get_base_ocel(json_obj: Any, parameters: Optional[Dict[Any, Any]] = None):
137137
events = pandas_utils.instantiate_dataframe(events)
138138
objects = pandas_utils.instantiate_dataframe(objects)
139139
relations = pandas_utils.instantiate_dataframe(relations)
140+
# If there are no relations, ensure the dataframe has the expected schema
141+
# to avoid downstream crashes when accessing required columns.
142+
if len(relations) == 0:
143+
relations = pandas_utils.instantiate_dataframe(
144+
{
145+
event_id: [],
146+
event_activity: [],
147+
event_timestamp: [],
148+
object_id: [],
149+
object_type: [],
150+
}
151+
)
140152

141153
events = pandas_utils.insert_index(
142154
events, internal_index, reset_index=False, copy_dataframe=False
143155
)
144-
relations = pandas_utils.insert_index(
145-
relations, internal_index, reset_index=False, copy_dataframe=False
146-
)
156+
# Only add temporary index and sort if there are relations rows
157+
if len(relations) > 0:
158+
relations = pandas_utils.insert_index(
159+
relations, internal_index, reset_index=False, copy_dataframe=False
160+
)
147161

148162
events = events.sort_values([event_timestamp, internal_index])
149-
relations = relations.sort_values([event_timestamp, internal_index])
163+
if len(relations) > 0:
164+
relations = relations.sort_values([event_timestamp, internal_index])
150165

151166
del events[internal_index]
152-
del relations[internal_index]
167+
if internal_index in relations.columns:
168+
del relations[internal_index]
153169

154170
globals = {}
155171
globals[constants.OCEL_GLOBAL_LOG] = json_obj[constants.OCEL_GLOBAL_LOG]

pm4py/visualization/align_table/variants/classic.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ def apply(
6969
variants_idx_list = []
7070
for variant in variants_idx_dict:
7171
variants_idx_list.append((variant, variants_idx_dict[variant]))
72+
# Deterministic ordering: sort by count (desc) then by variant key (asc)
7273
variants_idx_list = sorted(
73-
variants_idx_list, key=lambda x: len(x[1]), reverse=True
74+
variants_idx_list, key=lambda x: (-len(x[1]), x[0])
7475
)
7576

7677
image_format = exec_utils.get_param_value(

0 commit comments

Comments
 (0)