diff --git a/masque/ref.py b/masque/ref.py index f3241e4..a40776a 100644 --- a/masque/ref.py +++ b/masque/ref.py @@ -44,7 +44,7 @@ class Ref( __slots__ = ( '_mirrored', # inherited - '_offset', '_rotation', 'scale', '_repetition', '_annotations', + '_offset', '_rotation', '_scale', '_repetition', '_annotations', ) _mirrored: bool diff --git a/masque/test/test_ref.py b/masque/test/test_ref.py index e2d266b..c1dbf26 100644 --- a/masque/test/test_ref.py +++ b/masque/test/test_ref.py @@ -1,7 +1,9 @@ from typing import cast, TYPE_CHECKING +import pytest from numpy.testing import assert_equal, assert_allclose from numpy import pi +from ..error import MasqueError from ..pattern import Pattern from ..ref import Ref from ..repetition import Grid @@ -70,3 +72,18 @@ def test_ref_copy() -> None: ref2.offset[0] = 100 assert ref1.offset[0] == 1 + + +def test_ref_rejects_nonpositive_scale() -> None: + with pytest.raises(MasqueError, match='Scale must be positive'): + Ref(scale=0) + + with pytest.raises(MasqueError, match='Scale must be positive'): + Ref(scale=-1) + + +def test_ref_scale_by_rejects_nonpositive_scale() -> None: + ref = Ref(scale=2.0) + + with pytest.raises(MasqueError, match='Scale must be positive'): + ref.scale_by(-1)