From 8a7af104b7843764645748e4f3fe1429a60af6a0 Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Sat, 2 Dec 2023 09:58:41 -0600 Subject: [PATCH] Move regex out of loop --- stellarphot/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stellarphot/core.py b/stellarphot/core.py index abacae13..7e842074 100644 --- a/stellarphot/core.py +++ b/stellarphot/core.py @@ -370,6 +370,8 @@ def clean(self, remove_rows_with_mask=False, **other_restrictions): } recognized_comparison_ops = '|'.join(comparisons.keys()) + criteria_re = re.compile(r'({})([-+a-zA-Z0-9]+)'.format(recognized_comparison_ops)) + keepers = np.ones([len(self)], dtype=bool) if remove_rows_with_mask and self.has_masked_values: @@ -377,7 +379,6 @@ def clean(self, remove_rows_with_mask=False, **other_restrictions): keepers &= ~self[c].mask for column, restriction in other_restrictions.items(): - criteria_re = re.compile(r'({})([-+a-zA-Z0-9]+)'.format(recognized_comparison_ops)) results = criteria_re.match(restriction) if not results: raise ValueError("Criteria {}{} not "