Skip to content

Commit 07e96c6

Browse files
committed
Addressed Chris's comments
1 parent 4e8b0c9 commit 07e96c6

File tree

4 files changed

+3
-9
lines changed

4 files changed

+3
-9
lines changed

causal_testing/data_collection/data_collector.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ def filter_valid_data(self, data: pd.DataFrame, check_pos: bool = True) -> pd.Da
5050
for _, row in data.iterrows():
5151
solver.push()
5252
# Need to explicitly cast variables to their specified type. Z3 will not take e.g. np.int64 to be an int.
53-
for var in self.scenario.variables:
54-
self.scenario.variables[var].z3 == self.scenario.variables[var].z3_val(
55-
self.scenario.variables[var].z3, row[var]
56-
)
5753
model = [
5854
self.scenario.variables[var].z3
5955
== self.scenario.variables[var].z3_val(self.scenario.variables[var].z3, row[var])
@@ -145,7 +141,7 @@ def collect_data(self, **kwargs) -> pd.DataFrame:
145141
for meta in self.scenario.metas():
146142
meta.populate(execution_data_df)
147143
scenario_execution_data_df = self.filter_valid_data(execution_data_df)
148-
for vname, var in self.scenario.variables.items():
144+
for var_name, var in self.scenario.variables.items():
149145
if issubclass(var.datatype, Enum):
150-
scenario_execution_data_df[vname] = [var.datatype(x) for x in scenario_execution_data_df[vname]]
146+
scenario_execution_data_df[var_name] = [var.datatype(x) for x in scenario_execution_data_df[var_name]]
151147
return scenario_execution_data_df

causal_testing/generation/abstract_causal_test_case.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ def _generate_concrete_tests(
111111
== self.scenario.variables[v].z3_val(self.scenario.variables[v].z3, row[v])
112112
)
113113

114-
# optimizer.add_soft([optimizer.add_soft(self.scenario.variables[v].z3 == self.scenario.variables[v].z3_val(self.scenario.variables[v].z3, row[v])) for v in run_columns])
115114
if optimizer.check() == z3.unsat:
116115
logger.warning(
117116
"Satisfiability of test case was unsat.\n" "Constraints \n %s \n Unsat core %s",

causal_testing/json_front/json_class.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ def _create_abstract_test_case(self, test, mutates, effects):
9393
abstract_test = AbstractCausalTestCase(
9494
scenario=self.modelling_scenario,
9595
intervention_constraints=[mutates[v](k) for k, v in test["mutations"].items()],
96-
# TODO: Could change JSON to be treatment_var and mutation to it rather than a dict of mutations
9796
treatment_variable=next(self.modelling_scenario.variables[v] for v in test["mutations"]),
9897
expected_causal_effect={
9998
self.modelling_scenario.variables[variable]: effects[effect]

causal_testing/specification/variable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def z3_val(self, z3_var, val: Any) -> T:
173173
native_val = self.cast(val)
174174
if isinstance(native_val, Enum):
175175
values = [z3_var.sort().constructor(c)() for c in range(z3_var.sort().num_constructors())]
176-
values = [v for v in values if type(val)(str(v)) == val]
176+
values = [v for v in values if val.__class__(str(v)) == val]
177177
assert len(values) == 1, f"Expected {values} to be length 1"
178178
return values[0]
179179
return native_val

0 commit comments

Comments
 (0)