From 97b7eda21a4674444a203f6fcd9f890c1597db25 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Fri, 6 Dec 2019 22:28:11 -0800 Subject: [PATCH] Force repetition counts to be integers --- masque/repetition.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/masque/repetition.py b/masque/repetition.py index 6349662..2a9fa27 100644 --- a/masque/repetition.py +++ b/masque/repetition.py @@ -31,8 +31,8 @@ class GridRepetition: '_mirrored', '_a_vector', '_b_vector', - 'a_count', - 'b_count', + '_a_count', + '_b_count', 'identifier') pattern: 'Pattern' @@ -45,8 +45,8 @@ class GridRepetition: _a_vector: numpy.ndarray _b_vector: numpy.ndarray or None - a_count: int - b_count: int + _a_count: int + _b_count: int identifier: Tuple @@ -209,6 +209,27 @@ class GridRepetition: raise PatternError('b_vector must be convertible to size-2 ndarray') self._b_vector = val.flatten() + # a_count property + @property + def a_count(self) -> int: + return self._a_count + + @a_count.setter + def a_count(self, val: int): + if val != int(val): + raise PatternError('a_count must be convertable to an int!') + self._a_count = int(val) + + # b_count property + @property + def b_count(self) -> int: + return self._b_count + + @b_count.setter + def b_count(self, val: int): + if val != int(val): + raise PatternError('b_count must be convertable to an int!') + self._b_count = int(val) def as_pattern(self) -> 'Pattern': """