Skip to content

Commit

Permalink
Move regex out of loop
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcraig committed Dec 2, 2023
1 parent a980031 commit 8a7af10
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion stellarphot/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,15 @@ 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:
for c in self.columns:
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 "
Expand Down

0 comments on commit 8a7af10

Please sign in to comment.