You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In numpy 2.0+, the new dtype for strings in numpy are StringDType(). However, I don't believe MDAnalysis support this at all?
Consider the following code:
import MDAnalysis as mda
from MDAnalysis.tests.datafiles import PSF, DCD
import numpy as np
u = mda.Universe(PSF, DCD)
is_not_string = u.residues.resnames
Running print(is_not_string.dtype) yields object. Since the dtype is objects, it means that any of the new numpy 2.0+ numpy.strings functions would not work and it would require the user to manually cast the ndarray over from the object dtype into numpy.dtypes.StringDType in order to get it working. Wouldn't it be easier just to have the instance just automatically create create the ndarray as StringDType for convenience?
so we cannot use features only available in numpy 2.0+.
I am not sure when we will stop supporting numpy 1.x possibly in 2 years (~end of 2026), according to SPEC 0... but when that happens, we can use new types.
In numpy 2.0+, the new dtype for strings in numpy are StringDType(). However, I don't believe MDAnalysis support this at all?
Consider the following code:
Running
print(is_not_string.dtype)
yieldsobject
. Since the dtype is objects, it means that any of the new numpy 2.0+numpy.strings
functions would not work and it would require the user to manually cast the ndarray over from the object dtype intonumpy.dtypes.StringDType
in order to get it working. Wouldn't it be easier just to have the instance just automatically create create the ndarray as StringDType for convenience?Relevant numpy documentation:
https://numpy.org/doc/stable/user/basics.strings.html
https://numpy.org/doc/stable/reference/routines.strings.html#module-numpy.strings
The text was updated successfully, but these errors were encountered: