Skip to content

Commit

Permalink
Fix missing sandpit synchronisation. [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
lohedges committed Sep 23, 2022
1 parent fc89142 commit c39cfdb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions python/BioSimSpace/Sandpit/Exscientia/Types/_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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])
Expand Down

0 comments on commit c39cfdb

Please sign in to comment.