Skip to content

Commit f836c62

Browse files
committed
Linting
1 parent 29c9e0f commit f836c62

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

explainer/explainer_signal.py

+19-11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import requests
77
from tutorial.conf import system_instance, workspace_id, user_name, pw
88

9+
910
class ExplainerSignal:
1011
def __init__(self):
1112
self.constraints = [] # List to store constraints (constraint patterns)
@@ -80,7 +81,7 @@ def conformant(self, trace, constraints=None):
8081
:return: Boolean indicating if the trace is conformant with all constraints.
8182
"""
8283
if constraints == None:
83-
return self.post_query_trace_in_dataset(trace, self.constraints)
84+
return self.post_query_trace_in_dataset(trace, self.constraints)
8485
return self.post_query_trace_in_dataset(trace, constraints)
8586

8687
def minimal_expl(self, trace):
@@ -224,13 +225,14 @@ def get_nodes_from_constraint(self, constraint=None):
224225
return list(set(self.filter_keywords(constraint)))
225226

226227
def filter_keywords(self, text):
227-
""" Extracts the events from a SIGNAL constraint
228+
"""
229+
Extracts the events from a SIGNAL constraint
228230
229231
Args:
230232
text (String): The SIGNAL constraint
231233
232234
Returns:
233-
[String]: A list of the filtered events from the SIGNAL constraint
235+
[String]: A list of the filtered events from the SIGNAL constraint
234236
"""
235237
text = re.sub(r"\s+", "_", text.strip())
236238
words = re.findall(r"\b[A-Z_a-z]+\b", text)
@@ -392,7 +394,7 @@ def constraint_ctrb_to_fitness(self, log=None, constraints=None, index=-1):
392394
len_log = self.get_total_cases()
393395
return ctrb_count / (len_log * len(constraints))
394396

395-
def check_conformance(self, constraint, negative = True):
397+
def check_conformance(self, constraint, negative=True):
396398
"""
397399
Checks the conformance of the event log against a specific constraint.
398400
@@ -419,7 +421,9 @@ def check_violations(self, constraints):
419421
combined_constraints = " OR ".join(
420422
[f"NOT event_name MATCHES {constraint}" for constraint in constraints]
421423
)
422-
query = f'SELECT COUNT(CASE_ID) FROM "defaultview-4" WHERE {combined_constraints}'
424+
query = (
425+
f'SELECT COUNT(CASE_ID) FROM "defaultview-4" WHERE {combined_constraints}'
426+
)
423427
return self.post_query(query) # Execute the query and return the result
424428

425429
def get_total_cases(self):
@@ -442,7 +446,7 @@ def post_query(self, query):
442446
cache_key = hash(query) # Generate a cache key for the query
443447
if cache_key in self.cache: # Check if the result is already in the cache
444448
return self.cache[cache_key] # Return cached result if available
445-
449+
446450
# Send the query to the server
447451
request = requests.post(
448452
self.signal_endpoint,
@@ -464,15 +468,15 @@ def post_query_trace_in_dataset(self, trace, constraints):
464468
"""
465469
if not constraints:
466470
constraints = self.constraints # Use self.constraints if none are provided
467-
471+
468472
# Combine constraints with AND if there are multiple, otherwise use the single constraint
469473
if len(constraints) > 1:
470474
constraints = " AND ".join(
471475
[f"event_name MATCHES {constraint}" for constraint in constraints]
472476
)
473477
else:
474478
constraints = "".join(f"event_name MATCHES {constraints[0]}")
475-
479+
476480
# Formulate the query
477481
query = f'SELECT ACTIVITY, COUNT(CASE_ID) FROM "defaultview-4" WHERE {constraints}'
478482
cache_key = hash(query) # Generate a cache key for the query
@@ -503,8 +507,12 @@ def get_all_conformant_traces(self):
503507
constraints = "".join(f"event_name MATCHES {constraints[0]}")
504508

505509
# Formulate the query
506-
query = f'SELECT ACTIVITY, COUNT(CASE_ID) FROM "defaultview-4" WHERE {constraints}'
507-
return self.post_query_return_all(query) # Execute the query and return the list of conformant traces
510+
query = (
511+
f'SELECT ACTIVITY, COUNT(CASE_ID) FROM "defaultview-4" WHERE {constraints}'
512+
)
513+
return self.post_query_return_all(
514+
query
515+
) # Execute the query and return the list of conformant traces
508516

509517
def post_query_return_all(self, query):
510518
"""
@@ -516,7 +524,7 @@ def post_query_return_all(self, query):
516524
cache_key = hash(query) # Generate a cache key for the query
517525
if cache_key in self.cache: # Check if the result is already in the cache
518526
return self.cache[cache_key] # Return cached result if available
519-
527+
520528
# Send the query to the server
521529
request = requests.post(
522530
self.signal_endpoint,

0 commit comments

Comments
 (0)