Skip to content

Commit

Permalink
Fix: Will resolve unsupported types to supported ones on NT (Windows)
Browse files Browse the repository at this point in the history
Test: Added tests for macos and windows
Chore: Bump version, MINOR
  • Loading branch information
caniko authored and Can H. Tartanoglu committed Jul 29, 2023
1 parent abcfd59 commit 3dd1d6a
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 128 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ on:
pull_request:
branches: [ trunk ]

defaults:
run:
shell: bash

jobs:
unit_tests:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11" ]
os: [ ubuntu-latest, windows-latest, macos-latest ]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions pydantic_numpy/typing/i_dimensional.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
Np1DArrayUint16 = np_array_pydantic_annotated_typing(data_type=np.uint16, dimensions=1)
Np1DArrayUint8 = np_array_pydantic_annotated_typing(data_type=np.uint8, dimensions=1)

Np1DArrayFp128 = np_array_pydantic_annotated_typing(data_type=np.float128, dimensions=1)
Np1DArrayFp128 = np_array_pydantic_annotated_typing(data_type=np.longdouble, dimensions=1)
Np1DArrayFp64 = np_array_pydantic_annotated_typing(data_type=np.float64, dimensions=1)
Np1DArrayFp32 = np_array_pydantic_annotated_typing(data_type=np.float32, dimensions=1)
Np1DArrayFp16 = np_array_pydantic_annotated_typing(data_type=np.float16, dimensions=1)

Np1DArrayComplex256 = np_array_pydantic_annotated_typing(data_type=np.complex256, dimensions=1)
Np1DArrayComplex256 = np_array_pydantic_annotated_typing(data_type=np.clongdouble, dimensions=1)
Np1DArrayComplex128 = np_array_pydantic_annotated_typing(data_type=np.complex128, dimensions=1)
Np1DArrayComplex64 = np_array_pydantic_annotated_typing(data_type=np.complex64, dimensions=1)

Expand Down
4 changes: 2 additions & 2 deletions pydantic_numpy/typing/ii_dimensional.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
Np2DArrayUint16 = np_array_pydantic_annotated_typing(data_type=np.uint16, dimensions=2)
Np2DArrayUint8 = np_array_pydantic_annotated_typing(data_type=np.uint8, dimensions=2)

Np2DArrayFp128 = np_array_pydantic_annotated_typing(data_type=np.float128, dimensions=2)
Np2DArrayFp128 = np_array_pydantic_annotated_typing(data_type=np.longdouble, dimensions=2)
Np2DArrayFp64 = np_array_pydantic_annotated_typing(data_type=np.float64, dimensions=2)
Np2DArrayFp32 = np_array_pydantic_annotated_typing(data_type=np.float32, dimensions=2)
Np2DArrayFp16 = np_array_pydantic_annotated_typing(data_type=np.float16, dimensions=2)

Np2DArrayComplex256 = np_array_pydantic_annotated_typing(data_type=np.complex256, dimensions=2)
Np2DArrayComplex256 = np_array_pydantic_annotated_typing(data_type=np.clongdouble, dimensions=2)
Np2DArrayComplex128 = np_array_pydantic_annotated_typing(data_type=np.complex128, dimensions=2)
Np2DArrayComplex64 = np_array_pydantic_annotated_typing(data_type=np.complex64, dimensions=2)

Expand Down
4 changes: 2 additions & 2 deletions pydantic_numpy/typing/iii_dimensional.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
Np3DArrayUint16 = np_array_pydantic_annotated_typing(data_type=np.uint16, dimensions=3)
Np3DArrayUint8 = np_array_pydantic_annotated_typing(data_type=np.uint8, dimensions=3)

Np3DArrayFp128 = np_array_pydantic_annotated_typing(data_type=np.float128, dimensions=3)
Np3DArrayFp128 = np_array_pydantic_annotated_typing(data_type=np.longdouble, dimensions=3)
Np3DArrayFp64 = np_array_pydantic_annotated_typing(data_type=np.float64, dimensions=3)
Np3DArrayFp32 = np_array_pydantic_annotated_typing(data_type=np.float32, dimensions=3)
Np3DArrayFp16 = np_array_pydantic_annotated_typing(data_type=np.float16, dimensions=3)

