EFS-OpenSource / calibration-framework

The net:cal calibration framework is a Python 3 library for measuring and mitigating miscalibration of uncertainty estimates, e.g., by a neural network.
https://efs-opensource.github.io/calibration-framework/
Apache License 2.0
344 stars 42 forks source link

ReliabilityDiagram fails to import because of tikzplotlib #53

Closed Praisethefab closed 3 months ago

Praisethefab commented 8 months ago

When trying to plot a ReliabilityDiagram I got this traceback:

File "REDACTED", line 31, in from netcal.presentation import ReliabilityDiagram File "REDACTED.venv\Lib\site-packages\netcal\presentation__init.py", line 25, in from .ReliabilityDiagram import ReliabilityDiagram File "REDACTED.venv\Lib\site-packages\netcal\presentation\ReliabilityDiagram.py", line 14, in
import tikzplotlib File "REDACTED.venv\Lib\site-packages\tikzplotlib\
init__.py", line 5, in from ._save import Flavors, get_tikz_code, save from . import _axes File "REDACTED.venv\Lib\site-packages\tikzplotlib_axes.py", line 3, in from matplotlib.backends.backend_pgf import ( ImportError: cannot import name 'common_texification' from 'matplotlib.backends.backend_pgf' (REDACTED.venv\Lib\site-packages\matplotlib\backends\backend_pgf.py)

This seems to me to be caused by this issue in the tikzplotlib library and a quick fix would be to downgrade matplotlib to before 3.8.

tfriedel commented 3 months ago

workaround: Don't use tikz and monkey patch it.

import sys
import types

# Create a dummy module
dummy_module = types.ModuleType('tikzplotlib')

# Insert the dummy module into sys.modules
sys.modules['tikzplotlib'] = dummy_module
fabiankueppers commented 3 months ago

Hi everyone, which python version is affected of this issue? Would be very helpful to get more details about the environments you used. Thanks