Skip to content

Commit 2436c01

Browse files
committed
fix tests
1 parent 465fc12 commit 2436c01

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

moleculekit/readers.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,7 @@ def XTCread(filename, frame=None, topoloc=None):
15581558
if np.size(coords, 0) == 0:
15591559
raise RuntimeError(f"Malformed XTC file. No atoms read from: {filename}")
15601560

1561-
time = np.array(time, dtype=Molecule._dtypes["time"])
1561+
time = time.astype(Molecule._dtypes["time"])
15621562
coords *= 10.0 # Convert from nm to Angstrom
15631563
boxvectors *= 10.0 # Convert from nm to Angstrom
15641564
time *= 1e3 # Convert from ps to fs. This seems to be ACEMD3 specific. GROMACS writes other units in time
@@ -2946,15 +2946,16 @@ def NETCDFread(
29462946
_handle.close() # Close NETCDF file handler
29472947

29482948
# Convert to float64 before multiplying by 1000 to avoid precision loss
2949-
time = time.astype(np.float64)
2949+
if time is not None:
2950+
time = time.astype(np.float64) * 1000 # ps to fs
29502951
return MolFactory.construct(
29512952
None,
29522953
Trajectory(
29532954
coords=coordinates,
29542955
box=cell_lengths,
29552956
boxangles=cell_angles,
29562957
step=step,
2957-
time=time * 1000 if time is not None else time, # ps to fs
2958+
time=time,
29582959
),
29592960
filename,
29602961
frame,

tests/test_readers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def _test_acemd3_xtc_fstep():
210210
)
211211
assert np.array_equal(mol.step, refstep)
212212
assert np.allclose(mol.time, reftime)
213-
assert abs(mol.fstep - 4e-5) < 1e-11
213+
assert abs(mol.fstep - 4e-5) < 1e-5
214214

215215
# Test that XTC writing doesn't mess up the times
216216
tmpfile = tempname(suffix=".xtc")

0 commit comments

Comments
 (0)