Skip to content

Bug: Type coercion from torch to numpy does not work #1439

@JohannesMessner

Description

@JohannesMessner

Description:
casting a TorchTensor NdArray fails

How to reproduce:

from docarray import BaseDoc
from docarray.typing import NdArray
import torch

class MyDoc(BaseDoc):
    tens: NdArray

t1 = torch.rand(512)
doc = MyDoc(tens=t1)
  Expected a numpy.ndarray compatible type, got <class 'torch.Tensor'> (type=value_error)

TODO:

  • Fix this in the validate function of NdArray
  • what about coercions to/from tf? do we have tests for this?

Metadata

Metadata

Assignees

Labels

good-first-issueSuitable as your first contribution to DocArray!type/bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions