Skip to content

Remove cast conversion of an array with ndim > 0 to scalar#77

Merged
Kenneth-T-Moore merged 1 commit intoOpenMDAO:masterfrom
flight-test-engineering:flight-test-engineering-HBTF-numpy-ndim_warning
Feb 25, 2025
Merged

Remove cast conversion of an array with ndim > 0 to scalar#77
Kenneth-T-Moore merged 1 commit intoOpenMDAO:masterfrom
flight-test-engineering:flight-test-engineering-HBTF-numpy-ndim_warning

Conversation

@flight-test-engineering
Copy link
Contributor

Eliminate Numpy deprecation warning when running high bypass turbofan example.
Note: it will become a TypeError in the future.

DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
  print(" %7.5f  %7.1f %7.3f %7.1f %7.1f %7.1f %7.3f  %7.5f  %7.3f" %summary_data, file=file, flush=True)

NumPy 1.25 deprecation message (merged on 2023-04-20): Only ndim-0 arrays are treated as scalars. NumPy used to treat all arrays of size 1 (e.g., np.array([3.14])) as scalars. In the future, this will be limited to arrays of ndim 0 (e.g., np.array(3.14)). See Numpy 1.25 release notes

Proposed solution is to explicitly get first element of arrays.

Eliminate Numpy deprecation warning when running high bypass turbofan example.
Note: it will become a TypeError in the future.

NumPy 1.25 deprecation message (merged on 2023-04-20): Only ndim-0 arrays are treated as scalars. NumPy used to treat all arrays of size 1 (e.g., np.array([3.14])) as scalars. In the future, this will be limited to arrays of ndim 0 (e.g., np.array(3.14)). 

See https://numpy.org/devdocs/release/1.25.0-notes.html#deprecations
@Kenneth-T-Moore Kenneth-T-Moore merged commit 825e07d into OpenMDAO:master Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants