def test_applyAlphaMinerToCSV(self):
     # to avoid static method warnings in tests,
     # that by construction of the unittest package have to be expressed in such way
     self.dummy_variable = "dummy_value"
     # calculate and compare Petri nets obtained on the same log to verify that instances
     # are working correctly
     log1, net1, marking1, fmarking1 = self.obtainPetriNetThroughAlphaMiner(
         os.path.join(INPUT_DATA_DIR, "running-example.csv"))
     log2, net2, marking2, fmarking2 = self.obtainPetriNetThroughAlphaMiner(
         os.path.join(INPUT_DATA_DIR, "running-example.csv"))
     log1 = sorting.sort_timestamp(log1)
     log1 = sampling.sample(log1)
     log1 = index_attribute.insert_trace_index_as_event_attribute(log1)
     log2 = sorting.sort_timestamp(log2)
     log2 = sampling.sample(log2)
     log2 = index_attribute.insert_trace_index_as_event_attribute(log2)
     petri_exporter.export_net(
         net1, marking1,
         os.path.join(OUTPUT_DATA_DIR, "running-example.pnml"))
     os.remove(os.path.join(OUTPUT_DATA_DIR, "running-example.pnml"))
     self.assertEqual(len(net1.places), len(net2.places))
     self.assertEqual(len(net1.transitions), len(net2.transitions))
     self.assertEqual(len(net1.arcs), len(net2.arcs))
     final_marking = petri.petrinet.Marking()
     for p in net1.places:
         if not p.out_arcs:
             final_marking[p] = 1
     aligned_traces = token_replay.apply_log(log1, net1, marking1,
                                             final_marking)
     self.assertEqual(aligned_traces, aligned_traces)
 def test_importExportCSVtoCSV(self):
     # to avoid static method warnings in tests,
     # that by construction of the unittest package have to be expressed in such way
     self.dummy_variable = "dummy_value"
     event_log = csv_importer.import_event_stream(
         os.path.join(INPUT_DATA_DIR, "running-example.csv"))
     event_log = sorting.sort_timestamp(event_log)
     event_log = sampling.sample(event_log)
     event_log = index_attribute.insert_event_index_as_event_attribute(
         event_log)
     log = log_conv_fact.apply(event_log)
     log = sorting.sort_timestamp(log)
     log = sampling.sample(log)
     log = index_attribute.insert_trace_index_as_event_attribute(log)
     event_log_transformed = log_conv_fact.apply(
         log, variant=log_conv_fact.TO_EVENT_STREAM)
     csv_exporter.export(
         event_log_transformed,
         os.path.join(OUTPUT_DATA_DIR, "running-example-exported.csv"))
     event_log_imported_after_export = csv_importer.import_event_stream(
         os.path.join(OUTPUT_DATA_DIR, "running-example-exported.csv"))
     log_imported_after_export = log_conv_fact.apply(
         event_log_imported_after_export)
     self.assertEqual(len(log), len(log_imported_after_export))
     os.remove(os.path.join(OUTPUT_DATA_DIR,
                            "running-example-exported.csv"))
 def test_importExportCSVtoCSV(self):
     # to avoid static method warnings in tests,
     # that by construction of the unittest package have to be expressed in such way
     self.dummy_variable = "dummy_value"
     df = pd.read_csv(os.path.join(INPUT_DATA_DIR, "running-example.csv"))
     df = dataframe_utils.convert_timestamp_columns_in_df(df)
     event_log = log_conversion.apply(
         df, variant=log_conversion.TO_EVENT_STREAM)
     event_log = sorting.sort_timestamp(event_log)
     event_log = sampling.sample(event_log)
     event_log = index_attribute.insert_event_index_as_event_attribute(
         event_log)
     log = log_conversion.apply(event_log)
     log = sorting.sort_timestamp(log)
     log = sampling.sample(log)
     log = index_attribute.insert_trace_index_as_event_attribute(log)
     event_log_transformed = log_conversion.apply(
         log, variant=log_conversion.TO_EVENT_STREAM)
     df = log_conversion.apply(event_log_transformed,
                               variant=log_conversion.TO_DATA_FRAME)
     df.to_csv(os.path.join(OUTPUT_DATA_DIR,
                            "running-example-exported.csv"))
     df = pd.read_csv(
         os.path.join(OUTPUT_DATA_DIR, "running-example-exported.csv"))
     df = dataframe_utils.convert_timestamp_columns_in_df(df)
     event_log_imported_after_export = log_conversion.apply(
         df, variant=log_conversion.TO_EVENT_STREAM)
     log_imported_after_export = log_conversion.apply(
         event_log_imported_after_export)
     self.assertEqual(len(log), len(log_imported_after_export))
     os.remove(os.path.join(OUTPUT_DATA_DIR,
                            "running-example-exported.csv"))
 def test_importExportCSVtoXES(self):
     # to avoid static method warnings in tests,
     # that by construction of the unittest package have to be expressed in such way
     self.dummy_variable = "dummy_value"
     event_log = csv_importer.import_event_stream(os.path.join(INPUT_DATA_DIR, "running-example.csv"))
     event_log = sorting.sort_timestamp(event_log)
     event_log = sampling.sample(event_log)
     event_log = index_attribute.insert_event_index_as_event_attribute(event_log)
     log = log_transform.transform_event_stream_to_event_log(event_log)
     log = sorting.sort_timestamp(log)
     log = sampling.sample(log)
     log = index_attribute.insert_trace_index_as_event_attribute(log)
     xes_exporter.export_log(log, os.path.join(OUTPUT_DATA_DIR, "running-example-exported.xes"))
     log_imported_after_export = xes_importer.import_log(
         os.path.join(OUTPUT_DATA_DIR, "running-example-exported.xes"))
     self.assertEqual(len(log), len(log_imported_after_export))
     os.remove(os.path.join(OUTPUT_DATA_DIR, "running-example-exported.xes"))
 def test_alphaMinerVisualizationFromXES(self):
     # to avoid static method warnings in tests,
     # that by construction of the unittest package have to be expressed in such way
     self.dummy_variable = "dummy_value"
     log, net, marking, fmarking = self.obtainPetriNetThroughAlphaMiner(
         os.path.join(INPUT_DATA_DIR, "running-example.xes"))
     log = sorting.sort_timestamp(log)
     log = sampling.sample(log)
     log = index_attribute.insert_trace_index_as_event_attribute(log)
     petri_exporter.apply(net, marking, os.path.join(OUTPUT_DATA_DIR, "running-example.pnml"))
     os.remove(os.path.join(OUTPUT_DATA_DIR, "running-example.pnml"))
     gviz = pn_viz.graphviz_visualization(net)
     self.assertEqual(gviz, gviz)
     final_marking = petri.petrinet.Marking()
     for p in net.places:
         if not p.out_arcs:
             final_marking[p] = 1
     aligned_traces = token_replay.apply(log, net, marking, fmarking)
     self.assertEqual(aligned_traces, aligned_traces)