Skip to content

Commit c583759

Browse files
authored
Merge pull request #212 from CITCOM-project/quick-out
Quick out if no scenario constraints
2 parents 3e26c35 + 8f96b39 commit c583759

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

causal_testing/data_collection/data_collector.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ def filter_valid_data(self, data: pd.DataFrame, check_pos: bool = True) -> pd.Da
4848
f"Missing columns: missing data for variables {missing_variables}. Should they be marked as hidden?"
4949
)
5050

51+
# Quick out if we don't have any constraints
52+
if len(self.scenario.constraints) == 0:
53+
return data
54+
5155
# For each row, does it satisfy the constraints?
5256
solver = z3.Solver()
5357
for c in self.scenario.constraints:
@@ -56,6 +60,7 @@ def filter_valid_data(self, data: pd.DataFrame, check_pos: bool = True) -> pd.Da
5660
unsat_core = None
5761
for _, row in data.iterrows():
5862
solver.push()
63+
# Check that the row does not violate any scenario constraints
5964
# Need to explicitly cast variables to their specified type. Z3 will not take e.g. np.int64 to be an int.
6065
model = [
6166
self.scenario.variables[var].z3

0 commit comments

Comments
 (0)