AnBowell / whittaker-eilers

A sparse matrix implementation of Whittaker-Eilers smoothing and interpolation
https://crates.io/crates/whittaker-eilers
30 stars 2 forks source link

python: ImportError: cannot import name 'Whittaker' from 'whittaker_eilers' #2

Closed pranavlal closed 10 months ago

pranavlal commented 10 months ago

Hi,

I am trying to use this package. The error I am getting is as follows. Traceback (most recent call last):
File "/home/pranav/epat/stockbot/regression_strategy_test.py", line 9, in
from whittaker_eilers import Whittaker
ImportError: cannot import name 'Whittaker' from 'whittaker_eilers' (/home/pranav/.virtualenvs/regressiontest/lib/python3.11/site-packages/whittaker_eilers/init.py)

My code is below.


from whittaker_eilers import Whittaker
whittaker_smoother = WhittakerSmoother(lmbda=20,order=2,data_length=len(df["close"]))
    smoothed_prices = whittaker_smoother.smooth(df["close"])

```What am I doing wrong?
AnBowell commented 10 months ago

Hey there,

You'll need to import WhittakerSmoother instead of Whittaker and it should work for you. I'd definitely recommend getting some form of autocomplete set up in your IDE!

pranavlal commented 10 months ago

Hi Andrew,

Many thanks. I did have to write from whittaker_eilers import WhittakerSmoother I am using visual studio code which does indeed have auto complete but I cannot tell why it did not trigger in this case. Thanks again for your answer.

AnBowell commented 10 months ago

Hmm, good to know. Someone else did mention this being an issue but in Jupyter Notebook. I have since released a new version which I thought fixed this, so let me know if you continue to have issues with it!