| import re | |
| from typing import Tuple, List | |
| # Matches "foo" in "foo, bar" but not "foobar". Used to search for the | |
| # occurrence of a parameter in the derivative formula | |
| IDENT_REGEX = r'(^|\W){}($|\W)' | |
| # TODO: Use a real parser here; this will get bamboozled | |
| def split_name_params(schema: str) -> Tuple[str, List[str]]: | |
| m = re.match(r'(\w+)(\.\w+)?\((.*)\)', schema) | |
| if m is None: | |
| raise RuntimeError(f'Unsupported function schema: {schema}') | |
| name, _, params = m.groups() | |
| return name, params.split(', ') |