pmda icon indicating copy to clipboard operation
pmda copied to clipboard

Incompatible with Numpy 1.24.1

Open GregorySchwing opened this issue 1 year ago • 0 comments

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

GregorySchwing avatar Jan 11 '23 20:01 GregorySchwing