Skip to content

Commit 60eb119

Browse files
dwhswensonsroet
andauthored
Apply suggestions from code review
Co-authored-by: Sander Roet <sanderroet@hotmail.com>
1 parent 0b33b79 commit 60eb119

8 files changed

Lines changed: 16 additions & 26 deletions

File tree

‎paths_cli/tests/wizard/test_core.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,3 @@ def test_get_missing_object(length, expected):
4848
result = get_missing_object(wizard, dct, display_name='string',
4949
fallback_func=fallback)
5050
assert result == expected
51-
pass

‎paths_cli/tests/wizard/test_load_from_ops.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,3 @@ def test_load_from_ops(ops_file_fixture):
9494

9595
assert isinstance(obj, NamedObj)
9696
assert obj.name == 'bar'
97-
98-
pass

‎paths_cli/wizard/core.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ def interpret_req(req):
1313
return str(min_)
1414

1515
if min_ >= 1:
16-
string += "at least " + str(min_)
16+
string += f"at least {min_}"
1717

1818
if max_ < float("inf"):
19-
if string != "":
19+
if string:
2020
string += " and "
21-
string += "at most " + str(max_)
21+
string += f"at most {max_}"
2222

2323
return string
2424

@@ -44,4 +44,3 @@ def inner(*args, **kwargs):
4444
return obj
4545
return inner
4646

47-

‎paths_cli/wizard/cvs.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ def _mdtraj_function_cv(wizard, cv_does_str, cv_user_prompt, func,
8080
kwargs = {kwarg_name: indices}
8181

8282
summary = ("Here's what we'll create:\n"
83-
" Function: " + str(func.__name__) + "\n"
84-
" Atoms: " + " ".join([str(topology.mdtraj.atom(i))
85-
for i in indices[0]]) + "\n"
86-
" Topology: " + repr(topology.mdtraj))
83+
f" Function: {func.__name__}\n"
84+
f" Atoms: {" ".join([str(topology.mdtraj.atom(i))
85+
for i in indices[0]])} \n"
86+
f" Topology: {repr(topology.mdtraj))}"
8787
wizard.say(summary)
8888

8989
return MDTrajFunctionCV(func, topology, period_min=period_min,

‎paths_cli/wizard/joke.py‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,9 @@ def _joke4(name, obj_type): # no-cov
3636
a_an_thing=a_an_thing)
3737

3838
def name_joke(name, obj_type): # no-cov
39-
rnd = random.random()
40-
if rnd < 0.25:
41-
joke = _joke1
42-
elif rnd < 0.50:
43-
joke = _joke2
44-
elif rnd < 0.65:
45-
joke = _joke3
46-
else:
47-
joke = _joke4
39+
jokes = [_joke1, _joke2, _joke3, _joke4]
40+
weights = [5, 5, 3, 7]
41+
joke = random.choices(jokes, weights=weights)[0]
4842
return joke(name, obj_type)
4943

5044
if __name__ == "__main__":

‎paths_cli/wizard/load_from_ops.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def list_items(wizard, user_input):
99
store = getattr(storage, store_name)
1010
names = [obj for obj in store if obj.is_named]
1111
outstr = "\n".join(['* ' + obj.name for obj in names])
12-
wizard.say("Here's what I found:\n\n" + outstr)
12+
wizard.say(f"Here's what I found:\n\n{outstr})
1313

1414
return list_items
1515

‎paths_cli/wizard/tps.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from functools import partial
77

88
def tps_network(wizard):
9-
raise NotImplementedError("Still need to add other network choic")
9+
raise NotImplementedError("Still need to add other network choices")
1010

1111

1212
def tps_scheme(wizard, network=None):

‎paths_cli/wizard/volumes.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ def _vol_intro(wizard, as_state):
1717
def _binary_func_volume(wizard, op):
1818
wizard.say("Let's make the first constituent volume:")
1919
vol1 = volumes(wizard)
20-
wizard.say(f"The first volume is:\n{str(vol1)}")
20+
wizard.say(f"The first volume is:\n{vol1}")
2121
wizard.say("Let's make the second constituent volume:")
2222
vol2 = volumes(wizard)
23-
wizard.say(f"The second volume is:\n{str(vol2)}")
23+
wizard.say(f"The second volume is:\n{vol2}")
2424
vol = op(vol1, vol2)
25-
wizard.say(f"Created a volume:\n{str(vol)}")
25+
wizard.say(f"Created a volume:\n{vol}")
2626
return vol
2727

2828
def intersection_volume(wizard):
@@ -42,7 +42,7 @@ def negated_volume(wizard):
4242
wizard.say("Let's make the subvolume.")
4343
subvol = volumes(wizard)
4444
vol = ~subvol
45-
wizard.say(f"Created a volume:\n{str(vol)}")
45+
wizard.say(f"Created a volume:\n{vol}")
4646
return vol
4747

4848
def cv_defined_volume(wizard):

0 commit comments

Comments
 (0)