-
Notifications
You must be signed in to change notification settings - Fork 7
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Is there a way to extract json from .model_dump_json() and reconstruct / validate with .model_validate_json() ?
I am getting errors:
def array_validator(array: npt.NDArray) -> npt.NDArray:
> if dimensions and (array_dimensions := len(array.shape)) != dimensions:
E AttributeError: 'dict' object has no attribute 'shape'
Because the jsonified dict is not understood when validating.
from pydantic_numpy.model import NumpyModel
import pydantic_numpy as pnd
from pydantic import Field
import numpy as np
class A(NumpyModel):
numpy_arr: pnd.NpNDArrayFp16 = Field(frozen=True, strict=True, kw_only=False)
a = A(numpy_arr=np.zeros(10))
json_str = a.model_dump_json()
a.model_validate_json(json_str)
Replication of what I would expect to be able to do
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working