Skip to content

Commit c976789

Browse files
authored
Merge pull request #26 from Axiomatic-AI/print-only-formalized
Print only formalized statments (optional)
2 parents bc40c90 + 30bb08b commit c976789

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/axiomatic/pic_helpers.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def plot_parameter_history(parameters: List[Parameter], parameter_history: List[
208208
plt.show()
209209

210210

211-
def print_statements(statements: StatementDictionary, validation: Optional[StatementValidationDictionary] = None):
211+
def print_statements(statements: StatementDictionary, validation: Optional[StatementValidationDictionary] = None, only_formalized: bool = False):
212212
"""
213213
Print a list of statements in nice readable format.
214214
"""
@@ -231,6 +231,8 @@ def print_statements(statements: StatementDictionary, validation: Optional[State
231231

232232
print("-----------------------------------\n")
233233
for cost_stmt, cost_val in zip(statements.cost_functions or [], validation.cost_functions or []):
234+
if (cost_stmt.formalization is None or cost_stmt.formalization.mapping is None) and only_formalized:
235+
continue
234236
print("Type:", cost_stmt.type)
235237
print("Statement:", cost_stmt.text)
236238
print("Formalization:", end=" ")
@@ -256,6 +258,8 @@ def print_statements(statements: StatementDictionary, validation: Optional[State
256258
print(val.message)
257259
print("\n-----------------------------------\n")
258260
for param_stmt, param_val in zip(statements.parameter_constraints or [], validation.parameter_constraints or []):
261+
if (param_stmt.formalization is None or param_stmt.formalization.mapping is None) and only_formalized:
262+
continue
259263
print("Type:", param_stmt.type)
260264
print("Statement:", param_stmt.text)
261265
print("Formalization:", end=" ")
@@ -281,6 +285,8 @@ def print_statements(statements: StatementDictionary, validation: Optional[State
281285
print(f"Holds: {val.holds} ({val.message})")
282286
print("\n-----------------------------------\n")
283287
for struct_stmt, struct_val in zip(statements.structure_constraints or [], validation.structure_constraints or []):
288+
if struct_stmt.formalization is None and only_formalized:
289+
continue
284290
print("Type:", struct_stmt.type)
285291
print("Statement:", struct_stmt.text)
286292
print("Formalization:", end=" ")
@@ -301,11 +307,12 @@ def print_statements(statements: StatementDictionary, validation: Optional[State
301307
print(f"Satisfiable: {val.satisfiable}")
302308
print(f"Holds: {val.holds}")
303309
print("\n-----------------------------------\n")
304-
for unf_stmt in statements.unformalizable_statements or []:
305-
print("Type:", unf_stmt.type)
306-
print("Statement:", unf_stmt.text)
307-
print("Formalization: UNFORMALIZABLE")
308-
print("\n-----------------------------------\n")
310+
if not only_formalized:
311+
for unf_stmt in statements.unformalizable_statements or []:
312+
print("Type:", unf_stmt.type)
313+
print("Statement:", unf_stmt.text)
314+
print("Formalization: UNFORMALIZABLE")
315+
print("\n-----------------------------------\n")
309316

310317

311318
def _str_units_to_float(str_units: str) -> float:

0 commit comments

Comments
 (0)