Skip to content

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

@Jhawk414

Description

@Jhawk414

ThermoAdd.compute() raises a TypeError at line 121 due to two breaking changes:

  • OpenMDAO 3.42.0 stores scalar inputs as (1,) arrays instead of scalars

  • NumPy 2.0 removed implicit float() conversion on 1-element arrays

The crash: W_other_out[self.idx_compo] += W_other_mix on line 121 causes the following TypeErrors:

TypeError: 'DESIGN.burner.mix_fuel.thermo_add' <class ThermoAdd>: Error calling compute(), only 0-dimensional arrays can be converted to Python scalars

  File "C:\Users\REDACTED_FILEPATH\pycycle\thermo\tabular\thermo_add.py", line 121, in compute
    W_other_out[self.idx_compo] += float(W_other_mix)
                                   ^^^^^^^^^^^^^^^^^^
TypeError: only 0-dimensional arrays can be converted to Python scalars

Fix: change line 121 in thermo_add.py to W_other_out[self.idx_compo] += W_other_mix.item()

Versions: om-pycycle 4.4.0, openmdao 3.42.0, numpy 2.4.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions