Skip to content

Commit

Permalink
Merge pull request #179 from BoothGroup/bugfix
Browse files Browse the repository at this point in the history
Escape regex characters in orbital filter
  • Loading branch information
basilib authored Oct 14, 2024
2 parents c4a7c79 + b9ab3e5 commit d3527ed
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vayesta/core/fragmentation/fragmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import numpy as np
import scipy
import scipy.linalg
import re

from vayesta.core.util import dot, fix_orbital_sign, time_string, timer
from vayesta.core.fragmentation import helper
Expand Down Expand Up @@ -420,6 +421,10 @@ def get_atomic_fragment_indices(self, atoms, orbital_filter=None, name=None):
indices = np.nonzero(np.isin(self.get_atoms(), atom_indices))[0]
# Filter orbital types
if orbital_filter is not None:
if isinstance(orbital_filter, list):
orbital_filter = [re.escape(x) for x in orbital_filter]
elif isinstance(orbital_filter, str):
orbital_filter = re.escape(orbital_filter)
keep = self.search_labels(orbital_filter)
indices = [i for i in indices if i in keep]
return name, indices
Expand Down

0 comments on commit d3527ed

Please sign in to comment.