Skip to content

contract_path with ellipsis fails when shapes=True #235

@nova77

Description

@nova77

Easy way to reproduce:

input = np.random.rand(1,3,5,2,)
a = np.random.rand(2)
b = np.random.rand(7)

# ValueError: operands could not be broadcast together with shapes (4,) (0,) 
oe.contract_path('...D,D,k->...k', input.shape, a.shape, b.shape, shapes=True)

While if we do not pass the shapes, the function works:

oe.contract_path('...D,D,k->...k', input, a, b)  # all good!

The source of error is in in parser.py where operands (i.e. the shapes) are converted into arrays:

operands = [possibly_convert_to_numpy(x) for x in operands[1:]]

The fix should be simple: just skip the conversion when shapes is True.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions