choderalab / openmmtools

A batteries-included toolkit for the GPU-accelerated OpenMM molecular simulation engine.
http://openmmtools.readthedocs.io
MIT License
250 stars 80 forks source link

Latest Numpy Release Deprecations (e.g. numpy.float) Break Code #646

Closed sametz closed 1 year ago

sametz commented 1 year ago

I tried to run the first OpenMM tutorial for alchemical free energy calculations. I received the following error:

Traceback (most recent call last):
  File "/Users/geoffreysametz/Documents/programming/OpenMM/tutorials/alchemical-example.py", line 10, in <module>
    fluid = LennardJonesFluid(sigma=sigma, epsilon=epsilon)
  File "/Users/geoffreysametz/opt/anaconda3/envs/gmsmdml/lib/python3.9/site-packages/openmmtools/testsystems.py", line 1942, in __init__
    TestSystem.__init__(self, **kwargs)
  File "/Users/geoffreysametz/opt/anaconda3/envs/gmsmdml/lib/python3.9/site-packages/openmmtools/testsystems.py", line 496, in __init__
    self._positions = unit.Quantity(np.zeros([0, 3], np.float), unit.nanometers)
  File "/Users/geoffreysametz/opt/anaconda3/envs/gmsmdml/lib/python3.9/site-packages/numpy/__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'float'

Apparently the December release of Numpy 1.24 enforces the deprecations of types such as numpy.float:

The deprecation for the aliases np.object, np.bool, np.float, np.complex, np.str, and np.int is expired (introduces NumPy 1.20). Some of these will now give a FutureWarning in addition to raising an error since they will be mapped to the NumPy scalars in the future.

This page of the Numpy docs has a table of the deprecated numpy types and their replacements.

sametz commented 1 year ago

Apologies: I see this was fixed. Despite using a new conda install, and creating a new environment, an older version of openmmtools was installed as the default.