Skip to content

Commit

Permalink
Merge branch 'master' into pyup-pin-codecov-2.1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcello-Sega authored Apr 18, 2024
2 parents 10ee524 + b14af7e commit 990ec8d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions pytim/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def _assign_layers(self):

@property
def atoms(self):
if len(self._layers) == 0: return self._layers # an empty atom group
return self._layers[:].sum()

@property
Expand Down
5 changes: 5 additions & 0 deletions pytim/observables/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ def _sample_random_distribution(self, group):
rnd *= self.interface.universe.dimensions[:3]
rnd_pos = IntrinsicDistance(
self.interface, symmetry=self.symmetry).compute(rnd)
# the interpolator can return NaNs in some cases
rnd_pos = rnd_pos[np.isfinite(rnd_pos)]
rnd_accum, bins, _ = stats.binned_statistic(
rnd_pos,
np.ones(len(rnd_pos)),
Expand Down Expand Up @@ -221,6 +223,9 @@ def sample(self, group, **kargs):
rnd_accum, bins = self._sample_random_distribution(group)

values = self.observable.compute(group, **kargs)
# the interpolator can return NaNs in some cases
cond = np.isfinite(pos)
values, pos = values[cond], pos[cond]
accum, bins, _ = stats.binned_statistic(
pos,
values,
Expand Down
16 changes: 14 additions & 2 deletions pytim/willard_chandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

class WillardChandler(Interface):
""" Identifies the dividing surface using the Willard-Chandler method
NOTE that this method does *not* identify surface atoms
*(Willard, A. P.; Chandler, D. J. Phys. Chem. B 2010, 114, 1954–1958)*
Expand Down Expand Up @@ -83,9 +84,20 @@ class WillardChandler(Interface):
@property
def layers(self):
""" The method does not identify layers.
Example:
>>> import MDAnalysis as mda
>>> import pytim
>>> from pytim.datafiles import *
>>>
>>> u = mda.Universe(MICELLE_PDB)
>>> g = u.select_atoms('resname DPC')
>>> inter= pytim.WillardChandler(u, group=g, alpha=3.0, fast=True)
>>> inter.layers
<AtomGroup with 0 atoms>
"""
self.layers = None
return None
return self._layers

def _sanity_checks(self):
""" Basic checks to be performed after the initialization.
Expand Down
4 changes: 2 additions & 2 deletions requirements.testing.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mdtraj
pytest==7.2.1
pytest==8.1.1
codecov==2.1.13
pytest-cov
pytest-cov==5.0.0

0 comments on commit 990ec8d

Please sign in to comment.