Np3DArrayComplex256 = np_array_pydantic_annotated_typing(data_type=np.complex256, dimensions=3)
Np3DArrayComplex256 = np_array_pydantic_annotated_typing(data_type=np.clongdouble, dimensions=3)
Np3DArrayComplex128 = np_array_pydantic_annotated_typing(data_type=np.complex128, dimensions=3)
Np3DArrayComplex64 = np_array_pydantic_annotated_typing(data_type=np.complex64, dimensions=3)

Expand Down
4 changes: 2 additions & 2 deletions pydantic_numpy/typing/n_dimensional.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
NpNDArrayUint16 = np_array_pydantic_annotated_typing(data_type=np.uint16)
NpNDArrayUint8 = np_array_pydantic_annotated_typing(data_type=np.uint8)

NpNDArrayFp128 = np_array_pydantic_annotated_typing(data_type=np.float128)
NpNDArrayFp128 = np_array_pydantic_annotated_typing(data_type=np.longdouble)
NpNDArrayFp64 = np_array_pydantic_annotated_typing(data_type=np.float64)
NpNDArrayFp32 = np_array_pydantic_annotated_typing(data_type=np.float32)
NpNDArrayFp16 = np_array_pydantic_annotated_typing(data_type=np.float16)

NpNDArrayComplex256 = np_array_pydantic_annotated_typing(data_type=np.complex256)
NpNDArrayComplex256 = np_array_pydantic_annotated_typing(data_type=np.clongdouble)
NpNDArrayComplex128 = np_array_pydantic_annotated_typing(data_type=np.complex128)
NpNDArrayComplex64 = np_array_pydantic_annotated_typing(data_type=np.complex64)

Expand Down
4 changes: 2 additions & 2 deletions pydantic_numpy/typing/strict_data_type/i_dimensional.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
NpStrict1DArrayUint16 = np_array_pydantic_annotated_typing(data_type=np.uint16, dimensions=1, strict_data_typing=True)
NpStrict1DArrayUint8 = np_array_pydantic_annotated_typing(data_type=np.uint8, dimensions=1, strict_data_typing=True)

NpStrict1DArrayFp128 = np_array_pydantic_annotated_typing(data_type=np.float128, dimensions=1, strict_data_typing=True)
NpStrict1DArrayFp128 = np_array_pydantic_annotated_typing(data_type=np.longdouble, dimensions=1, strict_data_typing=True)
NpStrict1DArrayFp64 = np_array_pydantic_annotated_typing(data_type=np.float64, dimensions=1, strict_data_typing=True)
NpStrict1DArrayFp32 = np_array_pydantic_annotated_typing(data_type=np.float32, dimensions=1, strict_data_typing=True)
NpStrict1DArrayFp16 = np_array_pydantic_annotated_typing(data_type=np.float16, dimensions=1, strict_data_typing=True)

