Skip to content

Incompatible with Numpy 1.24.1  #159

@GregorySchwing

Description

@GregorySchwing

Expected behaviour

plt.plot(hbonds.timesteps, hbonds.count_by_time(), lw=2)
Plot my function

Actual behaviour

plt.plot(hbonds.timesteps, hbonds.count_by_time(), lw=2)


AttributeError Traceback (most recent call last)
Input In [14], in <cell line: 1>()
----> 1 plt.plot(hbonds.timesteps, hbonds.count_by_time(), lw=2)

File ~/anaconda3/envs/hbond3/lib/python3.8/site-packages/pmda-0.3.0+22.ge6ac508-py3.8.egg/pmda/hbond_analysis.py:494, in HydrogenBondAnalysis.count_by_time(self)
491 indices /= self.step
493 counts = np.zeros_like(self.frames)
--> 494 counts[indices.astype(np.int)] = tmp_counts
495 return counts

File ~/anaconda3/envs/hbond3/lib/python3.8/site-packages/numpy/init.py:284, in getattr(attr)
281 from .testing import Tester
282 return Tester
--> 284 raise AttributeError("module {!r} has no attribute "
285 "{!r}".format(name, attr))

AttributeError: module 'numpy' has no attribute 'int'

This link explains how the numpy aliases. such as np.int() are no longer supported and should be replaced without the "np." prefix.
https://levelup.gitconnected.com/fix-attributeerror-module-numpy-has-no-attribute-float-d7d68c5a4971

Therefore, a simple find and replace for np.int(x) -> int(x); and for the other aliases should fix this

Code to reproduce the behaviour

See attached
pmda_test.py.txt

Currently version of MDAnalysis:

Git : 0.3.0+22.ge6ac508
Numpy: 1.24.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions