itom-project / itom

itom core repository
https://itom-project.github.io/
Other
13 stars 5 forks source link

Unittest continuousDataObject2NpArray fail #288

Closed photoniker closed 2 months ago

photoniker commented 2 months ago

test_continuousDataObject2NpArray of DataObjectNpConversion fails for Python 3.12, Numpy 1.26.

image

magro11 commented 2 months ago

This issue is due to a change in Numpy. If a Numpy array is created from a compatible object of another type (here: a dataObject), Numpy for instance tries to get information about the matrix structure via the optional __array_struct__ member.

If Numpy is able to create its np.ndarray by means of a shallow copy (copy=False), the original source object is stored in the base member of the numpy array. For Numpy < 1.23, the base member was set to a ref-count incremented version of the original dataObject. For Numpy >= 1.23, the base member is now a tuple, that consists of the ref-count incremented dataObject (1st item) and the "PyCapsule" object as 2nd item.

For more information see:

The unittest in itom will be adapted with a version-switch for the numpy version.