-
-
Notifications
You must be signed in to change notification settings - Fork 409
Description
NumPy 2.0 hasn't been released yet, but the initial release notes from the pre-release mentions some breaking changes that they address in their migration guide. I don't know how the Cantera team wants to handle compatibility going forward, but I thought I would go ahead and make a thread in case it's helpful.
Previous Cantera builds
I installed NumPy 2.0.0b1 and attempted to import Cantera 3.0.0 which yields the following error:
...
from ._cantera import *
File "cantera/_cantera.pyx", line 33, in init cantera._cantera
File "cantera/_utils.pyx", line 1, in init cantera._utils
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
Clearly previous builds of Cantera can only be used with NumPy 1.x and will not work with 2.x releases. I don't know if there is a way to enforce numpy<2.0.0 as a package requirement on PyPI, or if that can't be done retroactively, but it might need to be added to some documentation somewhere.
Future Cantera builds
I attempted to build Cantera from source from the latest commit using NumPy 2.0.0b1 to see what changes would need to be made. The first build error that I get from the breaking changes is below:
build\python\cantera\_onedim.cpp(8544): error C2039: 'subarray': is not a member of '_PyArray_Descr'
...
build\python\cantera\_onedim.cpp(8545): error C2039: 'subarray': is not a member of '_PyArray_Descr'
The changes to the PyArray_Descr struct are covered in this section of the migration guide. It seems the PyDataType_SUBARRAY accessor function needs to be used. They also provide a npy2_compat.h file that can be included in the code base that will allow compilation on NumPy 1.x and not affect 2.x builds.
I haven't gotten any further yet, but I will edit this if I do.