Skip to content

Commit

Permalink
Merge d7b9494 into 96c9d78
Browse files Browse the repository at this point in the history
  • Loading branch information
jhprinz committed Mar 12, 2016
2 parents 96c9d78 + d7b9494 commit 70ffb67
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
35 changes: 32 additions & 3 deletions openpathsampling/engines/features/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@ def _decorator(cls):

__features__['classes'] += features

# add provided additional feature and run though the added ones
# recursively until nothing is added
feat_no = 0
while feat_no < len(__features__['classes']):
feature = __features__['classes'][feat_no]

# add provides additional features
if hasattr(feature, 'provides'):
if type(feature.provides) is list:
for c in feature.provides:
if c not in __features__['classes']:
__features__['classes'].append(c)
else:
if feature.provides not in __features__['classes']:
__features__['classes'].append(feature.provides)

feat_no += 1

if use_lazy_reversed:
cls._reversed = DelayedLoader()
# if '_reversed' not in __features__['lazy']:
Expand All @@ -91,7 +109,7 @@ def _decorator(cls):
origin = dict()
required = dict()
# loop over all the features
for feature in features:
for feature in __features__['classes']:

# add properties
for prop in feature.attributes:
Expand Down Expand Up @@ -189,7 +207,11 @@ def _decorator(cls):
]
code += [
" cls.{0} : self._lazy[cls.{0}],".format(lazy)
for lazy in __features__['lazy']
for lazy in __features__['lazy'] if lazy not in __features__['numpy']
]
code += [
" cls.{0} : self._lazy[cls.{0}].copy(),".format(lazy)
for lazy in __features__['lazy'] if lazy in __features__['numpy']
]
code += [
" }"
Expand All @@ -202,7 +224,14 @@ def _decorator(cls):
code += map(
" this.{0} = self.{0}".format,
filter(
lambda x : x not in __features__['lazy'],
lambda x : x not in __features__['lazy'] and x not in __features__['numpy'],
__features__['parameters']
)
)
code += map(
" this.{0} = self.{0}.copy()".format,
filter(
lambda x : x not in __features__['lazy'] and x in __features__['numpy'],
__features__['parameters']
)
)
Expand Down
3 changes: 3 additions & 0 deletions openpathsampling/engines/features/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
atomic coordinates
"""

from openpathsampling.engines.features import xyz

attributes = ['coordinates']
numpy = ['coordinates']

provides = [xyz]


def netcdfplus_init(store):
store.create_variable('coordinates', 'numpy.float32',
Expand Down
4 changes: 4 additions & 0 deletions openpathsampling/engines/features/statics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
from shared import StaticContainerStore
import mdtraj

from openpathsampling.engines.features import xyz

attributes = ['statics', 'box_vectors', 'md', 'coordinates']
lazy = ['statics']

provides = [xyz]


def netcdfplus_init(store):
store.storage.create_store('statics', StaticContainerStore())
Expand Down
3 changes: 0 additions & 3 deletions openpathsampling/engines/openmm/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
features.velocities,
features.coordinates,
features.box_vectors,
features.xyz,
features.topology
])
class MDSnapshot(BaseSnapshot):
Expand All @@ -28,7 +27,6 @@ class MDSnapshot(BaseSnapshot):
# features.velocities,
# features.coordinates,
# features.box_vectors,
# features.xyz,
# features.topology
# ],
# description="A fast MDSnapshot",
Expand All @@ -39,7 +37,6 @@ class MDSnapshot(BaseSnapshot):
@features.base.attach_features([
features.statics,
features.kinetics,
features.xyz,
features.topology # for compatibility
])
class Snapshot(BaseSnapshot):
Expand Down
1 change: 0 additions & 1 deletion openpathsampling/engines/toy/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
features=[
features.velocities,
features.coordinates,
features.xyz,
features.topology
],
description="Simulation snapshot. Only references to coordinates and velocities",
Expand Down

0 comments on commit 70ffb67

Please sign in to comment.