Skip to content

ENH: Einsum does not support object dtype #17837

@sagewe

Description

@sagewe

Reproducing code example:

import numpy as np

def dot(dim):
    x = np.random.rand(dim, dim).astype(object)
    y = np.random.rand(dim, dim).astype(object)
    print(np.einsum("ij,jk->ik", x, y, optimize=True))

dot(2) # ok
dot(3) # ok
dot(1) # error

Error message:

Traceback (most recent call last):
File "einsum.py", line 17, in
main()
File "einsum.py", line 13, in main
sum(dim)
File "einsum.py", line 8, in sum
print(np.einsum("ij,jk->ik", x, y, optimize=True))
File "<array_function internals>", line 6, in einsum
File "/Users/sage/Documents/venvs/FATE/lib/python3.6/site-packages/numpy/core/einsumfunc.py", line 1423, in einsum
new_view = c_einsum(einsum_str, *tmp_operands, **einsum_kwargs)
TypeError: invalid data type for einsum

NumPy/Python version information:

1.18.4 3.6.10 |Anaconda, Inc.| (default, May 7 2020, 23:06:31)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions