Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/hotfixes' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
fit-alessandro-berti committed Nov 24, 2024
2 parents 7df7a86 + 6c6e051 commit 139555c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
3 changes: 2 additions & 1 deletion pm4py/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from typing import List, Optional, Tuple, Dict, Union, Generator, Set, Any

from pm4py.objects.log.obj import Trace, EventLog, EventStream
from pm4py.objects.conversion.log import converter as log_converter
from pm4py.utils import __event_log_deprecation_warning
from pm4py.objects.petri_net.obj import PetriNet, Marking
from pm4py.utils import get_properties, pandas_utils, constants
Expand Down Expand Up @@ -283,6 +282,7 @@ def insert_case_service_waiting_time(log: Union[EventLog, pd.DataFrame], service

properties = get_properties(log, activity_key=activity_key, case_id_key=case_id_key, timestamp_key=timestamp_key)

from pm4py.objects.conversion.log import converter as log_converter
log = log_converter.apply(log, variant=log_converter.Variants.TO_DATA_FRAME, parameters=properties)

return pandas_utils.insert_case_service_waiting_time(log, case_id_column=case_id_key, timestamp_column=timestamp_key, start_timestamp_column=start_timestamp_key, service_time_column=service_time_column, waiting_time_column=waiting_time_column, sojourn_time_column=sojourn_time_column)
Expand Down Expand Up @@ -316,6 +316,7 @@ def insert_case_arrival_finish_rate(log: Union[EventLog, pd.DataFrame], arrival_

properties = get_properties(log, activity_key=activity_key, case_id_key=case_id_key, timestamp_key=timestamp_key)

from pm4py.objects.conversion.log import converter as log_converter
log = log_converter.apply(log, variant=log_converter.Variants.TO_DATA_FRAME, parameters=properties)

return pandas_utils.insert_case_arrival_finish_rate(log, case_id_column=case_id_key, timestamp_column=timestamp_key, start_timestamp_column=start_timestamp_key, arrival_rate_column=arrival_rate_column, finish_rate_column=finish_rate_column)
Expand Down
7 changes: 5 additions & 2 deletions pm4py/conformance.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@

from typing import List, Dict, Any, Union, Optional, Tuple, Set

from pm4py.objects.log.obj import EventLog, Trace, Event, EventStream
from pm4py.objects.log.obj import EventLog, Trace, Event
from pm4py.objects.petri_net.obj import PetriNet, Marking
from pm4py.convert import convert_to_event_log
from pm4py.objects.process_tree.obj import ProcessTree
from pm4py.util import xes_constants, constants
from pm4py.utils import get_properties, __event_log_deprecation_warning
Expand Down Expand Up @@ -91,6 +90,7 @@ def conformance_diagnostics_token_based_replay(log: Union[EventLog, pd.DataFrame
check_pandas_dataframe_columns(log, activity_key=activity_key, timestamp_key=timestamp_key, case_id_key=case_id_key)

if return_diagnostics_dataframe:
from pm4py.convert import convert_to_event_log
log = convert_to_event_log(log, case_id_key=case_id_key)
case_id_key = None

Expand Down Expand Up @@ -153,6 +153,7 @@ def conformance_diagnostics_alignments(log: Union[EventLog, pd.DataFrame], *args
check_pandas_dataframe_columns(log, activity_key=activity_key, timestamp_key=timestamp_key, case_id_key=case_id_key)

if return_diagnostics_dataframe:
from pm4py.convert import convert_to_event_log
log = convert_to_event_log(log, case_id_key=case_id_key)
case_id_key = None

Expand Down Expand Up @@ -761,6 +762,7 @@ def conformance_declare(log: Union[EventLog, pd.DataFrame], declare_model: Dict[
case_id_key=case_id_key)

if return_diagnostics_dataframe:
from pm4py.convert import convert_to_event_log
log = convert_to_event_log(log, case_id_key=case_id_key)
case_id_key = None

Expand Down Expand Up @@ -820,6 +822,7 @@ def conformance_log_skeleton(log: Union[EventLog, pd.DataFrame], log_skeleton: D
check_pandas_dataframe_columns(log, activity_key=activity_key, timestamp_key=timestamp_key, case_id_key=case_id_key)

if return_diagnostics_dataframe:
from pm4py.convert import convert_to_event_log
log = convert_to_event_log(log, case_id_key=case_id_key)
case_id_key = None

Expand Down
4 changes: 2 additions & 2 deletions pm4py/ml.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
import pandas as pd
import numpy as np
from pm4py.objects.ocel.obj import OCEL
from pm4py.objects.log.obj import EventLog, EventStream
from pm4py.objects.conversion.log import converter as log_converter
from pm4py.objects.log.obj import EventLog
from pm4py.utils import __event_log_deprecation_warning
import random
from pm4py.util.pandas_utils import check_is_pandas_dataframe, check_pandas_dataframe_columns
Expand Down Expand Up @@ -127,6 +126,7 @@ def extract_outcome_enriched_dataframe(log: Union[EventLog, pd.DataFrame], activ

properties = get_properties(log, activity_key=activity_key, case_id_key=case_id_key, timestamp_key=timestamp_key)

from pm4py.objects.conversion.log import converter as log_converter
log = log_converter.apply(log, variant=log_converter.Variants.TO_DATA_FRAME, parameters=properties)

from pm4py.util import pandas_utils
Expand Down
4 changes: 1 addition & 3 deletions pm4py/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@
from pm4py.objects.ocel.obj import OCEL
from pm4py.objects.petri_net.obj import PetriNet, Marking
from pm4py.objects.process_tree.obj import ProcessTree
from pm4py.objects.conversion.log import converter as log_converter
from pm4py.objects.log.util import dataframe_utils
from pm4py.util import constants

import os

from pandas import DataFrame
import importlib.util
from typing import Union

INDEX_COLUMN = "@@index"
Expand Down Expand Up @@ -92,6 +89,7 @@ def read_xes(file_path: str, variant: Optional[str] = None, return_legacy_log_ob
log = xes_importer.apply(file_path, variant=v, parameters=parameters)

if type(log) is EventLog and not return_legacy_log_object:
from pm4py.objects.conversion.log import converter as log_converter
log = log_converter.apply(log, variant=log_converter.Variants.TO_DATA_FRAME)

return log
Expand Down
2 changes: 1 addition & 1 deletion pm4py/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import pandas as pd

from pm4py.objects.log.obj import EventLog, EventStream, Trace, Event
from pm4py.objects.log.obj import EventLog, EventStream, Trace
from pm4py.objects.process_tree.obj import ProcessTree
from pm4py.objects.powl.obj import POWL
from pm4py.objects.ocel.obj import OCEL
Expand Down
7 changes: 3 additions & 4 deletions pm4py/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@
"""

from pm4py.objects.bpmn.obj import BPMN
from pm4py.objects.log.obj import EventLog, EventStream
from pm4py.objects.log.obj import EventLog
from pm4py.objects.ocel.obj import OCEL
from pm4py.objects.petri_net.obj import PetriNet, Marking
from pm4py.objects.process_tree.obj import ProcessTree
from pm4py.utils import __event_log_deprecation_warning
import pandas as pd
from typing import Union, Optional, Collection, Tuple, Dict
from typing import Union, Tuple, Dict
from pm4py.util import constants
from pm4py.util.pandas_utils import check_is_pandas_dataframe, check_pandas_dataframe_columns
from pm4py.objects.log.obj import XESExtension


def write_xes(log: Union[EventLog, pd.DataFrame], file_path: str, case_id_key: str = "case:concept:name", extensions: Optional[Collection[XESExtension]] = None, encoding: str = constants.DEFAULT_ENCODING, **kwargs) -> None:
def write_xes(log: Union[EventLog, pd.DataFrame], file_path: str, case_id_key: str = "case:concept:name", extensions = None, encoding: str = constants.DEFAULT_ENCODING, **kwargs) -> None:
"""
Writes an event log to disk in the XES format (see `xes-standard <https://xes-standard.org/>`_)
Expand Down

0 comments on commit 139555c

Please sign in to comment.