PEtab-dev / libpetab-python

Python package for working with PEtab files
https://libpetab-python.readthedocs.io
MIT License
14 stars 5 forks source link

Fix flatten_timepoint_specific_output_overrides #239

Closed dweindl closed 6 months ago

dweindl commented 6 months ago

... again.

Fixes an error when trying to apply re.sub to numeric values:

    petab.flatten_timepoint_specific_output_overrides(problem)
build/venv/lib/python3.9/site-packages/petab/core.py:290: in flatten_timepoint_specific_output_overrides
    observable[target] = re.sub(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

pattern = 'observableParameter([0-9]+)_obs_a'
repl = 'observableParameter\\1_obs_a__10__c0', string = 1, count = 0, flags = 0

    def sub(pattern, repl, string, count=0, flags=0):
        """Return the string obtained by replacing the leftmost
        non-overlapping occurrences of the pattern in string by the
        replacement repl.  repl can be either a string or a callable;
        if a string, backslash escapes in it are processed.  If it is
        a callable, it's passed the Match object and must return
        a replacement string to be used."""
>       return _compile(pattern, flags).sub(repl, string, count)
E       TypeError: cannot use a string pattern on a bytes-like object

/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/re.py:210: TypeError
codecov-commenter commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (eb08318) 76.30% compared to head (f1a01be) 76.33%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #239 +/- ## =========================================== + Coverage 76.30% 76.33% +0.02% =========================================== Files 34 34 Lines 3191 3194 +3 Branches 774 775 +1 =========================================== + Hits 2435 2438 +3 Misses 554 554 Partials 202 202 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.