caput.util.typeutils#

memdata data type utilities.

This internal module contains utilities to help deal with incompatibilities between numpy, mpi4py, and/or HDF5 data types.

This is mostly just conversions between numpy “U” unicode strings and “S” bytestrings.

Functions#

bytes_to_unicode(→ Any)

Ensure that a string (or collection of) are unicode.

check_byteorder(→ bool)

Test if a native byteorder; if not, check if byteorder matches the architecture.

check_unicode(→ numpy.typing.ArrayLike[Any])

Test if dataset contains unicode so we can raise an appropriate error.

dtype_to_bytestring(→ numpy.dtype)

Convert unicode strings in a dtype to byte strings.

dtype_to_unicode(→ numpy.dtype)

Convert byte strings in a dtype to unicode.

ensure_bytestring(→ numpy.typing.ArrayLike[Any])

If needed convert the array to contain bytestrings not unicode.

ensure_native_byteorder(→ numpy.typing.ArrayLike[Any])

If architecture and arr byteorder are the same, ensure byteorder is native.

ensure_unicode(→ numpy.typing.ArrayLike[Any])

If needed convert the array to contain unicode strings not bytestrings.

has_bytestring(→ bool)

Test if data type contains any unicode fields.

has_kind(→ bool)

Test if a numpy datatype has any fields of a specified type.

has_matching_byteorder(→ bool)

Test if byteorder marches the architecture.

has_unicode(→ bool)

Test if data type contains any unicode fields.