Description
This unittest mixes data types with sapyb:
|
ig = ImageGeometry(10,10) |
|
d1 = ig.allocate(1, dtype=np.complex64) |
|
d2 = ig.allocate(2, dtype=np.float32) |
|
a = 2.+1j |
|
b = -1. |
|
|
|
# equals to 2*[1] + -1*[2] = 0 |
|
out = d1.sapyb(a,d2,b) |
|
res = np.zeros_like(d1.as_array()) + 1j |
|
np.testing.assert_array_equal(res, out.as_array()) |
As you can see we allocate a complex64 (d1) and a float32 (d2) DataContainer then do sapyb. d1 is multiplied by a complex number a and d2 by a real number b whilst executing a*d1+b*d2. In this case we are doing sapyb via numpy.
- What should happen at line 1236?
- Do we have to do implicit type promotion?
- Are we expecting the unittest to pass? At line 1237 we change the result of
sapyb and add the missing 1j so that the unit test pass.
With my new changes to make CIL's DataContainers agnostic on the array they wrap this test fails.
Environment
import cil, sys
print(cil.version.version, cil.version.commit_hash, sys.version, sys.platform)
Description
This unittest mixes data types with
sapyb:CIL/Wrappers/Python/test/test_DataContainer.py
Lines 1229 to 1238 in f8f2e31
As you can see we allocate a
complex64(d1) and afloat32(d2)DataContainerthen dosapyb.d1is multiplied by a complex numberaandd2by a real numberbwhilst executinga*d1+b*d2. In this case we are doingsapybvia numpy.sapyband add the missing1jso that the unit test pass.With my new changes to make CIL's
DataContainers agnostic on the array they wrap this test fails.Environment