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 6, 2023
2 parents 8c7fe2f + be4b724 commit e446353
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion pm4py/objects/petri_net/importer/variants/pnml.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
class Parameters(Enum):
ENCODING = "encoding"
AUTO_GUESS_FINAL_MARKING = "auto_guess_final_marking"
RETURN_STOCHASTIC_MAP = "return_stochastic_map"


def import_net(input_file_path, parameters=None):
Expand Down Expand Up @@ -116,6 +117,7 @@ def import_net_from_xml_object(root, parameters=None):
parameters = {}

auto_guess_final_marking = exec_utils.get_param_value(Parameters.AUTO_GUESS_FINAL_MARKING, parameters, True)
return_stochastic_information = exec_utils.get_param_value(Parameters.RETURN_STOCHASTIC_MAP, parameters, False)

net = PetriNet('imported_' + str(time.time()))
marking = Marking()
Expand All @@ -126,7 +128,7 @@ def import_net_from_xml_object(root, parameters=None):
finalmarkings = None
variables = None

stochastic_information = {}
stochastic_map = {}

for child in root:
nett = child
Expand Down Expand Up @@ -271,6 +273,8 @@ def import_net_from_xml_object(root, parameters=None):

if random_variable is not None:
trans_dict[trans_id].properties[constants.STOCHASTIC_DISTRIBUTION] = random_variable
stochastic_map[trans_dict[trans_id]] = random_variable

if position_X is not None and position_Y is not None and dimension_X is not None and dimension_Y is not None:
trans_dict[trans_id].properties[constants.LAYOUT_INFORMATION_PETRI] = (
(position_X, position_Y), (dimension_X, dimension_Y))
Expand Down Expand Up @@ -346,4 +350,7 @@ def import_net_from_xml_object(root, parameters=None):
if constants.SHOW_INTERNAL_WARNINGS:
warnings.warn("the Petri net has been imported without a specified final marking. Please create it using the method pm4py.generate_marking")

if return_stochastic_information:
return net, marking, fmarking, stochastic_map

return net, marking, fmarking
2 changes: 1 addition & 1 deletion pm4py/objects/process_tree/utils/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def parse_recursive(string_rep, depth_cache, depth):
node
Process tree object
"""
string_rep = string_rep.strip()
string_rep = string_rep.strip().replace("\r", "").replace("\n", " ")
node = None
operator = None
if string_rep.startswith(pt_op.Operator.LOOP.value):
Expand Down
Binary file added tests/input_data/helpdesk.xes.gz
Binary file not shown.

0 comments on commit e446353

Please sign in to comment.