diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index d83a7c37b..1b5931113 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -63,7 +63,7 @@ jobs: - name: Install build dependencies run: | pip install setuptools - + - name: Install lib run: | python setup.py develop @@ -76,6 +76,7 @@ jobs: - name: pytest run: | pytest GPy/testing + test-macos: strategy: matrix: @@ -126,7 +127,6 @@ jobs: - name: Build lib run: | - pip install setuptools pip install wheel python setup.py develop python setup.py bdist_wheel @@ -159,7 +159,6 @@ jobs: - name: Build lib run: | - pip install setuptools pip install wheel python setup.py develop python setup.py bdist_wheel diff --git a/CHANGELOG.md b/CHANGELOG.md index 7440692e0..331157cc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog ## Unreleased +* update string checks in initialization method for latent variable and put `empirical_samples` init-method on a deprecation path + +* update dependencies to `numpy>=1.7.0,<2.0.0` * update dependencies to `numpy>=1.7.0,<2.0.0` diff --git a/GPy/util/initialization.py b/GPy/util/initialization.py index 1e19a3216..3262ae4f1 100644 --- a/GPy/util/initialization.py +++ b/GPy/util/initialization.py @@ -1,31 +1,59 @@ -''' +""" Created on 24 Feb 2014 @author: maxz -''' +""" import numpy as np +import warnings from ..util.pca import PCA + def initialize_latent(init, input_dim, Y): + """ + :param init: initialization method for the latent space, 'PCA' or 'random' + """ Xr = np.asfortranarray(np.random.normal(0, 1, (Y.shape[0], input_dim))) - if 'PCA' in init: + if "PCA" == init: p = PCA(Y) PC = p.project(Y, min(input_dim, Y.shape[1])) - Xr[:PC.shape[0], :PC.shape[1]] = PC - var = .1*p.fracs[:input_dim] - elif init in 'empirical_samples': + Xr[: PC.shape[0], : PC.shape[1]] = PC + var = 0.1 * p.fracs[:input_dim] + elif init == "empirical_samples": + # dealing with depcrecated initialization method + # should be remove along the next major release + warnings.warn( + "Deprecated initialization method 'empirical_samples'. " + "Use 'random' instead.", + DeprecationWarning, + ) + from ..util.linalg import tdot from ..util import diag + YYT = tdot(Y) diag.add(YYT, 1e-6) - EMP = np.asfortranarray(np.random.multivariate_normal(np.zeros(Y.shape[0]), YYT, min(input_dim, Y.shape[1])).T) - Xr[:EMP.shape[0], :EMP.shape[1]] = EMP + EMP = np.asfortranarray( + np.random.multivariate_normal( + np.zeros(Y.shape[0]), YYT, min(input_dim, Y.shape[1]) + ).T + ) + Xr[: EMP.shape[0], : EMP.shape[1]] = EMP var = np.random.uniform(0.5, 1.5, input_dim) + elif init == "random": + var = Xr.var(0) else: + # dealing with depcrecated initialization method + # should be remove along the next major release + warnings.warn( + f"{init} is not a valid initialization method." + "Supoprt for anything else than 'PCA' or 'random' will be removed in the next major release.", + DeprecationWarning, + ) var = Xr.var(0) + Xr -= Xr.mean(0) Xr /= Xr.std(0) - return Xr, var/var.max() + return Xr, var / var.max()