Skip to content

fix: use .item() in ThermoAdd.compute() for NumPy 2.x + OpenMDAO 3.42 compatibility#117

Merged
Kenneth-T-Moore merged 2 commits into
OpenMDAO:masterfrom
Jhawk414:fix/thermo-add-numpy2-compat
May 20, 2026
Merged

fix: use .item() in ThermoAdd.compute() for NumPy 2.x + OpenMDAO 3.42 compatibility#117
Kenneth-T-Moore merged 2 commits into
OpenMDAO:masterfrom
Jhawk414:fix/thermo-add-numpy2-compat

Conversation

@Jhawk414
Copy link
Copy Markdown
Contributor

Fixes a TypeError in ThermoAdd.compute() when running with NumPy 2.x and OpenMDAO 3.42+.

OpenMDAO 3.42.0 changed scalar inputs to be stored as (1,) arrays rather than scalars. NumPy 2.0 removed implicit scalar conversion on 1-element arrays, so W_other_out[self.idx_compo] += W_other_mix fails because it tries to broadcast a (1,) array into a 0-d indexed slot.

Fix: changed to W_other_mix.item() to extract a proper Python scalar before the in-place add.

Closes #116

@Kenneth-T-Moore Kenneth-T-Moore merged commit ee7e161 into OpenMDAO:master May 20, 2026
5 checks passed
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.

thermo_add.py crashes with NumPy 2.x and OpenMDAO 3.42+

2 participants