-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ft-1279-artificial-start-end-all' into 'integration'
FT 1279 Artificial start/end activities (Pandas + log + simplified interface) See merge request pm4py/pm4py-core!502
- Loading branch information
Showing
5 changed files
with
137 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from enum import Enum | ||
from typing import Optional, Dict, Any | ||
|
||
from pm4py.objects.log.obj import Event | ||
from pm4py.objects.log.obj import EventLog | ||
from pm4py.util import constants | ||
from pm4py.util import exec_utils | ||
from pm4py.util import xes_constants | ||
|
||
|
||
class Parameters(Enum): | ||
ACTIVITY_KEY = constants.PARAMETER_CONSTANT_ACTIVITY_KEY | ||
PARAM_ARTIFICIAL_START_ACTIVITY = constants.PARAM_ARTIFICIAL_START_ACTIVITY | ||
PARAM_ARTIFICIAL_END_ACTIVITY = constants.PARAM_ARTIFICIAL_END_ACTIVITY | ||
|
||
|
||
def insert_artificial_start_end(log: EventLog, parameters: Optional[Dict[Any, Any]] = None) -> EventLog: | ||
""" | ||
Inserts the artificial start/end activities in an event log | ||
Parameters | ||
------------------- | ||
log | ||
Event log | ||
parameters | ||
Parameters of the algorithm, including: | ||
- Parameters.ACTIVITY_KEY: the activity | ||
Returns | ||
------------------ | ||
log | ||
Enriched log | ||
""" | ||
if parameters is None: | ||
parameters = {} | ||
|
||
activity_key = exec_utils.get_param_value(Parameters.ACTIVITY_KEY, parameters, xes_constants.DEFAULT_NAME_KEY) | ||
artificial_start_activity = exec_utils.get_param_value(Parameters.PARAM_ARTIFICIAL_START_ACTIVITY, parameters, | ||
constants.DEFAULT_ARTIFICIAL_START_ACTIVITY) | ||
artificial_end_activity = exec_utils.get_param_value(Parameters.PARAM_ARTIFICIAL_END_ACTIVITY, parameters, | ||
constants.DEFAULT_ARTIFICIAL_END_ACTIVITY) | ||
|
||
for trace in log: | ||
trace.insert(0, Event({activity_key: artificial_start_activity})) | ||
trace.append(Event({activity_key: artificial_end_activity})) | ||
|
||
return log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters