Skip to content

Commit

Permalink
fixed lint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Isha Gokhale committed Oct 24, 2023
1 parent c4d191a commit 92b5fae
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
10 changes: 3 additions & 7 deletions casanovo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,12 @@ def __init__(self, config_file: Optional[str] = None):
keys_set = set(self._params.keys())
users_set = set(self._user_config.keys())
missing = list(keys_set - users_set)
raise KeyError(
f"Missing expected entry {missing}"
)
raise KeyError(f"Missing expected entry {missing}")
# detect unrecognized config file entries
keys = list(self._params.keys())
for key,val in self._user_config.items():
for key, val in self._user_config.items():
if key not in keys:
raise KeyError(
f"Unrecognized config file entry {key}"
)
raise KeyError(f"Unrecognized config file entry {key}")
# Validate:
for key, val in self._config_types.items():
self.validate_param(key, val)
Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def tiny_config(tmp_path):
"model_save_folder_path": str(tmp_path),
"accelerator": "cpu",
"precursor_mass_tol": 5,
"isotope_error_range": [0,1],
"isotope_error_range": [0, 1],
"min_peptide_len": 6,
"predict_batch_size": 1024,
"n_beams": 1,
Expand Down Expand Up @@ -252,8 +252,8 @@ def tiny_config(tmp_path):
"+42.011": 42.010565,
"+43.006": 43.005814,
"-17.027": -17.026549,
"+43.006-17.027": 25.980265
}
"+43.006-17.027": 25.980265,
},
}

cfg_file = tmp_path / "config.yml"
Expand Down
12 changes: 5 additions & 7 deletions tests/unit_tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@ def test_override(tmp_path, tiny_config):
"""
)

with open (tiny_config, 'r') as read_file:
with open(tiny_config, "r") as read_file:
contents = yaml.safe_load(read_file)
contents['random_seed_'] = 354
print(contents)
contents["random_seed_"] = 354

with open('output.yml', 'w') as write_file:
with open("output.yml", "w") as write_file:
yaml.safe_dump(contents, write_file)
with pytest.raises(KeyError):
config = Config('output.yml')
config = Config("output.yml")

with pytest.raises(KeyError):
config = Config(yml)

config = Config(yml)

0 comments on commit 92b5fae

Please sign in to comment.