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
This commit is contained in:
Martin Bubel 2023-04-21 18:32:33 +02:00 committed by GitHub
parent f63ed48b0d
commit 3c3ec60dea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 11 deletions

View file

@ -77,7 +77,7 @@ def randomize(self, rand_gen=None, *args, **kwargs):
# now draw from prior where possible # now draw from prior where possible
x = self.param_array.copy() 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] [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__ from paramz.transformations import __fixed__
unfixlist[self.constraints[__fixed__]] = False unfixlist[self.constraints[__fixed__]] = False
self.param_array.flat[unfixlist] = x.view(np.ndarray).ravel()[unfixlist] self.param_array.flat[unfixlist] = x.view(np.ndarray).ravel()[unfixlist]

View file

@ -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): def sample(self, Ntotal=10000, Nburn=1000, Nthin=10, tune=True, tune_throughout=False, tune_interval=400):
current = self.model.optimizer_array current = self.model.optimizer_array
fcurrent = self.model.log_likelihood() + self.model.log_prior() 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): for it in range(Ntotal):
print("sample %d of %d\r"%(it+1,Ntotal),end="") print("sample %d of %d\r"%(it+1,Ntotal),end="")
sys.stdout.flush() sys.stdout.flush()

View file

@ -82,9 +82,9 @@ def gradient_fill(x, percentiles, ax=None, fignum=None, **kwargs):
y2 = np.ones_like(x) * y2 y2 = np.ones_like(x) * y2
if where is None: if where is None:
where = np.ones(len(x), np.bool) where = np.ones(len(x), bool)
else: else:
where = np.asarray(where, np.bool) where = np.asarray(where, bool)
if not (x.shape == y1.shape == y2.shape == where.shape): if not (x.shape == y1.shape == y2.shape == where.shape):
raise ValueError("Argument dimensions are incompatible") raise ValueError("Argument dimensions are incompatible")

View file

@ -255,9 +255,9 @@ class MatplotlibPlots(AbstractPlottingLibrary):
y2 = np.ones_like(x) * y2 y2 = np.ones_like(x) * y2
if where is None: if where is None:
where = np.ones(len(x), np.bool) where = np.ones(len(x), bool)
else: else:
where = np.asarray(where, np.bool) where = np.asarray(where, bool)
if not (x.shape == y1.shape == y2.shape == where.shape): if not (x.shape == y1.shape == y2.shape == where.shape):
raise ValueError("Argument dimensions are incompatible") raise ValueError("Argument dimensions are incompatible")

View file

@ -119,11 +119,7 @@ except ModuleNotFoundError:
install_requirements = ['numpy>=1.7', 'six', 'paramz>=0.9.0', 'cython>=0.29'] install_requirements = ['numpy>=1.7', 'six', 'paramz>=0.9.0', 'cython>=0.29']
matplotlib_version = 'matplotlib==3.3.4' matplotlib_version = 'matplotlib==3.3.4'
if sys.version_info < (3, 6): install_requirements += ['scipy>=1.3.0']
install_requirements += ['scipy>=1.3.0,<1.5.0']
matplotlib_version = 'matplotlib==3.0.0'
else:
install_requirements += ['scipy>=1.3.0']
setup(name = 'GPy', setup(name = 'GPy',
version = __version__, version = __version__,