Repository navigation
Fix region-3 thrust shaving unpacking for numpy >= 2.5 - #737
Merged
gbarter merged 4 commits intoSep 29, 2026
Merged
Conversation
The peak thrust shaving branch in ComputePowerCurve assigned shape-(1,) ccblade outputs into scalar array slots, which numpy 2.5 turns from a DeprecationWarning into an error. Index with [0] as the other unpackings do, and make scaling_thrust a scalar. Add a regression test that reaches this branch and treats numpy's ndim conversion warning as an error so it also fails on older numpy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
I fixed the issue with the mac compilers here if you want me to pull in the same fix: NatLabRockies/ROSCO@8d95127 |
OpenMDAO 3.45.1 changed Autoscaler.get_bounds_scaling() to return a name-keyed BoundMap instead of a (lower, upper, equals) tuple, and represents unbounded directions as None or +/-inf rather than the now deprecated INF_BOUND sentinel. Read bounds from the BoundMap, following OpenMDAO's ScipyOptimizeDriver, and drop the INF_BOUND import. Also check double-sided constraints per element; previously the bounds array was overwritten by its first element inside the loop. OpenMDAO 3.45.1 also looks for the renamed 'pydoe' package instead of 'pyDOE3' for its DOE and GA drivers, so add it as a dependency. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix region-3 peak thrust shaving crash on numpy >= 2.5
Summary
ComputePowerCurve.compute()fails on numpy >= 2.5 when peak thrust shaving re-solves a region-3 point:In the
if peak_thrust_shaving and T[i] >= max_T:branch, the output ofccblade.evaluatewas unpacked withmyout[key]. That put shape-(1,) arrays into the scalar slotsP_aero[i],T[i], and so on. Numpy has warned about this since 1.25, and 2.5 raises an error. Every other unpacking in the function already usesmyout[key][0].We found this in WEIS CI (
iea22_raft_opt_driver, withthrust_shaving_coeff: 0.8). It only failed on Windows/Python 3.12, because whether this branch runs depends on the path the optimizer takes. NLRWindSystems/WEIS#478 pinsnumpy<2.5until a WISDEM release includes this fix.Changes
rotor_power.py: usemyout[key][0]in the region-3 thrust-shaving unpacking.rotor_power.py: makescaling_thrusta scalar (0.1*float(myout["T"][0])).ccblade.evaluateflattens its inputs, so scalar arguments still return shape-(1,) arrays.testRegulationTrajectory_PeakShavingRegion3. It uses the NREL 5MW test data with an 80 m/s tip-speed limit andpeak_thrust_shaving=0.5, which reaches this branch; no existing test does. The test treats numpy's "Conversion of an array with ndim > 0" warning as an error, so it also fails on numpy < 2.5 if this comes back.numpy<2.5pin in Speed up CI conda solve WEIS#478 can be removed.Audit of
wisdem/rotorse/I found no other cases:
float()or scalar casts on unindexedinputs[...]. All other unpackings ofevaluate()results already use[0]Testing
wisdem/test/test_rotorse/The new test fails on the old code under both numpy versions and passes with the fix.
Known issue (not addressed here)
With
peak_thrust_shaving=0.5, the rated-point solve doesn't converge. The point atrated_Vstays atfull thrust and 5 MW, and the next feww rated power. This happens withoutthis change too.
🤖 Generated with Claude Code