Skip to content

Commit e5c1786

Browse files
committed
Allow GeneralUnit inputs.
1 parent 99a261d commit e5c1786

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/loch/_sampler.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,8 +1626,8 @@ def _validate_sire_unit(parameter: str, value: str, unit: _Any) -> _Any:
16261626
parameter: str
16271627
The name of the parameter.
16281628
1629-
value: str
1630-
The value to validate.
1629+
value: str, sire.units.GeneralUnit
1630+
The value or GeneralUnit to validate.
16311631
16321632
unit: str
16331633
The unit to validate.
@@ -1639,8 +1639,10 @@ def _validate_sire_unit(parameter: str, value: str, unit: _Any) -> _Any:
16391639
The validated unit.
16401640
"""
16411641

1642-
if not isinstance(value, str):
1643-
raise ValueError(f"'{parameter}' must be of type 'str'")
1642+
if not isinstance(value, (str, _sr.units.GeneralUnit)):
1643+
raise ValueError(
1644+
f"'{parameter}' must be of type 'str' or 'sire.units.GeneralUnit'"
1645+
)
16441646

16451647
try:
16461648
u = _sr.u(value)

0 commit comments

Comments
 (0)