From a89d2cee5e789ad7c85f593f1a8b9d73ba1e50e6 Mon Sep 17 00:00:00 2001 From: James Graham <j.graham@soton.ac.uk> Date: Thu, 18 Mar 2021 19:21:28 +0000 Subject: [PATCH] fix: cast unitcell to float32 to avoid numpy warn --- pycgtool/frame.py | 6 +++++- test/test_bondset.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pycgtool/frame.py b/pycgtool/frame.py index e7ede1c..8aa7275 100644 --- a/pycgtool/frame.py +++ b/pycgtool/frame.py @@ -119,6 +119,10 @@ class Frame: self.time = traj.time + # Cast unitcell vectors to float32 to avoid warning - they're currently float64 + if traj.unitcell_vectors is not None: + traj.unitcell_vectors = traj.unitcell_vectors.astype(np.float32) + @property def residues(self): """Residues in the frame topology.""" @@ -204,7 +208,7 @@ class Frame: def build_trajectory(self) -> None: """Build an MDTraj trajectory from atom coordinates and the values stored as attributes on this frame.""" - xyz = np.array([atom.coords for atom in self._topology.atoms]) + xyz = np.array([atom.coords for atom in self._topology.atoms], dtype=np.float32) # We currently have axes: 0 - each atom, 1 - timestep, 2 - xyz coords # Need to convert to axes: 0 - timestep, 1 - each atom, 2 - xyz coords diff --git a/test/test_bondset.py b/test/test_bondset.py index aa34785..d990b52 100644 --- a/test/test_bondset.py +++ b/test/test_bondset.py @@ -1,9 +1,9 @@ -import unittest import math import os import pathlib import tempfile +import unittest from pycgtool.bondset import BondSet from pycgtool.frame import Frame -- GitLab