[Debichem-devel] Bug#1028722: prody: FTBFS: AssertionError: 3205 != 3211 : selection 'abs(x) == sqrt(sq(x))' for Selection 'all' failed, expected 3211, selected 3205

Santiago Vila sanvila at debian.org
Thu Oct 12 19:22:31 BST 2023


tags 1028722 + patch
thanks

Hello.

I asked Drew Parsons to look at this bug because he reported a similar
bug with severity:serious here:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1053265

In both cases the failure happens while comparing floating
point numbers using the equality comparison operator (==),
or something similarly dangerous.

It's true that in a first look it might seem that it's comparing
integer numbers, but as upstream explains here:

https://github.com/prody/ProDy/issues/1594#issuecomment-1748400116

it's actually comparing vectors of floating point numbers and
after that it's counting the number of matches between those vectors.

This is known to be a bad practice and should be avoided, as
machines with different floating point implementations
may yield different results for the "same" math operation.

This is why it fails 100% of the time in the virtual
machines from Hetzner where I tried, and for this reason
I would consider this to be a violation of Policy 4.2.

As an experiment (suggested by Drew) I ran today
"autopkgtest -B -- null" on a Hetzner machine using the
installed packages from the archive (built by the official buildds)
and as expected it also fails that way (see first attach).

To summarize: The failing test is buggy because when it fails
it does not necessarily mean that the package was misbuilt,
and in my opinion the best thing to do would be to disable it,
both in stable and unstable.

Trivial patch in the second attach.

Thanks.
-------------- next part --------------
=================================== FAILURES ===================================
______________________ TestSelect.testFunctionSelection13 ______________________

self = <prody.tests.atomic.test_select.TestSelect testMethod=testFunctionSelection13>
pdb = 'pdb3mht', test = ('abs(x) == sqrt(sq(x))', 3211), type_ = 'function'
kwargs = {}, atoms = <AtomGroup: 3mht (3211 atoms)>
selstr = 'abs(x) == sqrt(sq(x))', natoms = 3211, selstr2 = None
sel = array([   0,    1,    2, ..., 3208, 3209, 3210])

    def func(self, pdb=case, test=test, type_=type_, **kwargs):
    
        atoms = SELECTION_TESTS[pdb]['ag']
    
        selstr = test[0]
        natoms = test[1]
        selstr2 = None
        kwargs = EMPTYDICT
        if len(test) == 3:
            selstr2 = test[2]
        if len(test) == 4:
            kwargs = test[3]
    
        if natoms is None:
            self.assertRaises(prody.select.SelectionError,
                SELECT.getIndices, atoms, selstr, **kwargs)
        elif selstr2 is None:
            sel = SELECT.getIndices(atoms, selstr, **kwargs)
>           self.assertEqual(len(sel), natoms,
                'selection {0} for {1} failed, expected '
                '{2}, selected {3}'.format(repr(selstr),
                str(atoms), natoms, len(sel)))
E           AssertionError: 3205 != 3211 : selection 'abs(x) == sqrt(sq(x))' for AtomGroup 3mht failed, expected 3211, selected 3205

tests/atomic/test_select.py:442: AssertionError
______________________ TestSelect.testFunctionSelection14 ______________________

self = <prody.tests.atomic.test_select.TestSelect testMethod=testFunctionSelection14>
pdb = 'pdb3mht', test = ('abs(x) == sqrt(sq(x))', 3211), type_ = 'function'
kwargs = {}, atoms = <Selection: 'all' from 3mht (3211 atoms)>
selstr = 'abs(x) == sqrt(sq(x))', natoms = 3211, selstr2 = None
sel = array([   0,    1,    2, ..., 3208, 3209, 3210])

    @dec.slow
    def func(self, pdb=case, test=test, type_=type_, **kwargs):
    
        atoms = SELECTION_TESTS[pdb]['all']
    
        selstr = test[0]
        natoms = test[1]
        selstr2 = None
        kwargs = EMPTYDICT
        if len(test) == 3:
            selstr2 = test[2]
        if len(test) == 4:
            kwargs = test[3]
    
        if natoms is None:
            self.assertRaises(prody.select.SelectionError,
                SELECT.getIndices, atoms, selstr, **kwargs)
        elif selstr2 is None:
            sel = SELECT.getIndices(atoms, selstr, **kwargs)
>           self.assertEqual(len(sel), natoms,
                'selection {0} for {1} failed, expected '
                '{2}, selected {3}'.format(repr(selstr),
                str(atoms), natoms, len(sel)))
E           AssertionError: 3205 != 3211 : selection 'abs(x) == sqrt(sq(x))' for Selection 'all' failed, expected 3211, selected 3205

tests/atomic/test_select.py:483: AssertionError
=============================== warnings summary ===============================
utilities/misctools.py:424
  /usr/lib/python3/dist-packages/prody/utilities/misctools.py:424: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    import pkg_resources

../Bio/pairwise2.py:278
  /usr/lib/python3/dist-packages/Bio/pairwise2.py:278: BiopythonDeprecationWarning: Bio.pairwise2 has been deprecated, and we intend to remove it in a future release of Biopython. As an alternative, please consider using Bio.Align.PairwiseAligner as a replacement, and contact the Biopython developers if you still need the Bio.pairwise2 module.
    warnings.warn(

apps/evol_apps/__init__.py:3
  /usr/lib/python3/dist-packages/prody/apps/evol_apps/__init__.py:3: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
    import imp

tests/apps/test_prody_anm.py:42
  /usr/lib/python3/dist-packages/prody/tests/apps/test_prody_anm.py:42: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/apps/test_prody_catdcd.py:36
  /usr/lib/python3/dist-packages/prody/tests/apps/test_prody_catdcd.py:36: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/apps/test_prody_catdcd.py:52
  /usr/lib/python3/dist-packages/prody/tests/apps/test_prody_catdcd.py:52: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/apps/test_prody_catdcd.py:79
  /usr/lib/python3/dist-packages/prody/tests/apps/test_prody_catdcd.py:79: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/apps/test_prody_catdcd.py:108
  /usr/lib/python3/dist-packages/prody/tests/apps/test_prody_catdcd.py:108: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/apps/test_prody_catdcd.py:118
  /usr/lib/python3/dist-packages/prody/tests/apps/test_prody_catdcd.py:118: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/apps/test_prody_catdcd.py:128
  /usr/lib/python3/dist-packages/prody/tests/apps/test_prody_catdcd.py:128: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/apps/test_prody_catdcd.py:137
  /usr/lib/python3/dist-packages/prody/tests/apps/test_prody_catdcd.py:137: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/apps/test_prody_examples.py:64: 18 warnings
  /usr/lib/python3/dist-packages/prody/tests/apps/test_prody_examples.py:64: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/apps/test_prody_gnm.py:40
  /usr/lib/python3/dist-packages/prody/tests/apps/test_prody_gnm.py:40: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/apps/test_prody_pca.py:44
  /usr/lib/python3/dist-packages/prody/tests/apps/test_prody_pca.py:44: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/apps/test_prody_pca.py:61
  /usr/lib/python3/dist-packages/prody/tests/apps/test_prody_pca.py:61: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/atomic/test_select.py:464: 269 warnings
  /usr/lib/python3/dist-packages/prody/tests/atomic/test_select.py:464: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

utilities/eigtools.py:41
utilities/eigtools.py:41
utilities/eigtools.py:41
tests/dynamics/test_enms.py::TestRTB::testCalcModes
  /usr/lib/python3/dist-packages/prody/utilities/eigtools.py:41: DeprecationWarning: Keyword argument 'eigvals' is deprecated in favour of 'subset_by_index' keyword instead and will be removed in SciPy 1.12.0.
    values, vectors = linalg.eigh(M, turbo=turbo, eigvals=eigvals)

utilities/eigtools.py:41
utilities/eigtools.py:41
utilities/eigtools.py:41
utilities/eigtools.py:41
  /usr/lib/python3/dist-packages/prody/utilities/eigtools.py:41: DeprecationWarning: Keyword argument 'turbo' is deprecated in favour of 'driver=gvd' keyword instead and will be removed in SciPy 1.12.0.
    values, vectors = linalg.eigh(M, turbo=turbo, eigvals=eigvals)

trajectory/dcdfile.py:273: 2 warnings
tests/apps/test_prody_catdcd.py: 38 warnings
tests/measure/test_measure.py: 10 warnings
tests/trajectory/test_dcdfile.py: 4 warnings
tests/trajectory/test_frame.py: 6 warnings
  /usr/lib/python3/dist-packages/prody/trajectory/dcdfile.py:273: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
    xyz = fromstring(self._file.read(self._itemsize * n_floats),

trajectory/dcdfile.py:320: 1 warning
tests/apps/test_prody_catdcd.py: 6 warnings
tests/measure/test_measure.py: 2 warnings
tests/trajectory/test_dcdfile.py: 3 warnings
  /usr/lib/python3/dist-packages/prody/trajectory/dcdfile.py:320: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
    data = fromstring(data, self._dtype)

tests/proteins/test_dssp.py:20
  /usr/lib/python3/dist-packages/prody/tests/proteins/test_dssp.py:20: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/proteins/test_dssp.py:26
  /usr/lib/python3/dist-packages/prody/tests/proteins/test_dssp.py:26: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/proteins/test_localpdb.py:24
  /usr/lib/python3/dist-packages/prody/tests/proteins/test_localpdb.py:24: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/proteins/test_localpdb.py:30
  /usr/lib/python3/dist-packages/prody/tests/proteins/test_localpdb.py:30: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/proteins/test_localpdb.py:40
  /usr/lib/python3/dist-packages/prody/tests/proteins/test_localpdb.py:40: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/proteins/test_localpdb.py:52
  /usr/lib/python3/dist-packages/prody/tests/proteins/test_localpdb.py:52: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/proteins/test_localpdb.py:74
  /usr/lib/python3/dist-packages/prody/tests/proteins/test_localpdb.py:74: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/proteins/test_pdbfile.py:204
  /usr/lib/python3/dist-packages/prody/tests/proteins/test_pdbfile.py:204: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/proteins/test_pdbfile.py:217
  /usr/lib/python3/dist-packages/prody/tests/proteins/test_pdbfile.py:217: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/proteins/test_pdbfile.py:233
  /usr/lib/python3/dist-packages/prody/tests/proteins/test_pdbfile.py:233: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/proteins/test_pdbfile.py:259
  /usr/lib/python3/dist-packages/prody/tests/proteins/test_pdbfile.py:259: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/proteins/test_pdbfile.py:285
  /usr/lib/python3/dist-packages/prody/tests/proteins/test_pdbfile.py:285: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/proteins/test_pdbfile.py:299
  /usr/lib/python3/dist-packages/prody/tests/proteins/test_pdbfile.py:299: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/proteins/test_wwpdb.py:30
  /usr/lib/python3/dist-packages/prody/tests/proteins/test_wwpdb.py:30: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

tests/proteins/test_wwpdb.py:47
  /usr/lib/python3/dist-packages/prody/tests/proteins/test_wwpdb.py:47: DeprecationWarning: the np.testing.dec decorators are included for nose support, and are deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.
    @dec.slow

sequence/sequence.py:32: 75 warnings
tests/sequence/test_msafile.py: 175 warnings
  /usr/lib/python3/dist-packages/prody/sequence/sequence.py:32: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
    self._seq = fromstring(one, '|S1')

tests/apps/test_prody_catdcd.py: 21 warnings
tests/measure/test_measure.py: 6 warnings
tests/trajectory/test_frame.py: 6 warnings
  /usr/lib/python3/dist-packages/prody/trajectory/dcdfile.py:294: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
    unitcell = fromstring(self._file.read(48), dtype=np.float64)

tests/ensemble/test_functions.py: 9 warnings
tests/ensemble/test_pdbensemble.py: 25 warnings
tests/sequence/test_msa.py: 25 warnings
tests/sequence/test_msafile.py: 100 warnings
tests/sequence/test_sequence.py: 1 warning
  /usr/lib/python3/dist-packages/prody/sequence/sequence.py:52: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
    return self._array.tostring().decode()

tests/sequence/test_analysis.py: 129 warnings
  /usr/lib/python3/dist-packages/prody/sequence/analysis.py:592: PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices or deal with linear algebra (see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). Please adjust your code to use regular ndarray.
    c = matrix.dot(matrix(zeros((length*q, 1), float)),

tests/sequence/test_analysis.py: 129 warnings
  /usr/lib/python3/dist-packages/prody/sequence/analysis.py:593: PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices or deal with linear algebra (see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). Please adjust your code to use regular ndarray.
    matrix(zeros((1, length*q), float)))

tests/sequence/test_analysis.py: 129 warnings
  /usr/lib/python3/dist-packages/numpy/matrixlib/defmatrix.py:69: PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices or deal with linear algebra (see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). Please adjust your code to use regular ndarray.
    return matrix(data, dtype=dtype, copy=False)

tests/sequence/test_sequence.py::TestSequence::testStringConversion
  /usr/lib/python3/dist-packages/prody/sequence/sequence.py:36: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
    self._seq = fromstring(args[0], '|S1')

../_pytest/cacheprovider.py:451
  /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:451: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/prody/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/prody/.pytest_cache'
    config.cache.set("cache/nodeids", sorted(self.cached_nodeids))

../_pytest/cacheprovider.py:405
  /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:405: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/prody/.pytest_cache/v/cache/lastfailed: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/prody/.pytest_cache'
    config.cache.set("cache/lastfailed", self.lastfailed)

../_pytest/stepwise.py:56
  /usr/lib/python3/dist-packages/_pytest/stepwise.py:56: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/prody/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/prody/.pytest_cache'
    session.config.cache.set(STEPWISE_CACHE_DIR, [])

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/atomic/test_select.py::TestSelect::testFunctionSelection13 - Ass...
FAILED tests/atomic/test_select.py::TestSelect::testFunctionSelection14 - Ass...
= 2 failed, 902 passed, 10 skipped, 2 deselected, 1230 warnings in 260.69s (0:04:20) =
autopkgtest [12:11:36]: test command1: -----------------------]
autopkgtest [12:11:36]: test command1:  - - - - - - - - - - results - - - - - - - - - -
command1             FAIL non-zero exit status 1
autopkgtest [12:11:36]: @@@@@@@@@@@@@@@@@@@@ summary
command1             FAIL non-zero exit status 1
-------------- next part --------------
--- a/prody/tests/atomic/test_select.py
+++ b/prody/tests/atomic/test_select.py
@@ -198,7 +198,6 @@ SELECTION_TESTS = {'pdb3mht':
         ('beta % 4 % 3 < 1', 1530),
         ('ceil(beta) == 10', 60),
         ('floor(beta) == 10', 58),
-        ('abs(x) == sqrt(sq(x))', 3211),
         ('sq(x-5)+sq(y+4)+sq(z) > sq(100)', 1444),
         ('1 > sq(occ)', None),
         ('sq(x x) > 1', None),],


More information about the Debichem-devel mailing list