From b8b848c28f15ccdc06a74d8218f2a2f171ef56e1 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Wed, 15 May 2019 00:11:44 -0700 Subject: [PATCH] add Pattern.is_empty() --- masque/pattern.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/masque/pattern.py b/masque/pattern.py index eea1af8..a63bb6d 100644 --- a/masque/pattern.py +++ b/masque/pattern.py @@ -482,6 +482,14 @@ class Pattern: """ return copy.deepcopy(self) + def is_empty(self) -> bool: + """ + Returns true if the Pattern contains no shapes, labels, or subpatterns. + + :return: True if the pattern is empty. + """ + return (len(self.subpatterns) == 0 and len(self.shapes) == 0 and len(self.labels) == 0) + @staticmethod def load(filename: str) -> 'Pattern': """