Skip to main content

Serializable schema using traits

Project description

https://travis-ci.org/mivade/traitschema.svg?branch=master https://codecov.io/gh/mivade/traitschema/branch/master/graph/badge.svg https://img.shields.io/github/release/mivade/traitschema.svg

Create serializable, type-checked schema using traits and Numpy. A typical use case involves saving several Numpy arrays of varying shape and type.

Defining schema

In order to be able to properly serialize data, non-scalar traits should be declared as a traits.api.Array type. Example:

import numpy as np
from traits.api import Array, String
from traitschema import Schema

class NamedMatrix(Schema):
    name = String()
    data = Array(dtype=np.float64)

matrix = NamedMatrix(name="name", data=np.random.random((8, 8)))

Saving and loading

Data can be stored in the following formats:

  • HDF5 via h5py

  • JSON via the standard library json module

  • Numpy npz format

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

traitschema-1.1.1-py2.py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page