Skip to content

VectorData/ImageData mulitplication #1977

Description

@epapoutsellis

@bosschmidt

There is a problem with ImageData multiplied with VectorData

from cil.framework import VectorGeometry, ImageGeometry
vg = VectorGeometry(505)
ig  = ImageGeometry(505,505)


x1 = ig.allocate("random")
x2 = vg.allocate("random")

res1 = x1.array.dot(x2.array)
print(res1.shape)

res2 = x1.dot(x2)

returns

(505,)

ValueError                                Traceback (most recent call last)
Cell In[3], line 11
      8 res1 = x1.array.dot(x2.array)
      9 print(res1.shape)
---> 11 res2 = x1.dot(x2)

File /opt/conda/lib/python3.11/site-packages/cil/framework/data_container.py:718, in DataContainer.dot(self, other, *args, **kwargs)
    716         return sf
    717 else:
--> 718     raise ValueError('Shapes are not aligned: {} != {}'.format(self.shape, other.shape))

ValueError: Shapes are not aligned: (505, 505) != (505,)

So when comparing shapes in https://github.com/TomographicImaging/CIL/blob/master/Wrappers/Python/cil/framework/data_container.py#L705

we should check self.shape[1] == other.shape[0].

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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