ciemss / pyciemss

Causal and probabilistic reasoning with continuous time dynamical systems
Other
17 stars 6 forks source link

556 pattern matching on var finds multiple options #557

Closed djinnome closed 6 months ago

djinnome commented 6 months ago

Addressed this comment:

    # TODO: This "underscore-trailing-name matching" seems very fragile....
    #       It is done this way since you can intervene on params & states
    #       and that will match either.

With a regular expression

pattern = re.compile(f"(?:^|_){var}_(state|param)")

that captures the subtleties, and provided more rigorous test code that asserts KeyError is raised when no columns are found and ValueError is raised when multiple columns are found.

nkkchem commented 6 months ago

Yay,worked!