erdogant / distfit

distfit is a python library for probability density fitting.
https://erdogant.github.io/distfit
Other
361 stars 25 forks source link

plot freeze #37

Open alekin2 opened 1 year ago

alekin2 commented 1 year ago

On windows 10, python 3.10, pycharm Build #PC-231.9161.41, built on June 20, 2023

After

import numpy as np from distfit import distfit X = np.random.normal(0, 2, 10000) y = [-8,-6,0,1,2,3,4,5,6]

Initialize

dfit = distfit(alpha=0.01)

Fit

dfit.fit_transform(X)

Plot seperately

fig, ax = dfit.plot(chart='pdf')

I get a blank plot freezed! I can't resize or other. If I close plot I get: Process finished with exit code -805306369 (0xCFFFFFFF)

alekin2 commented 1 year ago

Also other plot

fig, ax = dfit.plot(chart='cdf', n_top=11)

freeze

erdogant commented 1 year ago

Thank you for mentioning this. I can not reproduce the error. Have you tried to create a new environment first? Also when you install distfit, force to download the latest version. Should be 1.6.10

import distfit
distfit.__version__
conda create -n env_test python=3.10
conda activate env_test
pip install -U distfit

import numpy as np
from distfit import distfit
import matplotlib.pyplot as plt
X = np.random.normal(0, 2, 10000)
y = [-8,-6,0,1,2,3,4,5,6]
dfit = distfit(alpha=0.01)
dfit.fit_transform(X)
fig, ax = dfit.plot(chart='pdf')
fig, ax = dfit.plot(chart='cdf', n_top=11)

plt.show()
# Or
fig.show()
alekin2 commented 1 year ago

C:\Users\Massimo>pip install distfit --upgrade Defaulting to user installation because normal site-packages is not writeable Collecting distfit Downloading distfit-1.6.10-py3-none-any.whl (40 kB) ---------------------------------------- 40.4/40.4 kB ? eta 0:00:00 Requirement already satisfied: scipy in c:\programdata\anaconda3\lib\site-packages (from distfit) (1.10.0) Requirement already satisfied: pandas in c:\programdata\anaconda3\lib\site-packages (from distfit) (1.5.3) Requirement already satisfied: tqdm in c:\programdata\anaconda3\lib\site-packages (from distfit) (4.64.1) Requirement already satisfied: numpy in c:\users\massimo\appdata\roaming\python\python310\site-packages (from distfit) (1.25.0) Collecting pypickle Downloading pypickle-1.1.0-py3-none-any.whl (5.1 kB) Collecting colourmap>=1.1.10 Downloading colourmap-1.1.14-py3-none-any.whl (9.2 kB) Requirement already satisfied: packaging in c:\programdata\anaconda3\lib\site-packages (from distfit) (22.0) Requirement already satisfied: statsmodels in c:\programdata\anaconda3\lib\site-packages (from distfit) (0.13.5) Requirement already satisfied: matplotlib>=3.5.2 in c:\programdata\anaconda3\lib\site-packages (from distfit) (3.7.0) Requirement already satisfied: pyparsing>=2.3.1 in c:\programdata\anaconda3\lib\site-packages (from matplotlib>=3.5.2->distfit) (3.0.9) Requirement already satisfied: kiwisolver>=1.0.1 in c:\programdata\anaconda3\lib\site-packages (from matplotlib>=3.5.2->distfit) (1.4.4) Requirement already satisfied: cycler>=0.10 in c:\programdata\anaconda3\lib\site-packages (from matplotlib>=3.5.2->distfit) (0.11.0) Requirement already satisfied: pillow>=6.2.0 in c:\programdata\anaconda3\lib\site-packages (from matplotlib>=3.5.2->distfit) (9.4.0) Requirement already satisfied: fonttools>=4.22.0 in c:\programdata\anaconda3\lib\site-packages (from matplotlib>=3.5.2->distfit) (4.25.0) Requirement already satisfied: contourpy>=1.0.1 in c:\programdata\anaconda3\lib\site-packages (from matplotlib>=3.5.2->distfit) (1.0.5) Requirement already satisfied: python-dateutil>=2.7 in c:\programdata\anaconda3\lib\site-packages (from matplotlib>=3.5.2->distfit) (2.8.2) Requirement already satisfied: pytz>=2020.1 in c:\programdata\anaconda3\lib\site-packages (from pandas->distfit) (2022.7) Requirement already satisfied: patsy>=0.5.2 in c:\programdata\anaconda3\lib\site-packages (from statsmodels->distfit) (0.5.3) Requirement already satisfied: colorama in c:\programdata\anaconda3\lib\site-packages (from tqdm->distfit) (0.4.6) Requirement already satisfied: six in c:\programdata\anaconda3\lib\site-packages (from patsy>=0.5.2->statsmodels->distfit) (1.16.0) Installing collected packages: pypickle, colourmap, distfit Successfully installed colourmap-1.1.14 distfit-1.6.10 pypickle-1.1.0

The update doesn't fix it. ... but with environment (argh!!) works!!!

alekin2 commented 1 year ago

I removed env_test and retried the code from cmd. Works! the problem occurs if you run the script from python console of pycharm Build #PC-231.9161.41, built on June 20, 2023

erdogant commented 1 year ago

Happy to hear that your issue is solved! I am not sure whether/how I can tackle this issue in the code. Maybe the most practical manner is to create a new page in the documentation that describes that some versions of pycharm can result in an error.

alekin2 commented 1 year ago

info: When I run plt.show() in pycharm debug mode, other scripts, not related to this library, also fail, because the graph freezes. Perhaps the problem is related

erdogant commented 1 year ago

thanks for letting know

erdogant commented 4 months ago

Is this still an issue? Or did time heal something over here?