bump version, docs, nocover error checking

This commit is contained in:
sneakers-the-rat 2024-09-03 17:02:50 -07:00
parent 56c5b9ac79
commit 9d31ecf385
Signed by untrusted user who does not match committer: jonny
GPG key ID: 6DCB96EF1E4D232D
3 changed files with 22 additions and 2 deletions

View file

@ -4,6 +4,11 @@
### 1.5.* ### 1.5.*
#### 1.5.2 - 24-09-03 - `datetime` support for HDF5
- [#15](https://github.com/p2p-ld/numpydantic/pull/15): Datetimes are supported as
dtype annotations for HDF5 arrays when encoded as `S32` isoformatted byte strings
#### 1.5.1 - 24-09-03 - Fix revalidation with proxy classes #### 1.5.1 - 24-09-03 - Fix revalidation with proxy classes
Bugfix: Bugfix:

View file

@ -1,6 +1,6 @@
[project] [project]
name = "numpydantic" name = "numpydantic"
version = "1.5.1" version = "1.5.2"
description = "Type and shape validation and serialization for arbitrary array types in pydantic models" description = "Type and shape validation and serialization for arbitrary array types 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"},

View file

@ -22,6 +22,21 @@ Interfaces for HDF5 Datasets
To have direct access to the hdf5 dataset, use the To have direct access to the hdf5 dataset, use the
:meth:`.H5Proxy.open` method. :meth:`.H5Proxy.open` method.
Datetimes
---------
Datetimes are supported as a dtype annotation, but currently they must be stored
as ``S32`` isoformatted byte strings (timezones optional) like:
.. code-block:: python
import h5py
from datetime import datetime
import numpy as np
data = np.array([datetime.now().isoformat().encode('utf-8')], dtype="S32")
h5f = h5py.File('test.hdf5', 'w')
h5f.create_dataset('data', data=data)
""" """
import sys import sys
@ -311,7 +326,7 @@ class H5Interface(Interface):
return np.datetime64 return np.datetime64
else: else:
return str return str
except (AttributeError, ValueError, TypeError): except (AttributeError, ValueError, TypeError): # pragma: no cover
return str return str
else: else:
return array.dtype return array.dtype