mirror of
https://github.com/p2p-ld/numpydantic.git
synced 2024-11-10 00:34:29 +00:00
v1.2.1 - fix dtypeerror inheritance
This commit is contained in:
parent
3544ce2bdc
commit
a45967818c
3 changed files with 10 additions and 3 deletions
|
@ -2,6 +2,13 @@
|
||||||
|
|
||||||
## 1.*
|
## 1.*
|
||||||
|
|
||||||
|
### 1.2.1 - 24-06-27
|
||||||
|
|
||||||
|
Fix a minor bug where {class}`~numpydantic.exceptions.DtypeError` would not cause
|
||||||
|
pydantic to throw a {class}`pydantic.ValidationError` because custom validator functions
|
||||||
|
need to raise either `AssertionError` or `ValueError` - made `DtypeError` also
|
||||||
|
inherit from `ValueError` because that is also technically true.
|
||||||
|
|
||||||
### 1.2.0 - 24-06-13 - Shape ranges
|
### 1.2.0 - 24-06-13 - Shape ranges
|
||||||
|
|
||||||
- Add ability to specify shapes as ranges - see [shape ranges](shape-ranges)
|
- Add ability to specify shapes as ranges - see [shape ranges](shape-ranges)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[project]
|
[project]
|
||||||
name = "numpydantic"
|
name = "numpydantic"
|
||||||
version = "1.2.0"
|
version = "1.2.1"
|
||||||
description = "Type and shape validation and serialization for numpy arrays in pydantic models"
|
description = "Type and shape validation and serialization for numpy arrays in pydantic models"
|
||||||
authors = [
|
authors = [
|
||||||
{name = "sneakers-the-rat", email = "sneakers-the-rat@protonmail.com"},
|
{name = "sneakers-the-rat", email = "sneakers-the-rat@protonmail.com"},
|
||||||
|
|
|
@ -33,7 +33,7 @@ def test_ndarray_type():
|
||||||
with pytest.raises(ValidationError):
|
with pytest.raises(ValidationError):
|
||||||
instance = Model(array=np.zeros((4, 6)))
|
instance = Model(array=np.zeros((4, 6)))
|
||||||
|
|
||||||
with pytest.raises(DtypeError):
|
with pytest.raises(ValidationError):
|
||||||
instance = Model(array=np.ones((2, 3), dtype=bool))
|
instance = Model(array=np.ones((2, 3), dtype=bool))
|
||||||
|
|
||||||
instance = Model(array=np.zeros((2, 3)), array_any=np.ones((3, 4, 5)))
|
instance = Model(array=np.zeros((2, 3)), array_any=np.ones((3, 4, 5)))
|
||||||
|
@ -112,7 +112,7 @@ def test_ndarray_coercion():
|
||||||
|
|
||||||
amod = Model(array=[1, 2, 3, 4.5])
|
amod = Model(array=[1, 2, 3, 4.5])
|
||||||
assert np.allclose(amod.array, np.array([1, 2, 3, 4.5]))
|
assert np.allclose(amod.array, np.array([1, 2, 3, 4.5]))
|
||||||
with pytest.raises(DtypeError):
|
with pytest.raises(ValidationError):
|
||||||
amod = Model(array=["a", "b", "c"])
|
amod = Model(array=["a", "b", "c"])
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue