Skip to content

Commit acc6be2

Browse files
committed
finish pylint/flake8 for compiling
1 parent df656ed commit acc6be2

4 files changed

Lines changed: 23 additions & 6 deletions

File tree

‎paths_cli/compiling/strategies.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55
)
66
from paths_cli.compiling.root_compiler import compiler_for
77

8+
89
def _strategy_name(class_name):
910
return f"openpathsampling.strategies.{class_name}"
1011

12+
1113
def _group_parameter(group_name):
1214
return Parameter('group', str, default=group_name,
1315
description="the group name for these movers")
1416

17+
1518
# TODO: maybe this moves into shooting once we have the metadata?
1619
SP_SELECTOR_PARAMETER = Parameter('selector', shooting_selector_compiler,
1720
default=None)
18-
1921
ENGINE_PARAMETER = Parameter('engine', compiler_for('engine'),
2022
description="the engine for moves of this "
2123
"type")
@@ -39,6 +41,7 @@ def _group_parameter(group_name):
3941
name='one-way-shooting',
4042
)
4143
build_one_way_shooting_strategy = ONE_WAY_SHOOTING_STRATEGY_PLUGIN
44+
4245
# build_two_way_shooting_strategy = StrategyCompilerPlugin(
4346
# builder=Builder(_strategy_name("TwoWayShootingStrategy")),
4447
# parameters = [

‎paths_cli/compiling/tools.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import numpy as np
2-
from .errors import InputError
2+
from paths_cli.compiling.errors import InputError
3+
34

45
def custom_eval(obj, named_objs=None):
56
"""Parse user input to allow simple math.
@@ -19,10 +20,12 @@ def custom_eval(obj, named_objs=None):
1920
}
2021
return eval(string, namespace)
2122

23+
2224
def custom_eval_int(obj, named_objs=None):
2325
val = custom_eval(obj, named_objs)
2426
return int(val)
2527

28+
2629
def custom_eval_int_strict_pos(obj, named_objs=None):
2730
val = custom_eval_int(obj, named_objs)
2831
if val <= 0:
@@ -33,6 +36,7 @@ def custom_eval_int_strict_pos(obj, named_objs=None):
3336
class UnknownAtomsError(RuntimeError):
3437
pass
3538

39+
3640
def mdtraj_parse_atomlist(inp_str, n_atoms, topology=None):
3741
"""
3842
n_atoms: int
@@ -47,7 +51,7 @@ def mdtraj_parse_atomlist(inp_str, n_atoms, topology=None):
4751
raise TypeError("Input is not integers")
4852
if arr.shape != (1, n_atoms):
4953
# try to clean it up
50-
if len(arr.shape) == 1 and arr.shape[0] == n_atoms:
54+
if len(arr.shape) == 1 and arr.shape[0] == n_atoms:
5155
arr.shape = (1, n_atoms)
5256
else:
5357
raise TypeError(f"Invalid input. Requires {n_atoms} "

‎paths_cli/compiling/topology.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import os
2-
from .errors import InputError
2+
from paths_cli.compiling.errors import InputError
33
from paths_cli.compiling.root_compiler import compiler_for
44

5+
56
def get_topology_from_engine(dct):
67
"""If given the name of an engine, use that engine's topology"""
78
engine_compiler = compiler_for('engine')
89
if dct in engine_compiler.named_objs:
910
engine = engine_compiler.named_objs[dct]
1011
return getattr(engine, 'topology', None)
12+
return None
13+
1114

1215
def get_topology_from_file(dct):
1316
"""If given the name of a file, use that to create the topology"""
@@ -16,6 +19,7 @@ def get_topology_from_file(dct):
1619
import openpathsampling as paths
1720
trj = md.load(dct)
1821
return paths.engines.MDTrajTopology(trj.topology)
22+
return None
1923

2024

2125
class MultiStrategyBuilder:
@@ -35,6 +39,7 @@ def __call__(self, dct):
3539
# only get here if we failed
3640
raise InputError.invalid_input(dct, self.label)
3741

42+
3843
build_topology = MultiStrategyBuilder(
3944
[get_topology_from_file, get_topology_from_engine],
4045
label='topology',

‎paths_cli/compiling/volumes.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import operator
22
import functools
33

4-
from .core import Parameter
5-
from .tools import custom_eval
4+
from paths_cli.compiling.core import Parameter
5+
from paths_cli.compiling.tools import custom_eval
66
from paths_cli.compiling.plugins import VolumeCompilerPlugin, CategoryPlugin
77
from paths_cli.compiling.root_compiler import compiler_for
88

9+
910
# TODO: extra function for volumes should not be necessary as of OPS 2.0
1011
def cv_volume_build_func(**dct):
1112
import openpathsampling as paths
@@ -18,6 +19,7 @@ def cv_volume_build_func(**dct):
1819
# TODO: wrap this with some logging
1920
return builder(**dct)
2021

22+
2123
CV_VOLUME_PLUGIN = VolumeCompilerPlugin(
2224
builder=cv_volume_build_func,
2325
parameters=[
@@ -39,6 +41,7 @@ def cv_volume_build_func(**dct):
3941
'items': {"$ref": "#/definitions/volume_type"}
4042
}
4143

44+
4245
INTERSECTION_VOLUME_PLUGIN = VolumeCompilerPlugin(
4346
builder=lambda subvolumes: functools.reduce(operator.__and__,
4447
subvolumes),
@@ -52,6 +55,7 @@ def cv_volume_build_func(**dct):
5255

5356
build_intersection_volume = INTERSECTION_VOLUME_PLUGIN
5457

58+
5559
UNION_VOLUME_PLUGIN = VolumeCompilerPlugin(
5660
builder=lambda subvolumes: functools.reduce(operator.__or__,
5761
subvolumes),
@@ -65,5 +69,6 @@ def cv_volume_build_func(**dct):
6569

6670
build_union_volume = UNION_VOLUME_PLUGIN
6771

72+
6873
VOLUME_COMPILER = CategoryPlugin(VolumeCompilerPlugin, aliases=['state',
6974
'states'])

0 commit comments

Comments
 (0)