Skip to content

Commit

Permalink
Docs: Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
caniko authored Mar 23, 2023
1 parent de07b90 commit 8579412
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For more examples see [test_ndarray.py](./tests/test_ndarray.py)

```python
import pydantic_numpy.dtype as pnd
from pydantic_numpy import NDArray, NDArrayFp32, NumpyModel
from pydantic_numpy import NDArray, NDArrayFp32, NumpyModel, model_agnostic_load


class MyPydanticNumpyModel(NumpyModel):
Expand All @@ -31,10 +31,12 @@ cfg = MyPydanticNumpyModel(K={"path": "path_to/array.npz", "key": "K"})
cfg.K
# np.ndarray[np.float32]

cfg.dump("path_to_dump")
cfg.load("path_to_dump")
cfg.dump("path_to_dump_dir", "object_id")
cfg.load("path_to_dump_dir", "object_id")
```

`NumpyModel.load` requires the original mode, use `model_agnostic_load` when you have several models, and you want to load into a set of possible models.

### Data type (dtype) support!

This package also comes with `pydantic_numpy.dtype`, which adds subtyping support such as `NDArray[float, pnd.float32]`. All subfields must be from this package as numpy dtypes have no Pydantic support, which is implemented in this package through the [generic class workflow](https://pydantic-docs.helpmanual.io/usage/types/#generic-classes-as-types).
Expand Down

0 comments on commit 8579412

Please sign in to comment.