2024-05-09 04:29:13 +00:00
|
|
|
import numpy as np
|
|
|
|
import pytest
|
|
|
|
|
2024-10-11 01:58:05 +00:00
|
|
|
from numpydantic.testing.cases import NumpyCase
|
2024-05-09 04:29:13 +00:00
|
|
|
|
2024-09-23 20:28:38 +00:00
|
|
|
pytestmark = pytest.mark.numpy
|
|
|
|
|
2024-05-09 04:29:13 +00:00
|
|
|
|
2024-09-23 20:28:38 +00:00
|
|
|
@pytest.mark.shape
|
2024-05-09 04:29:13 +00:00
|
|
|
def test_numpy_shape(shape_cases):
|
2024-10-11 01:58:05 +00:00
|
|
|
shape_cases.interface = NumpyCase
|
|
|
|
shape_cases.validate_case()
|
2024-05-09 04:29:13 +00:00
|
|
|
|
|
|
|
|
2024-09-23 20:28:38 +00:00
|
|
|
@pytest.mark.dtype
|
2024-05-09 04:29:13 +00:00
|
|
|
def test_numpy_dtype(dtype_cases):
|
2024-10-11 01:58:05 +00:00
|
|
|
dtype_cases.interface = NumpyCase
|
|
|
|
dtype_cases.validate_case()
|
2024-05-15 03:18:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_numpy_coercion(model_blank):
|
|
|
|
"""If no other interface matches, we try and coerce to a numpy array"""
|
|
|
|
instance = model_blank(array=[1, 2, 3])
|
|
|
|
assert isinstance(instance.array, np.ndarray)
|