From 3c3ec60dea0941d898c34f86c767e8ced6a000ca Mon Sep 17 00:00:00 2001 From: Martin Bubel <37817171+MartinBubel@users.noreply.github.com> Date: Fri, 21 Apr 2023 18:32:33 +0200 Subject: [PATCH] Fix issues encountered in modern python versions (#1011) * Update setup.py remove special handling of scipy dependencies for old python versions * Update __init__.py replace numpy type by native type * replace np.bool by bool --- GPy/core/__init__.py | 2 +- GPy/inference/mcmc/samplers.py | 2 +- GPy/plotting/matplot_dep/base_plots.py | 4 ++-- GPy/plotting/matplot_dep/plot_definitions.py | 4 ++-- setup.py | 6 +----- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/GPy/core/__init__.py b/GPy/core/__init__.py index 08659add..5219de24 100644 --- a/GPy/core/__init__.py +++ b/GPy/core/__init__.py @@ -77,7 +77,7 @@ def randomize(self, rand_gen=None, *args, **kwargs): # now draw from prior where possible x = self.param_array.copy() [np.put(x, ind, p.rvs(ind.size)) for p, ind in self.priors.items() if not p is None] - unfixlist = np.ones((self.size,),dtype=np.bool) + unfixlist = np.ones((self.size,),dtype=bool) from paramz.transformations import __fixed__ unfixlist[self.constraints[__fixed__]] = False self.param_array.flat[unfixlist] = x.view(np.ndarray).ravel()[unfixlist] diff --git a/GPy/inference/mcmc/samplers.py b/GPy/inference/mcmc/samplers.py index d2f11a49..684afe37 100644 --- a/GPy/inference/mcmc/samplers.py +++ b/GPy/inference/mcmc/samplers.py @@ -38,7 +38,7 @@ class Metropolis_Hastings(object): def sample(self, Ntotal=10000, Nburn=1000, Nthin=10, tune=True, tune_throughout=False, tune_interval=400): current = self.model.optimizer_array fcurrent = self.model.log_likelihood() + self.model.log_prior() - accepted = np.zeros(Ntotal,dtype=np.bool) + accepted = np.zeros(Ntotal,dtype=bool) for it in range(Ntotal): print("sample %d of %d\r"%(it+1,Ntotal),end="") sys.stdout.flush() diff --git a/GPy/plotting/matplot_dep/base_plots.py b/GPy/plotting/matplot_dep/base_plots.py index 567f869b..e43f8efa 100644 --- a/GPy/plotting/matplot_dep/base_plots.py +++ b/GPy/plotting/matplot_dep/base_plots.py @@ -82,9 +82,9 @@ def gradient_fill(x, percentiles, ax=None, fignum=None, **kwargs): y2 = np.ones_like(x) * y2 if where is None: - where = np.ones(len(x), np.bool) + where = np.ones(len(x), bool) else: - where = np.asarray(where, np.bool) + where = np.asarray(where, bool) if not (x.shape == y1.shape == y2.shape == where.shape): raise ValueError("Argument dimensions are incompatible") diff --git a/GPy/plotting/matplot_dep/plot_definitions.py b/GPy/plotting/matplot_dep/plot_definitions.py index 34f32ac5..7fadbf67 100644 --- a/GPy/plotting/matplot_dep/plot_definitions.py +++ b/GPy/plotting/matplot_dep/plot_definitions.py @@ -255,9 +255,9 @@ class MatplotlibPlots(AbstractPlottingLibrary): y2 = np.ones_like(x) * y2 if where is None: - where = np.ones(len(x), np.bool) + where = np.ones(len(x), bool) else: - where = np.asarray(where, np.bool) + where = np.asarray(where, bool) if not (x.shape == y1.shape == y2.shape == where.shape): raise ValueError("Argument dimensions are incompatible") diff --git a/setup.py b/setup.py index b79a0d12..4d3ea00a 100644 --- a/setup.py +++ b/setup.py @@ -119,11 +119,7 @@ except ModuleNotFoundError: install_requirements = ['numpy>=1.7', 'six', 'paramz>=0.9.0', 'cython>=0.29'] matplotlib_version = 'matplotlib==3.3.4' -if sys.version_info < (3, 6): - install_requirements += ['scipy>=1.3.0,<1.5.0'] - matplotlib_version = 'matplotlib==3.0.0' -else: - install_requirements += ['scipy>=1.3.0'] +install_requirements += ['scipy>=1.3.0'] setup(name = 'GPy', version = __version__,