Fixed an MPhys issue with setting scalars with Numpy 2.4#401
Open
Fixed an MPhys issue with setting scalars with Numpy 2.4#401
Conversation
… longer treated as float in numpy 2.4
Updated comment to clarify purpose of code change.
A-CGray
approved these changes
Apr 10, 2026
Member
A-CGray
left a comment
There was a problem hiding this comment.
Thanks for fixing this @sabakhshi
Member
|
@sanjan98 you're running ADflow through MPhys at the moment right? Could you test out this fix on your case using numpy 2.3 and 2.4? |
Contributor
|
@A-CGray I can test it tomorrow and approve |
Contributor
|
@sabakhshi @A-CGray |
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.
Purpose
The Mphys wrapper was not working with Numpy versions >2.4.
This is because as of Numpy 2.4 1D vectors of length 1 can no longer be treated as scalar data types.
This issue manifested when ADflow tried to print the alpha value set by OpenMDAO.
We now check if we are setting a 1D array of len(1) and explicitly index the first entry to get a scalar
data type.
Expected time until merged
1-2 days
Type of change
Testing
No new test required since we don't test on Numpy 2.4 yet.
This is just getting ahead of the issue.
The fix may no longer be needed if OpenMDAO changes something upstream
to account for this.
Checklist
ruff checkandruff formatto make sure the Python code adheres to PEP-8 and is consistently formattedfprettifyor C/C++ code withclang-formatas applicable