Skip to content

Commit

Permalink
fix test to close invalid json file (#657)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-goggins authored Jun 13, 2023
1 parent 3b52b40 commit 3bad598
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 9 additions & 6 deletions phdi/linkage/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,12 +949,15 @@ def read_linkage_config(config_file: pathlib.Path) -> List[dict]:
various parts of linkage pass function.
"""
try:
algo_config = json.load(open(config_file))
# Need to convert function keys back to column indices, since
# JSON serializes dict keys as strings
for rl_pass in algo_config.get("algorithm"):
rl_pass["funcs"] = {int(col): f for (col, f) in rl_pass["funcs"].items()}
return algo_config.get("algorithm", [])
with open(config_file) as f:
algo_config = json.load(f)
# Need to convert function keys back to column indices, since
# JSON serializes dict keys as strings
for rl_pass in algo_config.get("algorithm"):
rl_pass["funcs"] = {
int(col): f for (col, f) in rl_pass["funcs"].items()
}
return algo_config.get("algorithm", [])
except FileNotFoundError:
raise FileNotFoundError(f"No file exists at path {config_file}.")
except json.decoder.JSONDecodeError as e:
Expand Down
1 change: 0 additions & 1 deletion tests/not_valid_json_test.json

This file was deleted.

0 comments on commit 3bad598

Please sign in to comment.