From c39cfdbabb647fcbec8bc43e1886133b9c070476 Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Fri, 23 Sep 2022 14:07:30 +0100 Subject: [PATCH] Fix missing sandpit synchronisation. [ci skip] --- python/BioSimSpace/Sandpit/Exscientia/Types/_type.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/python/BioSimSpace/Sandpit/Exscientia/Types/_type.py b/python/BioSimSpace/Sandpit/Exscientia/Types/_type.py index 251bd0683..15b80922d 100644 --- a/python/BioSimSpace/Sandpit/Exscientia/Types/_type.py +++ b/python/BioSimSpace/Sandpit/Exscientia/Types/_type.py @@ -62,6 +62,9 @@ def __init__(self, *args): value = args[0] unit = args[1] + if hasattr(value, "to_default"): + value = value.to_default() + # Check that the value is valid. if type(value) is int: self._value = float(value) @@ -579,10 +582,15 @@ def _from_sire_unit(cls, sire_unit): sire_unit.TIME() ) + # Make sure that this isn't zero. + if hasattr(sire_unit, "is_zero"): + if sire_unit.is_zero(): + dimensions = cls._dimensions + # Make sure the dimensions match. if dimensions != cls._dimensions: - raise ValueError("The dimensions of the passed 'sire_unit' are incompatible with " - f"'{cls.__name__}'") + raise ValueError(f"The dimensions of the passed 'sire_unit' {sire_unit} are incompatible with " + f"'{cls.__name__}'") # Get the value in the default Sire unit for this type. value = sire_unit.to(cls._supported_units[cls._default_unit])