matrix-profile-foundation / matrixprofile

A Python 3 library making time series data mining tasks, utilizing matrix profile algorithms, accessible to everyone.
https://matrixprofile.org
Apache License 2.0
360 stars 62 forks source link

`matrixprofile.analyze()` raises AttributeError with `matplotlib==3.5.0` #85

Open sbetko opened 2 years ago

sbetko commented 2 years ago

Running matrixprofile.analyze() causes AttributeError: 'NoneType' object has no attribute 'get_subplotspec' when matplotlib version 3.5.0 is installed. All plots seem to be shown correctly, but due to the exception, the function never returns. Upgrading to matplotlib 3.5.1 resolves the issue.

The matrixprofile package lists matplotlib>=3.0.3 in requirements.txt. I haven't tested any other versions for this issue, but it might be worth adding matplotlib!=3.5.0 to the package requirements if this is a matplotlib bug and can't be fixed in matrixprofile itself.

To Reproduce Environment setup:

python3.9 -m venv env
source env/bin/activate
pip install --upgrade pip
pip install matrixprofile ipykernel matplotlib==3.5.0

Run the following in an IPython notebook:

import numpy as np
import matrixprofile as mp

np.random.seed(1)
vals = np.random.randn(500)
profile, figures = mp.analyze(vals)

It should throw an AttributeError. Then, restart the kernel, upgrade matplotlib with pip install matplotlib==3.5.1, and rerun the cell (it should run successfully).

Expected behavior matrixprofile.analyze() returns without any errors on both matplotlib 3.5.0 and 3.5.1.

Desktop