ydata-profiling icon indicating copy to clipboard operation
ydata-profiling copied to clipboard

test: matplotlib backend side-effects

Open jodom961 opened this issue 3 years ago • 2 comments

As described in the issues https://github.com/ydataai/pandas-profiling/issues/888 and https://github.com/ydataai/pandas-profiling/issues/837 , upon the release of 3.1.0, a side effect of importing pandas_profiling was that it overrode the existing backend of matplotlib on import, and prevented plots from being rendered in Jupyter environments.

Since it seems the backend does not needed to be set per matplots documentation,

By default, Matplotlib should automatically select a default backend which allows both interactive work and plotting from scripts, with output to the screen and/or to a file, so at least initially you will not need to worry about the backend.

Using matplot.libuse() will require changes in your code if users want to use a different backend. Therefore, you should avoid explicitly calling use unless absolutely necessary.

and it is generally a best practice to not have side effects upon importing a package, I have elected to remove that line.

A new test is in place in notebooks/notebook_plotting.ipynb to prevent this in the future.

jodom961 avatar May 09 '22 17:05 jodom961

@sbrugman clean start for tests. let me know if it needs anything else to be approved.

jodom961 avatar May 09 '22 17:05 jodom961

Thanks @jodom961. The comments above provide some pointers to improve the PR.

sbrugman avatar May 09 '22 19:05 sbrugman