GAA-UAM / scikit-fda

Functional Data Analysis Python package
https://fda.readthedocs.io
BSD 3-Clause "New" or "Revised" License
290 stars 51 forks source link

Error on importing FPCA #448

Closed SkyJoyTianle closed 2 years ago

SkyJoyTianle commented 2 years ago

Describe the bug ImportError Traceback (most recent call last) /var/folders/b7/znhy5tqn62g96g4j4cdtxvs00000gn/T/ipykernel_5617/2223815277.py in 4 from skfda.datasets import fetch_growth 5 from skfda.exploratory.visualization import FPCAPlot ----> 6 from skfda.preprocessing.dim_reduction import FPCA 7 from skfda.representation.basis import BSpline, Fourier, Monomial

ImportError: cannot import name 'FPCA' from 'skfda.preprocessing.dim_reduction' (/opt/anaconda3/lib/python3.9/site-packages/skfda/preprocessing/dim_reduction/init.py).

To Reproduce Code to reproduce the behavior:

import skfda
from skfda.preprocessing.dim_reduction import FPCA
...

Expected behavior A clear and concise description of what you expected to happen, results or figures.

Version information

Additional context I am trying the example of FPCA in the document, but I can't import the FPCA on my MacOS or the Google Colab, could you tell me why and how to solve it?

SkyJoyTianle commented 2 years ago

I just change the import code as from skfda.preprocessing.dim_reduction.feature_extraction import FPCA. It is because that the FPCA class is in the package feature_extraction not the dim_reduction directly

vnmabus commented 2 years ago

Yes. You are looking at the latest version of the documentation, which correspond to the development branch. You can instead read the documentation for the stable version, that correspond to the master branch.

We have changed the location of FPCA in the development branch. In the master branch (the one released) you can import it as:

from skfda.preprocessing.dim_reduction.feature_extraction import FPCA

This will still work for the next couple of releases (but with a warning). The new way to import it, starting from the next release, is:

from skfda.preprocessing.dim_reduction import FPCA

Sorry for the confusion. As we are adding more features to the library sometimes we have to rethink the ways things were previously done, and with two versions of the docs it can be a little bit confusing.

SkyJoyTianle commented 2 years ago

Thanks for your quick reply. I am okay with this problem.