From a2ab3cf6b9b949c6c144ce970789ef765d011b2f Mon Sep 17 00:00:00 2001 From: Jeffrey Larson Date: Wed, 24 Feb 2021 11:27:11 -0600 Subject: [PATCH] Removing np.float and np.int usage --- dfols/hessian.py | 2 +- dfols/model.py | 2 +- dfols/solver.py | 6 +++--- dfols/trust_region.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dfols/hessian.py b/dfols/hessian.py index 8e93ba2..0329e9e 100644 --- a/dfols/hessian.py +++ b/dfols/hessian.py @@ -39,7 +39,7 @@ class Hessian(object): def __init__(self, n, vals=None): self.n = n if vals is None: - self.hq = np.zeros((n * (n + 1) // 2,), dtype=np.float) + self.hq = np.zeros((n * (n + 1) // 2,), dtype=float) else: assert isinstance(vals, np.ndarray), "Can only set Hessian from NumPy array" assert len(vals.shape) in [1, 2], "Can only set Hessian from vector or matrix" diff --git a/dfols/model.py b/dfols/model.py index 4adc190..8f1901c 100644 --- a/dfols/model.py +++ b/dfols/model.py @@ -71,7 +71,7 @@ def __init__(self, npt, x0, r0, xl, xu, r0_nsamples, n=None, m=None, abs_tol=1e- self.fval = np.inf * np.ones((npt, )) # overall objective value for each xpt self.fval[0] = sumsq(r0) self.kopt = 0 # index of current iterate (should be best value so far) - self.nsamples = np.zeros((npt,), dtype=np.int) # number of samples used to evaluate objective at each point + self.nsamples = np.zeros((npt,), dtype=int) # number of samples used to evaluate objective at each point self.nsamples[0] = r0_nsamples self.fbeg = self.fval[0] # f(x0), saved to check for sufficient reduction diff --git a/dfols/solver.py b/dfols/solver.py index 1f8e8e6..8c66f35 100644 --- a/dfols/solver.py +++ b/dfols/solver.py @@ -852,7 +852,7 @@ def solve_main(objfun, x0, args, xl, xu, npt, rhobeg, rhoend, maxfun, nruns_so_f def solve(objfun, x0, args=(), bounds=None, npt=None, rhobeg=None, rhoend=1e-8, maxfun=None, nsamples=None, user_params=None, objfun_has_noise=False, scaling_within_bounds=False, do_logging=True, print_progress=False): - x0 = x0.astype(np.float) + x0 = x0.astype(np.float64) n = len(x0) # Set missing inputs (if not specified) to some sensible defaults @@ -861,8 +861,8 @@ def solve(objfun, x0, args=(), bounds=None, npt=None, rhobeg=None, rhoend=1e-8, xu = None else: assert len(bounds) == 2, "bounds must be a 2-tuple of (lower, upper), where both are arrays of size(x0)" - xl = bounds[0].astype(np.float) if bounds[0] is not None else None - xu = bounds[1].astype(np.float) if bounds[1] is not None else None + xl = bounds[0].astype(np.float64) if bounds[0] is not None else None + xu = bounds[1].astype(np.float64) if bounds[1] is not None else None if (xl is None or xu is None) and scaling_within_bounds: scaling_within_bounds = False diff --git a/dfols/trust_region.py b/dfols/trust_region.py index d360974..ec8c975 100644 --- a/dfols/trust_region.py +++ b/dfols/trust_region.py @@ -103,7 +103,7 @@ def trsbox(xopt, g, H, sl, su, delta, use_fortran=USE_FORTRAN): iterc = 0 nact = 0 # number of fixed variables - xbdi = np.zeros((n,), dtype=np.int) # fix x_i at bounds? [values -1, 0, 1] + xbdi = np.zeros((n,), dtype=int) # fix x_i at bounds? [values -1, 0, 1] xbdi[(xopt <= sl) & (g >= 0.0)] = -1 xbdi[(xopt >= su) & (g <= 0.0)] = 1