Skip to content

Commit 005aeab

Browse files
committed
more pylint cleanup for the wizard
main thing left is, I think, wizard.py
1 parent 8ed2442 commit 005aeab

9 files changed

Lines changed: 28 additions & 23 deletions

File tree

‎paths_cli/wizard/plugin_classes.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88

99
class WizardObjectPluginRegistrationError(Exception):
10-
pass
10+
"""Error during wizard object plugin registration.
11+
"""
1112

1213

1314
_PLUGIN_DOCSTRING = """
@@ -30,6 +31,7 @@ class WizardObjectPluginRegistrationError(Exception):
3031
created
3132
""" + _PLUGIN_DOCSTRING
3233

34+
3335
class LoadFromOPS(OPSPlugin):
3436
"""Wizard plugin type to load from an existing OPS file.
3537
@@ -62,6 +64,7 @@ def __init__(self, category, *, obj_name=None, store_name=None,
6264
def __call__(self, wizard, context=None):
6365
return load_from_ops(wizard, self.store_name, self.obj_name)
6466

67+
6568
def get_text_from_context(name, instance, default, wizard, context, *args,
6669
**kwargs):
6770
"""Generic method for getting text from context of other sources.
@@ -130,6 +133,7 @@ def __init__(self, name, category, builder, *, prerequisite=None,
130133
self._summary = summary # func to summarize
131134

132135
def default_summarize(self, wizard, context, result):
136+
"""Default summary function"""
133137
return [f"Here's what we'll make:\n {str(result)}"]
134138

135139
def get_summary(self, wizard, context, result):
@@ -354,8 +358,7 @@ def _set_context(self, wizard, context, selected):
354358
"""If user has provided a funtion to create context, use it."""
355359
if self._user_set_context:
356360
return self._user_set_context(wizard, context, selected)
357-
else:
358-
return context
361+
return context
359362

360363
def register_plugin(self, plugin):
361364
"""Register a :class:`.WizardObjectPlugin` with this category.

‎paths_cli/wizard/plugin_registration.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
import logging
12
from paths_cli.wizard.plugin_classes import (
23
LoadFromOPS, WizardObjectPlugin, WrapCategory
34
)
45
from paths_cli.utils import get_installed_plugins
56
from paths_cli.plugin_management import NamespacePluginLoader
67

7-
import logging
88
logger = logging.getLogger(__name__)
99

1010

1111
class CategoryWizardPluginRegistrationError(Exception):
12-
pass
12+
"""Error with wizard category plugin registration fails"""
1313

1414

1515
_CATEGORY_PLUGINS = {}
@@ -70,15 +70,16 @@ def register_plugins(plugins):
7070
object_plugins.append(plugin)
7171

7272
for plugin in categories:
73-
logger.debug("Registering " + str(plugin))
73+
logger.debug("Registering %s", str(plugin))
7474
_register_category_plugin(plugin)
7575

7676
for plugin in object_plugins:
7777
category = _CATEGORY_PLUGINS[plugin.category]
78-
logger.debug("Registering " + str(plugin))
79-
logger.debug("Category: " + str(category))
78+
logger.debug("Registering %s", str(plugin))
79+
logger.debug("Category: %s", str(category))
8080
category.register_plugin(plugin)
8181

82+
8283
def register_installed_plugins():
8384
"""Register all Wizard plugins found in standard locations.
8485

‎paths_cli/wizard/run_module.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from paths_cli.wizard.wizard import Wizard
33
from paths_cli.wizard.plugin_registration import get_category_wizard
44

5+
56
# TODO: for now we ignore this for coverage -- it's mainly used for UX
67
# testing by allowing each module to be run with, e.g.:
78
# python -m paths_cli.wizard.engines

‎paths_cli/wizard/shooting.py‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22

33
from paths_cli.wizard.core import get_missing_object
44
from paths_cli.wizard.plugin_registration import get_category_wizard
5-
from paths_cli.compiling.tools import custom_eval
65

7-
engines = get_category_wizard('engine')
86

9-
import numpy as np
7+
engines = get_category_wizard('engine')
108

119

1210
def uniform_selector(wizard):
11+
"""Create a uniform selector (using the wizard)"""
1312
import openpathsampling as paths
1413
return paths.UniformSelector()
1514

15+
1616
def gaussian_selector(wizard):
17+
"""Create a Gaussian biased selector (using the wizard)"""
1718
import openpathsampling as paths
1819
cv_name = wizard.ask_enumerate("Which CV do you want the Gaussian to "
1920
"be based on?",
@@ -44,6 +45,7 @@ def gaussian_selector(wizard):
4445

4546
# return allowed
4647

48+
4749
SHOOTING_SELECTORS = {
4850
'Uniform random': uniform_selector,
4951
'Gaussian bias': gaussian_selector,
@@ -59,6 +61,7 @@ def _get_selector(wizard, selectors=None):
5961
selector = selectors[sel](wizard)
6062
return selector
6163

64+
6265
def one_way_shooting(wizard, selectors=None, engine=None):
6366
from openpathsampling import strategies
6467
if engine is None:
@@ -73,6 +76,7 @@ def one_way_shooting(wizard, selectors=None, engine=None):
7376
# def two_way_shooting(wizard, selectors=None, modifiers=None):
7477
# pass
7578

79+
7680
def spring_shooting(wizard, engine=None):
7781
import openpathsampling as paths
7882
if engine is None:
@@ -109,10 +113,10 @@ def shooting(wizard, shooting_types=None, engine=None):
109113
# allowed_modifiers = get_allowed_modifiers(engine)
110114
# TWO_WAY = 'Two-way shooting'
111115
# if len(allowed_modifiers) == 0 and TWO_WAY in shooting_types:
112-
# del shooting_types[TWO_WAY]
116+
# del shooting_types[TWO_WAY]
113117
# else:
114-
# shooting_types[TWO_WAY] = partial(two_way_shooting,
115-
# allowed_modifiers=allowed_modifiers)
118+
# shooting_types[TWO_WAY] = partial(two_way_shooting,
119+
# allowed_modifiers=allowed_modifiers)
116120

117121
shooting_type = None
118122
if len(shooting_types) == 1:
@@ -126,4 +130,3 @@ def shooting(wizard, shooting_types=None, engine=None):
126130

127131
shooting_strategy = shooting_type(wizard)
128132
return shooting_strategy
129-

‎paths_cli/wizard/standard_categories.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
CATEGORIES = {cat.name: cat for cat in _CATEGORY_LIST}
2525

26+
2627
def get_category_info(category):
2728
"""Obtain info for a stanard (or registered) category.
2829

‎paths_cli/wizard/steps.py‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
from collections import namedtuple
2-
from functools import partial
3-
42
from paths_cli.wizard.plugin_registration import get_category_wizard
5-
from paths_cli.wizard.tps import tps_scheme
63

74
volumes = get_category_wizard('volume')
85

@@ -26,5 +23,3 @@
2623
store_name="states",
2724
minimum=2,
2825
maximum=float('inf'))
29-
30-

‎paths_cli/wizard/tools.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
def a_an(obj):
22
return "an" if obj[0].lower() in "aeiou" else "a"
33

4+
45
def yes_no(char):
56
return {'yes': True, 'no': False, 'y': True, 'n': False}[char.lower()]

‎paths_cli/wizard/tps.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from paths_cli.wizard.tools import a_an
21
from paths_cli.wizard.core import get_missing_object
32
from paths_cli.wizard.shooting import shooting
43
from paths_cli.wizard.plugin_registration import get_category_wizard
54

6-
from functools import partial
75
volumes = get_category_wizard('volume')
86

7+
98
def tps_network(wizard):
109
raise NotImplementedError("Still need to add other network choices")
1110

‎paths_cli/wizard/two_state_tps.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
)
66
from paths_cli.wizard.wizard import Wizard
77
from paths_cli.wizard import pause
8+
from paths_cli.wizard.volumes import _FIRST_STATE, _VOL_DESC
89

910
volumes = get_category_wizard('volume')
10-
from paths_cli.wizard.volumes import _FIRST_STATE, _VOL_DESC
11+
1112

1213
def two_state_tps(wizard, fixed_length=False):
1314
import openpathsampling as paths

0 commit comments

Comments
 (0)