Arviz: Update PyMC3 version string parsing

Created on 27 May 2021  路  2Comments  路  Source: arviz-devs/arviz

We're seeing an issue with version strings of the form "4.0.0.dev0" in _monkey_patch_pymc3.:

/usr/share/miniconda/envs/pymc3-dev-py37/lib/python3.7/site-packages/arviz/data/io_pymc3.py:46: in _monkey_patch_pymc3
    if tuple([int(x) for x in pm.__version__.split(".")]) < (3, 9):  # type: ignore
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

.0 = <list_iterator object at 0x7f4f23a2a990>

>   if tuple([int(x) for x in pm.__version__.split(".")]) < (3, 9):  # type: ignore
E   ValueError: invalid literal for int() with base 10: 'dev0'

Most helpful comment

from packaging import version
packaging.version.parse(pm.__version__) < packaging.version.parse("3.9")

All 2 comments

from packaging import version
packaging.version.parse(pm.__version__) < packaging.version.parse("3.9")

We should probably finish and merge #1660 instead of working on io_pymc3.py. pymc3 4.x already has the converter in the pymc codebase which does not need monkeypatching anymore and should not have this issue to begin with. The converter we still have at ArviZ should only be kept here for backwards compatibility and be imported at runtime only if pymc3 < 4.0 is installed.

Was this page helpful?
0 / 5 - 0 ratings