wafo-project / pywafo

Wave Analysis for Fatigue and Oceanography
http://www.maths.lth.se/matstat/wafo/
Other
94 stars 42 forks source link

ImportError: cannot import name 'entropy' from 'wafo.stats._distn_infrastructure' #52

Closed Cubostar closed 1 year ago

Cubostar commented 2 years ago

After installing wafo on an Anaconda Python 3.7 environment with help from this thread, I tried import wafo and got the titular error. Any fix?

Cubostar commented 2 years ago

The version I've tried to install is 0.4.0. Here's the full trace, though with the path in the first call omitted:

`Traceback (most recent call last):

File "{omitted}", line 1, in import wafo

File "C:\Users\qarbolante\Anaconda3\envs\wafobuild37\lib\site-packages\wafo__init__.py", line 7, in from . import objects

File "C:\Users\qarbolante\Anaconda3\envs\wafobuild37\lib\site-packages\wafo\objects.py", line 15, in from wafo.transform.core import TrData

File "C:\Users\qarbolante\Anaconda3\envs\wafobuild37\lib\site-packages\wafo\transform__init__.py", line 7, in from . import estimation

File "C:\Users\qarbolante\Anaconda3\envs\wafobuild37\lib\site-packages\wafo\transform\estimation.py", line 8, in from wafo.stats import edf, skew, kurtosis

File "C:\Users\qarbolante\Anaconda3\envs\wafobuild37\lib\site-packages\wafo\stats__init__.py", line 6, in from .distributions import *

File "C:\Users\qarbolante\Anaconda3\envs\wafobuild37\lib\site-packages\wafo\stats\distributions.py", line 10, in from ._distn_infrastructure import entropy, rv_discrete, rv_continuous, rv_frozen`

justaPCWingo commented 2 years ago

Hi @Cubostar , I ran into this recently as well. The solution I found was to add the line from scipy.stats import entropy to the import block to the top of the wafo/stats/_distn_infrastructure.py.

It appears that pywafo was relying on the entropy objecting being imported with the glob statement from scipy.stats._distn_infrastructure import *, which no longer appears to work.

ocefpaf commented 1 year ago

This was probably fixed in #54.

davidovitch commented 1 year ago

Indeed, it should have. Please report back if it hasn't.