Skip to content

Commit 1e531ba

Browse files
committed
more tests for compiling.schemes
1 parent ad714d9 commit 1e531ba

3 files changed

Lines changed: 30 additions & 21 deletions

File tree

‎paths_cli/compiling/plugins.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ def __init__(self, plugin_class, aliases=None, requires_ops=(1, 0),
1818
def name(self):
1919
return self.plugin_class.compiler_name
2020

21+
def __repr__(self):
22+
return (f"CompilerPlugin({self.plugin_class.__name__}, "
23+
f"{self.aliases})")
24+
2125

2226
class EngineCompilerPlugin(InstanceBuilder):
2327
compiler_name = 'engine'
@@ -32,7 +36,7 @@ class NetworkCompilerPlugin(InstanceBuilder):
3236
compiler_name = 'network'
3337

3438
class SchemeCompilerPlugin(InstanceBuilder):
35-
compiler_name = 'scheme'
39+
compiler_name = 'scheme'
3640

3741
class StrategyCompilerPlugin(InstanceBuilder):
3842
compiler_name = 'strategy'

‎paths_cli/compiling/strategies.py‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ def _group_parameter(group_name):
3030
REPLACE_FALSE_PARAMETER = Parameter('replace', bool, default=False)
3131

3232

33-
34-
build_one_way_shooting_strategy = StrategyCompilerPlugin(
33+
ONE_WAY_SHOOTING_STRATEGY_PLUGIN = StrategyCompilerPlugin(
3534
builder=Builder(_strategy_name("OneWayShootingStrategy")),
3635
parameters=[
3736
SP_SELECTOR_PARAMETER,
@@ -41,18 +40,18 @@ def _group_parameter(group_name):
4140
],
4241
name='one-way-shooting',
4342
)
44-
45-
build_two_way_shooting_strategy = StrategyCompilerPlugin(
46-
builder=Builder(_strategy_name("TwoWayShootingStrategy")),
47-
parameters = [
48-
Parameter('modifier', ...),
49-
SP_SELECTOR_PARAMETER,
50-
ENGINE_PARAMETER,
51-
SHOOTING_GROUP_PARAMETER,
52-
REPLACE_TRUE_PARAMETER,
53-
],
54-
name='two-way-shooting',
55-
)
43+
build_one_way_shooting_strategy = ONE_WAY_SHOOTING_STRATEGY_PLUGIN
44+
# build_two_way_shooting_strategy = StrategyCompilerPlugin(
45+
# builder=Builder(_strategy_name("TwoWayShootingStrategy")),
46+
# parameters = [
47+
# Parameter('modifier', ...),
48+
# SP_SELECTOR_PARAMETER,
49+
# ENGINE_PARAMETER,
50+
# SHOOTING_GROUP_PARAMETER,
51+
# REPLACE_TRUE_PARAMETER,
52+
# ],
53+
# name='two-way-shooting',
54+
# )
5655

5756
build_nearest_neighbor_repex_strategy = StrategyCompilerPlugin(
5857
builder=Builder(_strategy_name("NearestNeighborRepExStrategy")),

‎paths_cli/tests/compiling/test_schemes.py‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from unittest.mock import patch
77
from openpathsampling.tests.test_helpers import make_1d_traj
88
from paths_cli.tests.compiling.utils import mock_compiler
9+
from paths_cli.compiling.strategies import ONE_WAY_SHOOTING_STRATEGY_PLUGIN
910

1011
_COMPILERS_LOC = 'paths_cli.compiling.root_compiler._COMPILERS'
1112

@@ -42,6 +43,7 @@ def test_build_spring_shooting_scheme(tps_compilers_and_traj):
4243
assert isinstance(scheme, paths.SpringShootingMoveScheme)
4344
# smoke test that it can build its tree and load init conds
4445
scheme.move_decision_tree()
46+
assert len(scheme.strategies) == 2 # includes the global
4547
_ = scheme.initial_conditions_from_trajectories(traj)
4648

4749

@@ -61,18 +63,22 @@ def test_build_one_way_shooting_scheme(network, tps_compilers_and_traj,
6163
_ = scheme.initial_conditions_from_trajectories(traj)
6264

6365

64-
def test_movescheme_plugin(tis_compilers_and_traj, flat_engine):
66+
def test_movescheme_plugin(tis_compilers_and_traj):
6567
paths.InterfaceSet._reset()
6668
compilers, traj = tis_compilers_and_traj
69+
compilers['strategy'] = mock_compiler(
70+
'strategy',
71+
type_dispatch={
72+
'one-way-shooting': ONE_WAY_SHOOTING_STRATEGY_PLUGIN
73+
},
74+
named_objs={}
75+
)
6776

6877
dct = {'network': 'tis_network',
6978
'strategies': [
70-
{'type': ''},
71-
{'type': ''},
72-
{'type': ''},
73-
{'type': ''},
79+
{'type': 'one-way-shooting',
80+
'engine': 'flat_engine'},
7481
]}
75-
pytest.skip()
7682
with patch.dict(_COMPILERS_LOC, compilers):
7783
scheme = MOVESCHEME_PLUGIN(dct)
7884

0 commit comments

Comments
 (0)