Skip to content

Commit

Permalink
fix numpy 1.25 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
ewu63 committed Nov 13, 2023
1 parent e44883a commit 38dad46
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pyoptsparse/pyIPOPT/pyIPOPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ def __call__(
jac = extractRows(jac, indices) # Does reordering
scaleRows(jac, fact) # Perform logical scaling
else:
blc = np.array([-INFINITY])
buc = np.array([INFINITY])
blc = np.array(-INFINITY)
buc = np.array(INFINITY)
ncon = 1

jac = convertToCOO(jac) # Conver to coo format for IPOPT
Expand Down
10 changes: 5 additions & 5 deletions pyoptsparse/pySLSQP/pySLSQP.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def slgrad(m, me, la, n, f, g, df, dg, x):
gg = np.zeros([la], float)
df = np.zeros([n + 1], float)
dg = np.zeros([la, n + 1], float)
acc = np.array([self.getOption("ACC")], float)
acc = np.array(self.getOption("ACC"), float)
maxit = self.getOption("MAXIT")
iprint = self.getOption("IPRINT")
iout = self.getOption("IOUT")
Expand All @@ -204,13 +204,13 @@ def slgrad(m, me, la, n, f, g, df, dg, x):
lsei = ((n + 1) + mineq) * ((n + 1) - meq) + 2 * meq + (n + 1)
slsqpb = (n + 1) * (n / 2) + 2 * m + 3 * n + 3 * (n + 1) + 1
lwM = lsq + lsi + lsei + slsqpb + n + m
lw = np.array([lwM], int)
lw = np.array(lwM, int)
w = np.zeros(lw, float)
ljwM = max(mineq, (n + 1) - meq)
ljw = np.array([ljwM], int)
ljw = np.array(ljwM, int)
jw = np.zeros(ljw, np.intc)
nfunc = np.array([0], int)
ngrad = np.array([0], int)
nfunc = np.array(0, int)
ngrad = np.array(0, int)

# Run SLSQP
t0 = time.time()
Expand Down
6 changes: 3 additions & 3 deletions pyoptsparse/pySNOPT/pySNOPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def __call__(
if nnCon == 0:
nnCon = 1
self.optProb.jacIndices = [0]
self.optProb.fact = np.array([1.0])
self.optProb.fact = np.array(1.0)
self.optProb.offset = np.zeros_like(self.optProb.fact)

# Make sure restartDict is provided if using hot start
Expand Down Expand Up @@ -461,7 +461,7 @@ def __call__(

# Setup argument list values
start = np.array(self.getOption("Start"))
ObjAdd = np.array([0.0], float)
ObjAdd = np.array(0.0, float)
ProbNm = np.array(self.optProb.name, "c")
cdummy = -1111111 # this is a magic variable defined in SNOPT for undefined strings
cw[51, :] = cdummy # we set these to cdummy so that a placeholder is used in printout
Expand Down Expand Up @@ -704,7 +704,7 @@ def _set_snopt_options(self, iPrint: int, iSumm: int, cw: ndarray, iw: ndarray,
"""
# Set Options from the local options dictionary
# ---------------------------------------------
inform = np.array([-1], np.intc)
inform = np.array(-1, np.intc)
for name, value in self.options.items():
# these do not get set using snset
if name in self.specialOptions or name in self.pythonOptions:
Expand Down

0 comments on commit 38dad46

Please sign in to comment.