Skip to content

Support conversion from int to float #45

@amnore

Description

@amnore

I have the following type:

NDArray[Shape['2'], float]

and this json:

[150, 100]

When trying to deserialize from json, I would get the following error:

Value error, Invalid dtype! expected (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>), got int64 [type=value_error, input_value=[150, 100], input_type=list]
    For further information visit https://errors.pydantic.dev/2.10/v/value_error

This requirement seems too strict. Is it possible to automatically convert from integer to floats in this case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions