diff --git a/package/AUTHORS b/package/AUTHORS index 1313548bda9..43e64e745dc 100644 --- a/package/AUTHORS +++ b/package/AUTHORS @@ -81,6 +81,7 @@ Chronological list of authors - Shantanu Srivastava 2017 - Utkarsh Bansal + - Vedant Rathore External code ------------- diff --git a/package/CHANGELOG b/package/CHANGELOG index f75f30545d5..79c5866ea6a 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -15,7 +15,7 @@ The rules for this file: ------------------------------------------------------------------------------ ??/??/16 kain88-de, fiona-naughton, richardjgowers, tyler.je.reddy, jdetle euhruska, orbeckst, rbrtdlg, jbarnoud, wouterboomsma, shanmbic, - dotsdl, manuel.nuno.melo, utkbansal + dotsdl, manuel.nuno.melo, utkbansal, vedantrathore * 0.16.0 @@ -61,6 +61,7 @@ Enhancements * Added groupby method to Group objects. (PR #1112) Fixes + * Argument validation of dist_mat_to_vec is fixed (#597 PR #1183) * Give correct error when the topology file format is not recognized (Issue #982) * Give correct error when file doesn't exist/ has bad permissions (Issue #981) * Improvement of analysis/waterdynamics module (Issue #935) diff --git a/package/MDAnalysis/analysis/psa.py b/package/MDAnalysis/analysis/psa.py index aaa57adabb8..44f9ea92d25 100644 --- a/package/MDAnalysis/analysis/psa.py +++ b/package/MDAnalysis/analysis/psa.py @@ -212,6 +212,7 @@ from six.moves import range, cPickle import numpy as np +import warnings import MDAnalysis import MDAnalysis.analysis.align @@ -581,7 +582,7 @@ def dist_mat_to_vec(N, i, j): error_str = "Matrix indices are invalid; i and j must be greater than 0 and N must be greater the 2" raise ValueError(error_str) - if i > N or j > N: + if (j > i and (i > N - 1 or j > N)) or (j < i and (i > N or j > N - 1)): err_str = "Matrix indices are out of range; i and j must be less than" \ + " N = {0:d}".format(N) raise ValueError(err_str) @@ -591,7 +592,7 @@ def dist_mat_to_vec(N, i, j): warn_str = "Column index entered (j = {:d} is smaller than row index" \ + " (i = {:d}). Using symmetric element in upper triangle of" \ + " distance matrix instead: i --> j, j --> i" - warnings.warn(war_str.format(j, i)) + warnings.warn(warn_str.format(j, i)) return (N*j) + i - (j+2)*(j+1)/2 else: err_str = "Error in processing matrix indices; i and j must be integers"\ diff --git a/testsuite/AUTHORS b/testsuite/AUTHORS index 6745b837268..5dc674d5986 100644 --- a/testsuite/AUTHORS +++ b/testsuite/AUTHORS @@ -73,7 +73,7 @@ Chronological list of authors 2017 - Utkarsh Bansal - + - Vedant Rathore External code ------------- diff --git a/testsuite/CHANGELOG b/testsuite/CHANGELOG index 77800f0b95f..a5f18e496e3 100644 --- a/testsuite/CHANGELOG +++ b/testsuite/CHANGELOG @@ -14,7 +14,7 @@ and https://github.com/MDAnalysis/mdanalysis/wiki/UnitTests ------------------------------------------------------------------------------ ??/??/16 jbarnoud, orbeckst, fiona-naughton, manuel.nuno.melo, richardjgowers - tyler.je.reddy, utkbansal + tyler.je.reddy, utkbansal, vedantrathore * 0.16 - added two unit tests for MDAnalysis.analysis.polymer diff --git a/testsuite/MDAnalysisTests/analysis/test_psa.py b/testsuite/MDAnalysisTests/analysis/test_psa.py index 9c6e03d3a2f..45ee8da6e27 100644 --- a/testsuite/MDAnalysisTests/analysis/test_psa.py +++ b/testsuite/MDAnalysisTests/analysis/test_psa.py @@ -144,7 +144,7 @@ def test_dist_mat_to_vec_func_out_of_bounds(self): with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, -1, 2) - # Check if i is negative + # Check if j is negative with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, 1, -2)