Skip to content

Commit a9c4d96

Browse files
committed
simplify code to reflect current usage
1 parent a52bac0 commit a9c4d96

4 files changed

Lines changed: 16 additions & 124 deletions

File tree

‎paths_cli/wizard/shooting.py‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ def gaussian_selector(wizard):
2222
selector = paths.GaussianBiasSelector(cv, alpha=alpha, l_0=l_0)
2323
return selector
2424

25-
def random_velocities(wizard):
26-
pass
25+
# def random_velocities(wizard):
26+
# pass
2727

28-
def gaussian_momentum_shift(wizard):
29-
pass
28+
# def gaussian_momentum_shift(wizard):
29+
# pass
3030

31-
def get_allowed_modifiers(engine):
32-
allowed = []
33-
randomize_attribs = ['randomize_velocities', 'apply_constraints']
34-
if any(hasattr(engine, attr) for attr in randomize_attribs):
35-
allowed.append('random_velocities')
31+
# def get_allowed_modifiers(engine):
32+
# allowed = []
33+
# randomize_attribs = ['randomize_velocities', 'apply_constraints']
34+
# if any(hasattr(engine, attr) for attr in randomize_attribs):
35+
# allowed.append('random_velocities')
3636

37-
if not engine.has_constraints():
38-
allowed.append('velocity_changers')
37+
# if not engine.has_constraints():
38+
# allowed.append('velocity_changers')
3939

40-
return allowed
40+
# return allowed
4141

4242
SHOOTING_SELECTORS = {
4343
'Uniform random': uniform_selector,
@@ -64,8 +64,8 @@ def one_way_shooting(wizard, selectors=None, engine=None):
6464
strat = strategies.OneWayShootingStrategy(selector=selector)
6565
return strat
6666

67-
def two_way_shooting(wizard, selectors=None, modifiers=None):
68-
pass
67+
# def two_way_shooting(wizard, selectors=None, modifiers=None):
68+
# pass
6969

7070
def spring_shooting(wizard, engine=None):
7171
from openpathsampling import strategies

‎paths_cli/wizard/steps.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
from paths_cli.wizard.cvs import cvs
55
from paths_cli.wizard.engines import engines
66
from paths_cli.wizard.volumes import volumes
7-
from paths_cli.wizard.tps import (
8-
flex_length_tps_network, fixed_length_tps_network, tps_scheme
9-
)
7+
from paths_cli.wizard.tps import tps_scheme
108

119
WizardStep = namedtuple('WizardStep', ['func', 'display_name', 'store_name',
1210
'minimum', 'maximum'])

‎paths_cli/wizard/tps.py‎

Lines changed: 1 addition & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,8 @@
11
from paths_cli.wizard.tools import a_an
22
from paths_cli.wizard.core import get_missing_object
3-
from paths_cli.wizard.shooting import (
4-
shooting,
5-
# ALGORITHMS
6-
one_way_shooting,
7-
two_way_shooting,
8-
spring_shooting,
9-
# SELECTORS
10-
uniform_selector,
11-
gaussian_selector,
12-
# MODIFIERS
13-
random_velocities,
14-
# all_atom_delta_v,
15-
# single_atom_delta_v,
16-
)
3+
from paths_cli.wizard.shooting import shooting
174
from functools import partial
185

19-
def _select_states(wizard, state_type):
20-
# TODO: change this significantly ... I dislike in usage
21-
states = []
22-
do_another = True
23-
while do_another:
24-
options = [name for name in wizard.states
25-
if name not in states]
26-
done = f"No more {state_type} states to select"
27-
if len(states) >= 1:
28-
options.append(done)
29-
30-
state = wizard.ask_enumerate(
31-
f"Pick a state to use for as {a_an(state_type)} {state_type} "
32-
"state", options=options
33-
)
34-
if state == done:
35-
do_another = False
36-
else:
37-
states.append(state)
38-
39-
state_objs = [wizard.states[state] for state in states]
40-
return state_objs
41-
42-
def _get_pathlength(wizard):
43-
# redo as get_custom_eval with int type
44-
pathlength = None
45-
while pathlength is None:
46-
len_str = wizard.ask("How long (in frames) do you want yout "
47-
"trajectories to be?")
48-
try:
49-
pathlength = int(len_str)
50-
except Exceptions as e:
51-
wizard.exception(f"Sorry, I couldn't make '{len_str}' into "
52-
"an integer.", e)
53-
return pathlength
54-
55-
def flex_length_tps_network(wizard):
56-
import openpathsampling as paths
57-
initial_states = _select_states(wizard, 'initial')
58-
final_states = _select_states(wizard, 'final')
59-
network = paths.TPSNetwork(initial_states, final_states)
60-
return network
61-
62-
def fixed_length_tps_network(wizard):
63-
import openpathsampling as paths
64-
pathlength = _get_pathlength(wizard)
65-
initial_states = _select_states(wizard, 'initial')
66-
final_states = _select_states(wizard, 'final')
67-
network = paths.FixedLengthTPSNetwork(initial_states, final_states,
68-
length=pathlength)
69-
return network
70-
71-
def tps_network(wizard):
72-
import openpathsampling as paths
73-
FIXED = "Fixed length TPS"
74-
FLEX = "Flexible length TPS"
75-
tps_types = {
76-
FLEX: paths.TPSNetwork,
77-
FIXED: paths.FixedLengthTPSNetwork,
78-
}
79-
network_type = None
80-
network_type = wizard.ask_enumerate(
81-
"Do you want to do flexible path length TPS (recommended) "
82-
"or fixed path length TPS?", options=list(tps_types.keys())
83-
)
84-
network_class = tps_types[network_type]
85-
86-
if network_type == FIXED:
87-
pathlength = _get_pathlength(wizard)
88-
network_class = partial(network_class, length=pathlength)
89-
90-
initial_states = _select_states(wizard, 'initial')
91-
final_states = _select_states(wizard, 'final')
92-
93-
# TODO: summary
94-
95-
obj = network_class(initial_states, final_states)
96-
return obj
97-
986
def _get_network(wizard):
997
if len(wizard.networks) == 0:
1008
network = tps_network(wizard)
@@ -121,16 +29,3 @@ def tps_scheme(wizard, network=None):
12129
scheme.append(shooting_strategy)
12230
scheme.append(global_strategy)
12331
return scheme
124-
125-
def tps_setup(wizard):
126-
network = tps_network(wizard)
127-
scheme = tps_scheme(wizard, network)
128-
# name it
129-
# provide final info on how to use it
130-
return scheme
131-
132-
133-
if __name__ == "__main__":
134-
from paths_cli.wizard.wizard import Wizard
135-
wiz = Wizard({'tps_network': ('networks', 1, '='),
136-
'tps_scheme': ('schemes', 1, '=')})

‎paths_cli/wizard/wizard.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ def obj_selector(self, store_name, text_name, create_func):
136136
sel = self.ask_enumerate(f"Which {text_name} would you like to "
137137
"use?", list(opts.keys()))
138138
obj = opts[sel](self)
139-
print(sel, obj)
140139
if sel == create_new:
141140
obj = self.register(obj, text_name, store_name)
142141
return obj

0 commit comments

Comments
 (0)