NpStrict1DArrayComplex256 = np_array_pydantic_annotated_typing(
data_type=np.complex256, dimensions=1, strict_data_typing=True
data_type=np.clongdouble, dimensions=1, strict_data_typing=True
)
NpStrict1DArrayComplex128 = np_array_pydantic_annotated_typing(
data_type=np.complex128, dimensions=1, strict_data_typing=True
Expand Down
6 changes: 4 additions & 2 deletions pydantic_numpy/typing/strict_data_type/ii_dimensional.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
NpStrict2DArrayUint16 = np_array_pydantic_annotated_typing(data_type=np.uint16, dimensions=2, strict_data_typing=True)
NpStrict2DArrayUint8 = np_array_pydantic_annotated_typing(data_type=np.uint8, dimensions=2, strict_data_typing=True)

NpStrict2DArrayFp128 = np_array_pydantic_annotated_typing(data_type=np.float128, dimensions=2, strict_data_typing=True)
NpStrict2DArrayFp128 = np_array_pydantic_annotated_typing(
data_type=np.longdouble, dimensions=2, strict_data_typing=True
)
NpStrict2DArrayFp64 = np_array_pydantic_annotated_typing(data_type=np.float64, dimensions=2, strict_data_typing=True)
NpStrict2DArrayFp32 = np_array_pydantic_annotated_typing(data_type=np.float32, dimensions=2, strict_data_typing=True)
NpStrict2DArrayFp16 = np_array_pydantic_annotated_typing(data_type=np.float16, dimensions=2, strict_data_typing=True)

NpStrict2DArrayComplex256 = np_array_pydantic_annotated_typing(
data_type=np.complex256, dimensions=2, strict_data_typing=True
data_type=np.clongdouble, dimensions=2, strict_data_typing=True
)
NpStrict2DArrayComplex128 = np_array_pydantic_annotated_typing(
data_type=np.complex128, dimensions=2, strict_data_typing=True
Expand Down
6 changes: 4 additions & 2 deletions pydantic_numpy/typing/strict_data_type/iii_dimensional.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
NpStrict3DArrayUint16 = np_array_pydantic_annotated_typing(data_type=np.uint16, dimensions=3, strict_data_typing=True)
NpStrict3DArrayUint8 = np_array_pydantic_annotated_typing(data_type=np.uint8, dimensions=3, strict_data_typing=True)

NpStrict3DArrayFp128 = np_array_pydantic_annotated_typing(data_type=np.float128, dimensions=3, strict_data_typing=True)
NpStrict3DArrayFp128 = np_array_pydantic_annotated_typing(
data_type=np.longdouble, dimensions=3, strict_data_typing=True
)
NpStrict3DArrayFp64 = np_array_pydantic_annotated_typing(data_type=np.float64, dimensions=3, strict_data_typing=True)
NpStrict3DArrayFp32 = np_array_pydantic_annotated_typing(data_type=np.float32, dimensions=3, strict_data_typing=True)
NpStrict3DArrayFp16 = np_array_pydantic_annotated_typing(data_type=np.float16, dimensions=3, strict_data_typing=True)

NpStrict3DArrayComplex256 = np_array_pydantic_annotated_typing(
data_type=np.complex256, dimensions=3, strict_data_typing=True
data_type=np.clongdouble, dimensions=3, strict_data_typing=True
)
NpStrict3DArrayComplex128 = np_array_pydantic_annotated_typing(
data_type=np.complex128, dimensions=3, strict_data_typing=True
Expand Down
4 changes: 2 additions & 2 deletions pydantic_numpy/typing/strict_data_type/n_dimensional.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
NpStrictNDArrayUint16 = np_array_pydantic_annotated_typing(data_type=np.uint16, strict_data_typing=True)
NpStrictNDArrayUint8 = np_array_pydantic_annotated_typing(data_type=np.uint8, strict_data_typing=True)

NpStrictNDArrayFp128 = np_array_pydantic_annotated_typing(data_type=np.float128, strict_data_typing=True)
NpStrictNDArrayFp128 = np_array_pydantic_annotated_typing(data_type=np.longdouble, strict_data_typing=True)
NpStrictNDArrayFp64 = np_array_pydantic_annotated_typing(data_type=np.float64, strict_data_typing=True)
NpStrictNDArrayFp32 = np_array_pydantic_annotated_typing(data_type=np.float32, strict_data_typing=True)
NpStrictNDArrayFp16 = np_array_pydantic_annotated_typing(data_type=np.float16, strict_data_typing=True)

NpStrictNDArrayComplex256 = np_array_pydantic_annotated_typing(data_type=np.complex256, strict_data_typing=True)
NpStrictNDArrayComplex256 = np_array_pydantic_annotated_typing(data_type=np.clongdouble, strict_data_typing=True)
NpStrictNDArrayComplex128 = np_array_pydantic_annotated_typing(data_type=np.complex128, strict_data_typing=True)
NpStrictNDArrayComplex64 = np_array_pydantic_annotated_typing(data_type=np.complex64, strict_data_typing=True)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pydantic_numpy"
version = "3.1.2"
version = "3.1.3"
description = "Pydantic Model integration of the NumPy array"
authors = ["Can H. Tartanoglu", "Christoph Heindl"]
maintainers = ["Can H. Tartanoglu <[email protected]>"]
Expand Down
10 changes: 10 additions & 0 deletions tests/helper/cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from functools import cache
from typing import Optional

import numpy as np
import numpy.typing as npt
from hypothesis import strategies as st
from hypothesis.extra.numpy import arrays
from pydantic import BaseModel


Expand All @@ -9,3 +14,8 @@ class ModelForTesting(BaseModel):
array_field: array_type_hint

return ModelForTesting


@cache
def cached_hyp_array(numpy_dtype: npt.DTypeLike, dimensions: Optional[int] = None, *, _axis_length: int = 1):
return arrays(numpy_dtype, tuple(_axis_length for _ in range(dimensions or 1)))
54 changes: 27 additions & 27 deletions tests/helper/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
np.uint32,
np.uint16,
np.uint8,
np.float128,
np.longdouble,
np.float64,
np.float32,
np.float16,
np.complex256,
np.clongdouble,
np.complex128,
np.complex64,
np.datetime64,
# np.datetime64,
np.timedelta64,
)

Expand All @@ -31,15 +31,15 @@
(np.uint32, Np1DArrayUint32, 1),
(np.uint16, Np1DArrayUint16, 1),
(np.uint8, Np1DArrayUint8, 1),
(np.float128, Np1DArrayFp128, 1),
(np.longdouble, Np1DArrayFp128, 1),
(np.float64, Np1DArrayFp64, 1),
(np.float32, Np1DArrayFp32, 1),
(np.float16, Np1DArrayFp16, 1),
(np.complex256, Np1DArrayComplex256, 1),
(np.clongdouble, Np1DArrayComplex256, 1),
(np.complex128, Np1DArrayComplex128, 1),
(np.complex64, Np1DArrayComplex64, 1),
(bool, Np1DArrayBool, 1),
(np.datetime64, Np1DArrayDatetime64, 1),
# (np.datetime64, Np1DArrayDatetime64, 1),
(np.timedelta64, Np1DArrayTimedelta64, 1),
]
data_type_2d_array_typing_dimensions = [
Expand All @@ -51,15 +51,15 @@
(np.uint32, Np2DArrayUint32, 2),
(np.uint16, Np2DArrayUint16, 2),
(np.uint8, Np2DArrayUint8, 2),
(np.float128, Np2DArrayFp128, 2),
(np.longdouble, Np2DArrayFp128, 2),
(np.float64, Np2DArrayFp64, 2),
(np.float32, Np2DArrayFp32, 2),
(np.float16, Np2DArrayFp16, 2),
(np.complex256, Np2DArrayComplex256, 2),
(np.clongdouble, Np2DArrayComplex256, 2),
(np.complex128, Np2DArrayComplex128, 2),
(np.complex64, Np2DArrayComplex64, 2),
(bool, Np2DArrayBool, 2),
(np.datetime64, Np2DArrayDatetime64, 2),
# (np.datetime64, Np2DArrayDatetime64, 2),
(np.timedelta64, Np2DArrayTimedelta64, 2),
]
data_type_3d_array_typing_dimensions = [
Expand All @@ -71,15 +71,15 @@
(np.uint32, Np3DArrayUint32, 3),
(np.uint16, Np3DArrayUint16, 3),
(np.uint8, Np3DArrayUint8, 3),
(np.float128, Np3DArrayFp128, 3),
(np.longdouble, Np3DArrayFp128, 3),
(np.float64, Np3DArrayFp64, 3),
(np.float32, Np3DArrayFp32, 3),
(np.float16, Np3DArrayFp16, 3),
(np.complex256, Np3DArrayComplex256, 3),
(np.clongdouble, Np3DArrayComplex256, 3),
(np.complex128, Np3DArrayComplex128, 3),
(np.complex64, Np3DArrayComplex64, 3),
(bool, Np3DArrayBool, 3),
(np.datetime64, Np3DArrayDatetime64, 3),
# (np.datetime64, Np3DArrayDatetime64, 3),
(np.timedelta64, Np3DArrayTimedelta64, 3),
]
data_type_nd_array_typing_dimensions = [
Expand All @@ -91,15 +91,15 @@
(np.uint32, NpNDArrayUint32, None),
(np.uint16, NpNDArrayUint16, None),
(np.uint8, NpNDArrayUint8, None),
(np.float128, NpNDArrayFp128, None),
(np.longdouble, NpNDArrayFp128, None),
(np.float64, NpNDArrayFp64, None),
(np.float32, NpNDArrayFp32, None),
(np.float16, NpNDArrayFp16, None),
(np.complex256, NpNDArrayComplex256, None),
(np.clongdouble, NpNDArrayComplex256, None),
(np.complex128, NpNDArrayComplex128, None),
(np.complex64, NpNDArrayComplex64, None),
(bool, NpNDArrayBool, None),
(np.datetime64, NpNDArrayDatetime64, None),
# (np.datetime64, NpNDArrayDatetime64, None),
(np.timedelta64, NpNDArrayTimedelta64, None),
]

Expand All @@ -120,15 +120,15 @@
(np.uint32, NpStrict1DArrayUint32, 1),
(np.uint16, NpStrict1DArrayUint16, 1),
(np.uint8, NpStrict1DArrayUint8, 1),
(np.float128, NpStrict1DArrayFp128, 1),
(np.longdouble, NpStrict1DArrayFp128, 1),
(np.float64, NpStrict1DArrayFp64, 1),
(np.float32, NpStrict1DArrayFp32, 1),
(np.float16, NpStrict1DArrayFp16, 1),
(np.complex256, NpStrict1DArrayComplex256, 1),
(np.clongdouble, NpStrict1DArrayComplex256, 1),
(np.complex128, NpStrict1DArrayComplex128, 1),
(np.complex64, NpStrict1DArrayComplex64, 1),
(bool, NpStrict1DArrayBool, 1),
(np.datetime64, NpStrict1DArrayDatetime64, 1),
# (np.datetime64, NpStrict1DArrayDatetime64, 1),
(np.timedelta64, NpStrict1DArrayTimedelta64, 1),
]
strict_data_type_2d_array_typing_dimensions = [
Expand All @@ -140,15 +140,15 @@
(np.uint32, NpStrict2DArrayUint32, 2),
(np.uint16, NpStrict2DArrayUint16, 2),
(np.uint8, NpStrict2DArrayUint8, 2),
(np.float128, NpStrict2DArrayFp128, 2),
(np.longdouble, NpStrict2DArrayFp128, 2),
(np.float64, NpStrict2DArrayFp64, 2),
(np.float32, NpStrict2DArrayFp32, 2),
(np.float16, NpStrict2DArrayFp16, 2),
(np.complex256, NpStrict2DArrayComplex256, 2),
(np.clongdouble, NpStrict2DArrayComplex256, 2),
(np.complex128, NpStrict2DArrayComplex128, 2),
(np.complex64, NpStrict2DArrayComplex64, 2),
(bool, NpStrict2DArrayBool, 2),
(np.datetime64, NpStrict2DArrayDatetime64, 2),
# (np.datetime64, NpStrict2DArrayDatetime64, 2),
(np.timedelta64, NpStrict2DArrayTimedelta64, 2),
]
strict_data_type_3d_array_typing_dimensions = [
Expand All @@ -160,15 +160,15 @@
(np.uint32, NpStrict3DArrayUint32, 3),
(np.uint16, NpStrict3DArrayUint16, 3),
(np.uint8, NpStrict3DArrayUint8, 3),
(np.float128, NpStrict3DArrayFp128, 3),
(np.longdouble, NpStrict3DArrayFp128, 3),
(np.float64, NpStrict3DArrayFp64, 3),
(np.float32, NpStrict3DArrayFp32, 3),
(np.float16, NpStrict3DArrayFp16, 3),
(np.complex256, NpStrict3DArrayComplex256, 3),
(np.clongdouble, NpStrict3DArrayComplex256, 3),
(np.complex128, NpStrict3DArrayComplex128, 3),
(np.complex64, NpStrict3DArrayComplex64, 3),
(bool, NpStrict3DArrayBool, 3),
(np.datetime64, NpStrict3DArrayDatetime64, 3),
# (np.datetime64, NpStrict3DArrayDatetime64, 3),
(np.timedelta64, NpStrict3DArrayTimedelta64, 3),
]
strict_data_type_nd_array_typing_dimensions = [
Expand All @@ -180,15 +180,15 @@
(np.uint32, NpStrictNDArrayUint32, None),
(np.uint16, NpStrictNDArrayUint16, None),
(np.uint8, NpStrictNDArrayUint8, None),
(np.float128, NpStrictNDArrayFp128, None),
(np.longdouble, NpStrictNDArrayFp128, None),
(np.float64, NpStrictNDArrayFp64, None),
(np.float32, NpStrictNDArrayFp32, None),
(np.float16, NpStrictNDArrayFp16, None),
(np.complex256, NpStrictNDArrayComplex256, None),
(np.clongdouble, NpStrictNDArrayComplex256, None),
(np.complex128, NpStrictNDArrayComplex128, None),
(np.complex64, NpStrictNDArrayComplex64, None),
(bool, NpStrictNDArrayBool, None),
(np.datetime64, NpStrictNDArrayDatetime64, None),
# (np.datetime64, NpStrictNDArrayDatetime64, None),
(np.timedelta64, NpStrictNDArrayTimedelta64, None),
]

Expand Down
Loading

0 comments on commit 3dd1d6a

Please sign in to comment.