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

Some PSA module components don't behave as expected #1507

Closed
sseyler opened this Issue Jul 18, 2017 · 0 comments

Comments

Projects
None yet
3 participants
@sseyler
Contributor

sseyler commented Jul 18, 2017

NOTE: The issues described below are fixed in the context of #1006 (increase code coverage in PSA)


Expected behaviour

  1. MDAnalysis.analysis.psa.dist_mat_to_vec() should return an integer index between 0 and N*(N-1)/2 - 1, regardless of input type; e.g.,
>>> MDAnalysis.analysis.psa.dist_mat_to_vec(3, 0, 1)
<type 'int'>
>>> MDAnalysis.analysis.psa.dist_mat_to_vec(3.0, 0, 1)
<type 'int'>
  1. MDAnalysis.analysis.psa.PSAnalysis.run_pairs_analysis() should store (Hausdorff) distances in an all-pairs matrix as MDAnalysis.analysis.psa.PSAnalysis.run() does. (The distances are computed anyway, so it is trivial to store them in a 2D NumPy array as usual.)

Actual behaviour

  1. MDAnalysis.analysis.psa.dist_mat_to_vec() returns a float if one or more arguments are of type float.
  2. MDAnalysis.analysis.psa.PSAnalysis.run_pairs_analysis() doesn't store (Hausdorff) distances in an all-pairs matrix like MDAnalysis.analysis.psa.PSAnalysis.run() does; the user must utilize dist_mat_to_vec() to extract distances from MDAnalysis.analysis.psa.PSAnalysis.hausdorff_pairs[idx]['distance'], where idx would be an integer index of a pair of compared paths (e.g., calculated from dist_mat_to_vec()).

Note: The problem with dist_mat_to_vec(), where a float was returned for float argument(s) provided as input, became apparent in attempting to extract Hausdorff distances from the list of {frames, distance} dictionaries in stored as psa.PSAnalysis.hausdorff_pairs after running run_pairs_analysis().

Code to reproduce the behaviour

>>> import MDAnalysis
>>> MDAnalysis.analysis.psa.dist_mat_to_vec(3.0, 0, 1)
<type 'float'>
In [1]: import MDAnalysis as mda
In [2]: import MDAnalysis.analysis.psa as PSA
In [3]: from MDAnalysisTests.datafiles import PSF, DCD
In [4]: u1 = mda.Universe(PSF, DCD)
In [5]: u2 = mda.Universe(PSF, DCD)
In [6]: u3 = mda.Universe(PSF, DCD)
In [7]: mypsa = PSA.PSAnalysis([u1, u2, u3],  path_select='name CA')
In [8]: mypsa.generate_paths(align=True)
Fitted frame    98/98  [100.0%]
Fitted frame    98/98  [100.0%]
Fitted frame    98/98  [100.0%]

In [9]: mypsa.paths[-1] = mypsa.paths[-1][::-1,:,:]  # reverse third path
In [10]: idx = PSA.dist_mat_to_vec(3.0, 0, 1)
In [11]: mypsa.run_pairs_analysis(neighbors=True, hausdorff_pairs=True)
In [12]: mypsa.hausdorff_pairs[idx]['distance']
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-b6132d74b16e> in <module>()
----> 1 mypsa.hausdorff_pairs[idx]['distance']

TypeError: list indices must be integers, not float

Applicable versions of MDAnalysis: 0.15.0 (up through 0.16.2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment