Skip to content

Commit

Permalink
Merge pull request #212 from CITCOM-project/quick-out
Browse files Browse the repository at this point in the history
Quick out if no scenario constraints
  • Loading branch information
jmafoster1 authored Jul 13, 2023
2 parents 3e26c35 + 8f96b39 commit c583759
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions causal_testing/data_collection/data_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def filter_valid_data(self, data: pd.DataFrame, check_pos: bool = True) -> pd.Da
f"Missing columns: missing data for variables {missing_variables}. Should they be marked as hidden?"
)

# Quick out if we don't have any constraints
if len(self.scenario.constraints) == 0:
return data

# For each row, does it satisfy the constraints?
solver = z3.Solver()
for c in self.scenario.constraints:
Expand All @@ -56,6 +60,7 @@ def filter_valid_data(self, data: pd.DataFrame, check_pos: bool = True) -> pd.Da
unsat_core = None
for _, row in data.iterrows():
solver.push()
# Check that the row does not violate any scenario constraints
# Need to explicitly cast variables to their specified type. Z3 will not take e.g. np.int64 to be an int.
model = [
self.scenario.variables[var].z3
Expand Down

0 comments on commit c583759

Please sign in to comment.