Skip to content

Commit 9d61206

Browse files
dwhswensonsroet
andauthored
Apply suggestions from code review
Co-authored-by: Sander Roet <sanderroet@hotmail.com>
1 parent 7fce8a5 commit 9d61206

11 files changed

Lines changed: 15 additions & 30 deletions

File tree

‎paths_cli/commands/compile.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def import_module(module_name, format_type=None, install=None):
1919
if format_type is None:
2020
format_type = module_name
2121

22-
msg = "Unable to find a compiler for f{format_type} on your system."
22+
msg = f"Unable to find a compiler for {format_type} on your system."
2323
if install is not None:
24-
msg += " Please install f{install} to use this format."
24+
msg += f" Please install {install} to use this format."
2525

2626
raise MissingIntegrationError(msg)
2727
return mod

‎paths_cli/compiling/core.py‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ def description(self):
5858
@staticmethod
5959
def _get_from_loader(loader, attr_name, attr):
6060
if attr is None:
61-
try:
62-
attr = getattr(loader, attr_name)
63-
except AttributeError:
64-
pass
61+
attr = getattr(loader, attr_name, None)
6562
return attr
6663

6764
def __call__(self, *args, **kwargs):
@@ -98,7 +95,7 @@ class Builder:
9895
remapper : Callable[[Dict], Dict], optional
9996
callable to remap the the mapping of ???
10097
after_build : Callable[[Any, Dict], Any], optional
101-
ccallable to update the created object with any additional
98+
callable to update the created object with any additional
10299
information from the original dictionary.
103100
"""
104101
def __init__(self, builder, *, remapper=None, after_build=None):
@@ -217,8 +214,8 @@ def compile_attrs(self, dct):
217214
except KeyError:
218215
raise InputError(f"'{self.builder_name}' missing required "
219216
f"parameter '{attr}'")
220-
self.logger.debug(f"{attr}: {input_dct[attr]}")
221-
new_dct[attr] = func(input_dct[attr])
217+
self.logger.debug(f"{attr}: {value}")
218+
new_dct[attr] = func(value)
222219

223220
optionals = set(self.optional_attributes) & set(dct)
224221

‎paths_cli/compiling/root_compiler.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def _sort_user_categories(user_categories):
168168
"""Organize user input categories into compile order.
169169
170170
"Cateogories" are the first-level keys in the user input file (e.g.,
171-
'engines', 'cvs', etc.) There must be one CategoryCompiler per category.
171+
'engines', 'cvs', etc.). There must be one CategoryCompiler per category.
172172
"""
173173
user_to_canonical = {user_key: _canonical_name(user_key)
174174
for user_key in user_categories}

‎paths_cli/compiling/schemes.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __call__(self, **dct):
4343
scheme = builder(**dct)
4444
for strat in strategies:
4545
scheme.append(strat)
46-
# self.logger.debug(f"strategies: {scheme.strategies}")
46+
self.logger.debug(f"strategies: {scheme.strategies}")
4747
return scheme
4848

4949

‎paths_cli/compiling/strategies.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def _group_parameter(group_name):
3434
SP_SELECTOR_PARAMETER,
3535
ENGINE_PARAMETER,
3636
SHOOTING_GROUP_PARAMETER,
37-
Parameter('replace', bool, default=True)
37+
REPLACE_TRUE_PARAMETER
3838
],
3939
name='one-way-shooting',
4040
)

‎paths_cli/compiling/topology.py‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@
44

55
def get_topology_from_engine(dct):
66
"""If given the name of an engine, use that engine's topology"""
7-
# from paths_cli.compiling.engines import engine_compiler
87
engine_compiler = compiler_for('engine')
98
if dct in engine_compiler.named_objs:
109
engine = engine_compiler.named_objs[dct]
11-
try:
12-
return engine.topology
13-
except AttributeError: # no-cov
14-
# how could this happen? passing is correct, to raise the
15-
# InputError from MultiStrategyBuilder, but how to test?
16-
pass
10+
return getattr(engine, 'topology', None)
1711

1812
def get_topology_from_file(dct):
1913
"""If given the name of a file, use that to create the topology"""

‎paths_cli/tests/commands/test_compile.py‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_loaders(mod_name, tmpdir):
2929
dump_getter = {
3030
'json': _std_dump,
3131
'yaml': _std_dump,
32-
'toml': _std_dump,
32+
# 'toml': _std_dump,
3333
}[mod_name]
3434
loader = {
3535
'json': load_json,
@@ -83,7 +83,7 @@ def test_compile(ad_openmm, test_data_dir):
8383
traceback.print_tb(result.exc_info[2])
8484
print(result.exception)
8585
print(result.exc_info)
86-
print(result.output)
86+
print(result.output)
8787
assert result.exit_code == 0
8888
assert os.path.exists(str(ad_openmm / 'setup.db'))
8989
import openpathsampling as paths
@@ -100,8 +100,3 @@ def test_compile(ad_openmm, test_data_dir):
100100
from openpathsampling.experimental.storage.monkey_patches import unpatch
101101
paths = unpatch(paths)
102102
paths.InterfaceSet.simstore = False
103-
import importlib
104-
importlib.reload(paths.netcdfplus)
105-
importlib.reload(paths.collectivevariable)
106-
importlib.reload(paths.collectivevariables)
107-
importlib.reload(paths)

‎paths_cli/tests/compiling/test_cvs.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ def test_build_mdtraj_function_cv(self):
3939
def test_bad_mdtraj_function_name(self):
4040
yml = self.yml.format(kwargs=self.kwargs, func="foo")
4141
dct = yaml.load(yml, Loader=yaml.FullLoader)
42-
with pytest.raises(InputError):
42+
with pytest.raises(InputError, match="foo"):
4343
cv = MDTRAJ_CV_PLUGIN(dct)

‎paths_cli/tests/compiling/test_engines.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def setup(self):
1818
"integrator: integrator.xml", "topology: ad.pdb",
1919
"n_steps_per_frame: 10", "n_frames_max: 10000"
2020
])
21-
pass
2221

2322
def teardown(self):
2423
os.chdir(self.cwd)

‎paths_cli/tests/compiling/test_topology.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ def test_build_topology_fail(self):
2828
patch_loc = 'paths_cli.compiling.root_compiler._COMPILERS'
2929
compilers = {'engine': mock_compiler('engine')}
3030
with patch.dict(patch_loc, compilers):
31-
with pytest.raises(InputError):
31+
with pytest.raises(InputError, match="foo"):
3232
topology = build_topology('foo')

0 commit comments

Comments
 (0)