Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST/DOC: Add a test for vanhove and fix the documented example. #516

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion trackpy/motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def vanhove(pos, lagtime, mpp=1, ensemble=False, bins=24):
Examples
--------
>>> pos = traj.set_index(['frame', 'particle'])['x'].unstack() # particles as columns
>>> vh = vanhove(pos)
>>> vh = vanhove(pos, lagtime=2)
"""
# Reindex with consecutive frames, placing NaNs in the gaps.
pos = pos.reindex(np.arange(pos.index[0], 1 + pos.index[-1]))
Expand Down
18 changes: 18 additions & 0 deletions trackpy/tests/test_motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,24 @@ def test_theta_entropy(self):
self.steppers.groupby('particle').apply(theta_entropy)


class TestVanHove(StrictTestCase):
def setUp(self):
N = 10
P = 50 # particles
A = 1 # step amplitude
np.random.seed(0)
particles = [DataFrame({'x': A*random_walk(N), 'y': A*random_walk(N),
'frame': np.arange(N), 'particle': i})
for i in range(P)]
self.many_walks = conformity(pandas_concat(particles))

def test_vanhove(self):
# a simple "smoke test" to ensure no exceptions are raised
traj = self.many_walks
pos = traj.set_index(['frame', 'particle'])['x'].unstack() # particles as columns
vh = tp.vanhove(pos, lagtime=2)


if __name__ == '__main__':
import nose
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
Expand Down