This commit is contained in:
@@ -5,30 +5,8 @@ import glob
|
||||
import os
|
||||
import sys
|
||||
|
||||
STATE_COLUMNS = [
|
||||
"open_count",
|
||||
"closed_stick_count",
|
||||
"closed_slip_count",
|
||||
"closed_restick_count",
|
||||
"separating_count",
|
||||
"state_failed_projection_count",
|
||||
]
|
||||
|
||||
|
||||
def require_columns(row: dict[str, str], columns: list[str]) -> bool:
|
||||
missing = [column for column in columns if column not in row]
|
||||
if missing:
|
||||
print("missing contact diagnostic columns: " + ", ".join(missing))
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def read_pair_rows(result_dir: str) -> list[dict[str, str]]:
|
||||
rows: list[dict[str, str]] = []
|
||||
for path in sorted(glob.glob(os.path.join(result_dir, "contact_*.csv"))):
|
||||
with open(path, newline="") as stream:
|
||||
rows.extend(row for row in csv.DictReader(stream) if row["kind"] == "PAIR")
|
||||
return rows
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
|
||||
from contact_schema import read_pair_rows, require_pair_schema
|
||||
|
||||
|
||||
def main() -> int:
|
||||
@@ -40,18 +18,7 @@ def main() -> int:
|
||||
if len(pair_rows) < 2:
|
||||
print("shell-shell contact diagnostic path is too short")
|
||||
return 1
|
||||
if not require_columns(
|
||||
pair_rows[0],
|
||||
STATE_COLUMNS
|
||||
+ [
|
||||
"gap_residual",
|
||||
"gap_l2",
|
||||
"failed_projection_count",
|
||||
"active_set_flip_count",
|
||||
"aug_factor",
|
||||
"aug_lambda",
|
||||
],
|
||||
):
|
||||
if not require_pair_schema(pair_rows):
|
||||
return 1
|
||||
|
||||
profile_path = os.path.join(result_dir, "shell_shell_contact_profile.csv")
|
||||
|
||||
Reference in New Issue
Block a user