Skip to content

Commit 64cd901

Browse files
committed
Quick out for data checking. Closes #209
1 parent 7ad5827 commit 64cd901

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

causal_testing/data_collection/data_collector.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ 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+
55+
5156
# For each row, does it satisfy the constraints?
5257
solver = z3.Solver()
5358
for c in self.scenario.constraints:
@@ -57,6 +62,7 @@ def filter_valid_data(self, data: pd.DataFrame, check_pos: bool = True) -> pd.Da
5762
for _, row in data.iterrows():
5863
solver.push()
5964
# Need to explicitly cast variables to their specified type. Z3 will not take e.g. np.int64 to be an int.
65+
# Check that the row does not violate any scenario constraints
6066
model = [
6167
self.scenario.variables[var].z3
6268
== self.scenario.variables[var].z3_val(self.scenario.variables[var].z3, row[var])

0 commit comments

Comments
 (0)