CIL icon indicating copy to clipboard operation
CIL copied to clipboard

`DataContainer` agnostic on backend

Open paskino opened this issue 8 months ago • 2 comments

Description

Removes all the checks on the array wrapped by the DataContainer

Example Usage

:heart: Thanks for your contribution!

paskino avatar Apr 08 '25 17:04 paskino

I had to fix 2 unittest errors which depend on code I do not think I changed. It relates to geometry allocate. The actual test is the following:

geometry.dtype = complex
data = geometry.allocate(dtype=np.int64)
self.assertEqual(data.dtype, np.int64)

The error was due to the fact that the newly allocated ImageData or AcquisitionData are passed a copy of the geometry whose dtype might be different than the one requested by allocate resulting in the error below. I wonder why this didn't creep up earlier.

======================================================================
FAIL: test_AcquisitionGeometry_allocate_dtype (test_DataContainer.TestDataContainer.test_AcquisitionGeometry_allocate_dtype)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/CIL/CIL/Wrappers/Python/test/test_DataContainer.py", line 726, in test_AcquisitionGeometry_allocate_dtype
    self.dtype_allocate_test(ag)
  File "/home/runner/work/CIL/CIL/Wrappers/Python/test/test_DataContainer.py", line 699, in dtype_allocate_test
    self.assertEqual(data.geometry.dtype, np.int64)
AssertionError: <class 'complex'> != <class 'numpy.int64'>

======================================================================
FAIL: test_ImageGeometry_allocate_dtype (test_DataContainer.TestDataContainer.test_ImageGeometry_allocate_dtype)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/CIL/CIL/Wrappers/Python/test/test_DataContainer.py", line 711, in test_ImageGeometry_allocate_dtype
    self.dtype_allocate_test(ig)
  File "/home/runner/work/CIL/CIL/Wrappers/Python/test/test_DataContainer.py", line 699, in dtype_allocate_test
    self.assertEqual(data.geometry.dtype, np.int64)
AssertionError: <class 'complex'> != <class 'numpy.int64'>

----------------------------------------------------------------------
Ran 1027 tests in 120.134s

FAILED (failures=2, skipped=223)

paskino avatar Jun 04 '25 16:06 paskino

Thanks for the ping @purepani !

I highly recommend reading https://github.com/scipy/scipy/issues/18286 for a feel of the direction we are heading in with SciPy. Please feel free to ping me with any questions.

lucascolley avatar Jun 18 '25 23:06 lucascolley