votchallenge / toolkit

The official VOT Challenge evaluation and analysis toolkit
http://www.votchallenge.net/
GNU General Public License v3.0
164 stars 46 forks source link

[bug] matplotlib broke compatibility with get_cmap in version 3.9 #119

Closed lparolari closed 5 months ago

lparolari commented 5 months ago

I'm reporting a bug encountered during the usage of vot toolkit.

To reproduce

  1. Install vot-toolkit (pip install vot-toolkit)
  2. Run vot initialize vot2022 --workspace workspace

It raises the following error

cannot import name 'get_cmap' from 'matplotlib.cm'

I'm using python 3.10.

About the error

The get_cmap function is used here: https://github.com/votchallenge/toolkit/blob/0abc8e537ca8c94bf898abae0217529daa272e7d/vot/report/__init__.py#L305

I did some digging on the internet and I found it is a recent change introduced by matplotlib in version3.9. Here I report the 3.9 changelog that removed get_cmap function: https://matplotlib.org/stable/api/prev_api_changes/api_changes_3.9.0.html#top-level-cmap-registration-and-access-functions-in-mpl-cm

Other projects are having the same issue:

Possible solutions

use matplotlib.colormaps[name] instead if you have a str. Use matplotlib.cm.ColormapRegistry.get_cmap if you have a str, None or a matplotlib.colors.Colormap object that you want to convert to a Colormap object.

I am willing to investigate more on the problem and possibly fix the code. Guidance might help.

Thank you

lukacu commented 5 months ago

I have committed to fixing this issue in the development branch.

lparolari commented 5 months ago

Thank you