diff --git a/VERSION b/VERSION deleted file mode 100644 index aec258df7..000000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.8 diff --git a/docs/conf.py b/docs/conf.py index f10f375aa..73221b2d6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -56,7 +56,6 @@ 'sphinx.ext.viewcode', 'sphinx.ext.napoleon', 'sphinx.ext.mathjax', - 'sphinx_rtd_theme', 'sphinx_gallery.gen_gallery', 'sphinx.ext.intersphinx', 'sphinx.ext.doctest', diff --git a/pyproject.toml b/pyproject.toml index 0515a4a03..19dcf600c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,6 @@ classifiers = [ dynamic = ["version"] dependencies = [ - "cython", "dcor", "fdasrsf>=2.2.0", "findiff", @@ -58,5 +57,11 @@ documentation = "https://fda.readthedocs.io" repository = "https://github.com/GAA-UAM/scikit-fda" [build-system] -# Minimum requirements for the build system to execute. -requires = ["setuptools", "wheel"] \ No newline at end of file +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.packages.find] +include = ["skfda*"] + +[tool.setuptools.dynamic] +version = {attr = "skfda.__version__"} diff --git a/readthedocs.yml b/readthedocs.yml index 6e905e528..2c148156d 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -18,7 +18,7 @@ sphinx: # Optionally set the version of Python and requirements required to build your docs python: - version: 3.8 + version: "3.8" install: - requirements: readthedocs-requirements.txt - method: pip diff --git a/requirements.txt b/requirements.txt index 0a9ce64ed..2a806336a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,6 @@ matplotlib numpy scipy setuptools -Cython scikit-learn multimethod>=1.2 findiff diff --git a/setup.py b/setup.py deleted file mode 100644 index 63d4dd7c2..000000000 --- a/setup.py +++ /dev/null @@ -1,38 +0,0 @@ -# encoding: utf-8 - -""" -Functional Data Analysis Python package. - -Functional Data Analysis, or FDA, is the field of Statistics that analyses -data that depend on a continuous parameter. - -This package offers classes, methods and functions to give support to FDA -in Python. Includes a wide range of utils to work with functional data, and its -representation, exploratory analysis, or preprocessing, among other tasks -such as inference, classification, regression or clustering of functional data. -See documentation or visit the -`github page `_ of the project for -further information on the features included in the package. - -The documentation is available at -`fda.readthedocs.io/en/stable/ `_, which -includes detailed information of the different modules, classes and methods of -the package, along with several examples showing different funcionalities. -""" - -import os - -from setuptools import find_packages, setup - -with open( - os.path.join(os.path.dirname(__file__), "VERSION"), - "r", -) as version_file: - version = version_file.read().strip() - -setup( - name="scikit-fda", - version=version, - include_package_data=True, - packages=find_packages(), -) diff --git a/skfda/__init__.py b/skfda/__init__.py index 99d72a19b..1a8f41021 100644 --- a/skfda/__init__.py +++ b/skfda/__init__.py @@ -30,18 +30,4 @@ concatenate as concatenate, ) -try: - with open( - _os.path.join( - _os.path.dirname(__file__), - '..', - 'VERSION', - ), - 'r', - ) as version_file: - __version__ = version_file.read().strip() -except IOError as e: - if e.errno != _errno.ENOENT: - raise - - __version__ = "0.0" +__version__ = "0.8.1" diff --git a/skfda/misc/metrics/_mahalanobis.py b/skfda/misc/metrics/_mahalanobis.py index cb04149d0..1bf854a20 100644 --- a/skfda/misc/metrics/_mahalanobis.py +++ b/skfda/misc/metrics/_mahalanobis.py @@ -104,11 +104,11 @@ def fit( if self.eigenvalues is None or self.eigenvectors is None: fpca = FPCA( - self.n_components, - self.centering, - self.regularization, - self.weights, - self.components_basis, + n_components=self.n_components, + centering=self.centering, + regularization=self.regularization, + components_basis=self.components_basis, + _weights=self.weights, ) fpca.fit(X) self.eigenvalues_ = fpca.explained_variance_ diff --git a/skfda/preprocessing/dim_reduction/_fpca.py b/skfda/preprocessing/dim_reduction/_fpca.py index 89e468bc3..d82debbaa 100644 --- a/skfda/preprocessing/dim_reduction/_fpca.py +++ b/skfda/preprocessing/dim_reduction/_fpca.py @@ -87,6 +87,7 @@ class FPCA( # noqa: WPS230 (too many public attributes) def __init__( self, n_components: int = 3, + *, centering: bool = True, regularization: Optional[L2Regularization[FData]] = None, components_basis: Optional[Basis] = None, @@ -354,27 +355,25 @@ def _fit_grid( regularization=self.regularization, ) - basis_matrix = basis.data_matrix[..., 0] - if regularization_matrix is not None: - basis_matrix += regularization_matrix + # See issue #497 for more information about this approach + factorization_matrix = weights_matrix.astype(float) + if self.regularization is not None: + factorization_matrix += regularization_matrix - fd_data = np.linalg.solve( - basis_matrix.T, - fd_data.T, - ).T + # Tranpose of the Cholesky decomposition + Lt = np.linalg.cholesky(factorization_matrix).T - # see docstring for more information - final_matrix = fd_data @ np.sqrt(weights_matrix) + new_data_matrix = fd_data @ weights_matrix + new_data_matrix = np.linalg.solve(Lt.T, new_data_matrix.T).T pca = PCA(n_components=self.n_components) - pca.fit(final_matrix) + pca.fit(new_data_matrix) + + components = pca.components_ + components = np.linalg.solve(Lt, pca.components_.T).T + self.components_ = X.copy( - data_matrix=np.transpose( - np.linalg.solve( - np.sqrt(weights_matrix), - np.transpose(pca.components_), - ), - ), + data_matrix=components, sample_names=(None,) * self.n_components, )