Skip to content

Unittest that mixes types of DataContainer, what should happen? #2289

@paskino

Description

@paskino

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.

  1. What should happen at line 1236?
  2. Do we have to do implicit type promotion?
  3. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions