Skip to content

Commit 90bb873

Browse files
committed
Fixing errors in new LineDesign test
- Had to debug and figure out that the specific LineDesign results we have for the tests are based on a specific SciPy version - - So we needed to install that specific version (which only happened to work with a separate pip install call, rather than appending to the existing conda install in "Exras") - Also, needed to uninstall the existing moorpy installation to allow for the current dev branch installation - Updated the np.float parameters in fadsolvers to a current format that numpy v2 can use, just in case
1 parent c0023f0 commit 90bb873

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

.github/workflows/CI_FAModel.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
- name: Extras
4141
run: |
4242
conda install -y pytest meson ninja nlopt
43+
pip install scipy==1.11.2 # specific SciPy version needed for current LineDesign test results
4344
conda info
4445
4546
- name: Conda Install famodel
@@ -48,6 +49,7 @@ jobs:
4849
4950
- name: Overwrite MoorPy
5051
run: |
52+
pip uninstall moorpy # need to uninstall the old version to install the current dev branch
5153
pip install git+https://github.com/NREL/MoorPy@dev
5254
5355
- name: Example run

famodel/design/fadsolvers.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def dsolve(eval_func, X0, Ytarget=[], step_func=None, args=[], tol=0.0001, maxIt
141141

142142
# process inputs and format as arrays in case they aren't already
143143

144-
X = np.array(X0, dtype=np.float_) # start off design variable
144+
X = np.array(X0, dtype=np.float64) # start off design variable
145145
N = len(X)
146146

147147
Xs = np.zeros([maxIter,N]) # make arrays to store X and error results of the solve
@@ -152,9 +152,9 @@ def dsolve(eval_func, X0, Ytarget=[], step_func=None, args=[], tol=0.0001, maxIt
152152

153153
# check the target Y value input
154154
if len(Ytarget)==N:
155-
Ytarget = np.array(Ytarget, dtype=np.float_)
155+
Ytarget = np.array(Ytarget, dtype=np.float64)
156156
elif len(Ytarget)==0:
157-
Ytarget = np.zeros(N, dtype=np.float_)
157+
Ytarget = np.zeros(N, dtype=np.float64)
158158
else:
159159
raise TypeError("Ytarget must be of same length as X0")
160160

@@ -193,14 +193,14 @@ def step_func(X, args, Y, oths, Ytarget, err, tol, iter, maxIter):
193193
if len(Xmin)==0:
194194
Xmin = np.zeros(N)-np.inf
195195
elif len(Xmin)==N:
196-
Xmin = np.array(Xmin, dtype=np.float_)
196+
Xmin = np.array(Xmin, dtype=np.float64)
197197
else:
198198
raise TypeError("Xmin must be of same length as X0")
199199

200200
if len(Xmax)==0:
201201
Xmax = np.zeros(N)+np.inf
202202
elif len(Xmax)==N:
203-
Xmax = np.array(Xmax, dtype=np.float_)
203+
Xmax = np.array(Xmax, dtype=np.float64)
204204
else:
205205
raise TypeError("Xmax must be of same length as X0")
206206

@@ -209,7 +209,7 @@ def step_func(X, args, Y, oths, Ytarget, err, tol, iter, maxIter):
209209
if len(dX_last)==0:
210210
dX_last = np.zeros(N)
211211
else:
212-
dX_last = np.array(dX_last, dtype=np.float_)
212+
dX_last = np.array(dX_last, dtype=np.float64)
213213

214214
if display>1:
215215
print(f"Starting dsolve iterations>>> aiming for Y={Ytarget}")
@@ -365,7 +365,7 @@ def dsolve2(eval_func, X0, Ytarget=[], step_func=None, args=[], tol=0.0001, maxI
365365
start_time = time.time()
366366
# process inputs and format as arrays in case they aren't already
367367

368-
X = np.array(X0, dtype=np.float_) # start off design variable
368+
X = np.array(X0, dtype=np.float64) # start off design variable
369369
N = len(X)
370370

371371
Xs = np.zeros([maxIter,N]) # make arrays to store X and error results of the solve
@@ -376,9 +376,9 @@ def dsolve2(eval_func, X0, Ytarget=[], step_func=None, args=[], tol=0.0001, maxI
376376

377377
# check the target Y value input
378378
if len(Ytarget)==N:
379-
Ytarget = np.array(Ytarget, dtype=np.float_)
379+
Ytarget = np.array(Ytarget, dtype=np.float64)
380380
elif len(Ytarget)==0:
381-
Ytarget = np.zeros(N, dtype=np.float_)
381+
Ytarget = np.zeros(N, dtype=np.float64)
382382
else:
383383
raise TypeError("Ytarget must be of same length as X0")
384384

@@ -393,14 +393,14 @@ def dsolve2(eval_func, X0, Ytarget=[], step_func=None, args=[], tol=0.0001, maxI
393393
if len(Xmin)==0:
394394
Xmin = np.zeros(N)-np.inf
395395
elif len(Xmin)==N:
396-
Xmin = np.array(Xmin, dtype=np.float_)
396+
Xmin = np.array(Xmin, dtype=np.float64)
397397
else:
398398
raise TypeError("Xmin must be of same length as X0")
399399

400400
if len(Xmax)==0:
401401
Xmax = np.zeros(N)+np.inf
402402
elif len(Xmax)==N:
403-
Xmax = np.array(Xmax, dtype=np.float_)
403+
Xmax = np.array(Xmax, dtype=np.float64)
404404
else:
405405
raise TypeError("Xmax must be of same length as X0")
406406

@@ -454,7 +454,7 @@ def step_func(X, args, Y, oths, Ytarget, err, tols, iter, maxIter):
454454
if len(dX_last)==0:
455455
dX_last = np.zeros(N)
456456
else:
457-
dX_last = np.array(dX_last, dtype=np.float_)
457+
dX_last = np.array(dX_last, dtype=np.float64)
458458

459459
if display>0:
460460
print(f"Starting dsolve iterations>>> aiming for Y={Ytarget}")
@@ -639,7 +639,7 @@ def dopt(eval_func, X0, tol=0.0001, maxIter=20, Xmin=[], Xmax=[], a_max=1.2, dX_
639639
if len(X0) == 0:
640640
raise ValueError("X0 cannot be empty")
641641

642-
X = np.array(X0, dtype=np.float_) # start off design variable (optimized)
642+
X = np.array(X0, dtype=np.float64) # start off design variable (optimized)
643643

644644
# do a test call to see what size the results are
645645
f, g, Xextra, Yextra, oths, stop = eval_func(X) #, XtLast, Ytarget, args)
@@ -657,20 +657,20 @@ def dopt(eval_func, X0, tol=0.0001, maxIter=20, Xmin=[], Xmax=[], a_max=1.2, dX_
657657
if len(Xmin)==0:
658658
Xmin = np.zeros(N)-np.inf
659659
elif len(Xmin)==N:
660-
Xmin = np.array(Xmin, dtype=np.float_)
660+
Xmin = np.array(Xmin, dtype=np.float64)
661661
else:
662662
raise TypeError("Xmin must be of same length as X0")
663663

664664
if len(Xmax)==0:
665665
Xmax = np.zeros(N)+np.inf
666666
elif len(Xmax)==N:
667-
Xmax = np.array(Xmax, dtype=np.float_)
667+
Xmax = np.array(Xmax, dtype=np.float64)
668668
else:
669669
raise TypeError("Xmax must be of same length as X0")
670670

671671

672672
if len(dX_last)==N:
673-
dX_last = np.array(dX_last, dtype=np.float_)
673+
dX_last = np.array(dX_last, dtype=np.float64)
674674
elif len(dX_last)==0:
675675
dX_last = np.zeros(N)
676676
else:
@@ -748,7 +748,7 @@ def dopt(eval_func, X0, tol=0.0001, maxIter=20, Xmin=[], Xmax=[], a_max=1.2, dX_
748748

749749
dX = np.zeros(N) # optimization step size to take
750750

751-
X2 = np.array(X, dtype=np.float_)
751+
X2 = np.array(X, dtype=np.float64)
752752

753753
Jf = np.zeros([N])
754754
Jg = np.zeros([N,m])
@@ -1136,7 +1136,7 @@ def dopt2(eval_func, X0, tol=0.0001, maxIter=20, Xmin=[], Xmax=[], a_max=1.2, dX
11361136
if len(X0) == 0:
11371137
raise ValueError("X0 cannot be empty")
11381138

1139-
X = np.array(X0, dtype=np.float_) # start off design variable (optimized)
1139+
X = np.array(X0, dtype=np.float64) # start off design variable (optimized)
11401140

11411141
# do a test call to see what size the results are
11421142
f, g, Xextra, Yextra, oths, stop = eval_func(X, args) #, XtLast, Ytarget, args)
@@ -1154,20 +1154,20 @@ def dopt2(eval_func, X0, tol=0.0001, maxIter=20, Xmin=[], Xmax=[], a_max=1.2, dX
11541154
if len(Xmin)==0:
11551155
Xmin = np.zeros(N)-np.inf
11561156
elif len(Xmin)==N:
1157-
Xmin = np.array(Xmin, dtype=np.float_)
1157+
Xmin = np.array(Xmin, dtype=np.float64)
11581158
else:
11591159
raise TypeError("Xmin must be of same length as X0")
11601160

11611161
if len(Xmax)==0:
11621162
Xmax = np.zeros(N)+np.inf
11631163
elif len(Xmax)==N:
1164-
Xmax = np.array(Xmax, dtype=np.float_)
1164+
Xmax = np.array(Xmax, dtype=np.float64)
11651165
else:
11661166
raise TypeError("Xmax must be of same length as X0")
11671167

11681168

11691169
if len(dX_last)==N:
1170-
dX_last = np.array(dX_last, dtype=np.float_)
1170+
dX_last = np.array(dX_last, dtype=np.float64)
11711171
elif len(dX_last)==0:
11721172
dX_last = np.zeros(N)
11731173
else:
@@ -1264,7 +1264,7 @@ def dopt2(eval_func, X0, tol=0.0001, maxIter=20, Xmin=[], Xmax=[], a_max=1.2, dX
12641264

12651265
dX = np.zeros(N) # optimization step size to take
12661266

1267-
X2 = np.array(X, dtype=np.float_)
1267+
X2 = np.array(X, dtype=np.float64)
12681268

12691269
Jf = np.zeros([N])
12701270
Jg = np.zeros([N,m])

0 commit comments

Comments
 (0)