From 064a6b7b477935c494ca047a1dbf6ecfc426984d Mon Sep 17 00:00:00 2001 From: Noam Bernstein Date: Thu, 24 Oct 2024 11:44:55 -0400 Subject: [PATCH] Fix detection of scalar temperature to work with any scalar, since e.g. np.float64 failed with previous isinstance(float) check --- wfl/generate/md/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wfl/generate/md/__init__.py b/wfl/generate/md/__init__.py index ff8d03e5..fafedb90 100644 --- a/wfl/generate/md/__init__.py +++ b/wfl/generate/md/__init__.py @@ -125,9 +125,14 @@ def _get_temperature(atoms): raise RuntimeError(f'NVE (temperature_tau is None) can only accept temperature=float for initial T, got {type(temperature_use)}') if temperature_use is not None: - if isinstance(temperature_use, (float, int)): - # float into a list - temperature_use = [temperature_use] + # assume that dicts are already in temperature profile format + if not isinstance(temperature_use, dict): + try: + # check if it's a list, tuple, etc + len(temperature_use) + except: + # number into a list + temperature_use = [temperature_use] if not isinstance(temperature_use[0], dict): # create a stage dict from a constant or ramp t_stage_data = temperature_use