Skip to content

Commit

Permalink
Fix coo_map when only one match from regex pattern (#525)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Durant <martin.durant@alumni.utoronto.ca>
  • Loading branch information
aaTman and martindurant authored Nov 22, 2024
1 parent ccf431b commit 56ef473
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kerchunk/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,11 @@ def _get_value(self, index, z, var, fn=None):
elif isinstance(selector, list):
o = selector[index]
elif isinstance(selector, re.Pattern):
o = selector.search(fn).groups()[0]
regex_groups_o = selector.search(fn).groups()
if len(regex_groups_o) == 0:
o = selector.search(fn).group()
else:
o = regex_groups_o[0]
elif not isinstance(selector, str):
# constant, should be int or float
o = selector
Expand Down

0 comments on commit 56ef473

Please sign in to comment.