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
The previous ArrayReader AtomGroup used to return the positions as float32 when generated from a float64 numpy array.
The new MemoryReader-based AtomGroup returns positions in the same format as the input numpy array, in my case float64.
This breaks the usage of MemoryReader trajectories with MDAnalysis.analysis.distances.distance_array, which enforces a strict float32 format for both the reference and configuration arrays.
Is this enforcement needed or should it be allowed to work with float64 as well? Alternatively, should the AtomGroup.positions method always return float32?
Code to reproduce the behaviour
importMDAnalysisasmdaref=mda.Universe(topology, coords_array, format=MemoryReader)
conf=mda.Universe(topology, coords_array, format=MemoryReader)
ref_coords=ref.select_atoms("name H").positionsconf_coords=conf.select_atoms("protein").positionsdistance_array=mda.analysis.distances.distance_array(ref_coords, conf_coords)
File"/Users/joaommartins/.virtualenvs/MDAnalyis_0.16dev/src/mdanalysis/package/MDAnalysis/lib/distances.py", line179, in_check_arrayraiseTypeError("{0} must be of type float32".format(desc))
TypeError: refmustbeoftypefloat32
....
Currently version of MDAnalysis:
0.16.0-dev0
The text was updated successfully, but these errors were encountered:
So short term, MemoryReader should always return float32 positions to be in line with all other Readers. This should be a fairly simple fix.
Medium term, distance_array should probably learn to check arguments and convert them to float32 (possible with a warning of loss of precision).
Longer term, the forced float32 precision in distance_array and friends is annoying, (especially since they return float64). Really we should seamlessly support both (like how working with numpy feels).
Expected behaviour
The previous ArrayReader AtomGroup used to return the positions as float32 when generated from a float64 numpy array.
The new MemoryReader-based AtomGroup returns positions in the same format as the input numpy array, in my case float64.
This breaks the usage of MemoryReader trajectories with MDAnalysis.analysis.distances.distance_array, which enforces a strict float32 format for both the reference and configuration arrays.
Is this enforcement needed or should it be allowed to work with float64 as well? Alternatively, should the AtomGroup.positions method always return float32?
Code to reproduce the behaviour
Currently version of MDAnalysis:
0.16.0-dev0
The text was updated successfully, but these errors were encountered: