arviz icon indicating copy to clipboard operation
arviz copied to clipboard

mpl incompatibility on ChatGPT

Open twiecki opened this issue 2 years ago • 2 comments

Trying to import arviz on ChatGPT leads to:

----> 3     import arviz as az
      4     result = "ArviZ is available."
      5 except ImportError:

File ~/.local/lib/python3.8/site-packages/arviz/__init__.py:324
    322     import colorcet
    323 except ModuleNotFoundError:
--> 324     _mpl_cm("gray", _linear_grey_10_95_c0)
    325     _mpl_cm("gray_r", list(reversed(_linear_grey_10_95_c0)))
    328 # clean namespace

File ~/.local/lib/python3.8/site-packages/arviz/__init__.py:318, in _mpl_cm(name, colorlist)
    316 def _mpl_cm(name, colorlist):
    317     cmap = LinearSegmentedColormap.from_list(name, colorlist, N=256)
--> 318     mpl.colormaps.register(cmap, name="cet_" + name)

AttributeError: module 'matplotlib' has no attribute 'colormaps'

I bet the env has an incompatible matplotlib version (installed is 3.4.3.) but I'm wondering if there's an easy way to maybe make it compatible.

twiecki avatar Feb 26 '24 14:02 twiecki

The minimum mpl version required for ArviZ is 3.5, when the colormaps module was added, not sure how that env came to be. Is is possible to update matplotlib somehow?

Another alternative would be to avoid triggering that try except, which wouldn't be triggered if colorcet were installed.

OriolAbril avatar Feb 26 '24 14:02 OriolAbril

It's just whatever openai cobbled together I guess.

twiecki avatar Feb 26 '24 16:02 twiecki