Hi all,

This might be useful for us. Both numtraits and traitlets are pure python packages that would not be difficult to add as dependencies.


---------- Forwarded message ----------
From: Thomas Robitaille <thomas.robitaille@gmail.com>
Date: Wed, Sep 23, 2015 at 11:39 AM
Subject: [Numpy-discussion] ANN: numtraits v0.2
To: "Discussions about using IPython. http://ipython.org" <ipython-user@scipy.org>, Discussion of Numerical Python <numpy-discussion@scipy.org>, SciPy Users List <scipy-user@scipy.org>

Hi everyone,

We have released a small experimental package called numtraits that
builds on top of the traitlets package and provides a NumericalTrait
class that can be used to validate properties such as:

* number of dimension (for arrays)
* shape (for arrays)
* domain (e.g. positive, negative, range of values)
* units (with support for astropy.units, pint, and quantities)

The idea is to be able to write a class like:

    class Sphere(HasTraits):

        radius = NumericalTrait(domain='strictly-positive', ndim=0)
        position = NumericalTrait(shape=(3,))

and all the validation will then be done automatically when the user
sets 'radius' or 'position'.

In addition, tuples and lists can get automatically converted to
arrays, and default values can be specified. You can read more about
the package and see examples of it in use here:


and it can be easily installed with

  pip install numtraits

The package supports both Python 3.3+ and Legacy Python (2.7) :)

At this point, we would be very interested in feedback - the package
is still very young and we can still change the API if needed. Please
open issues with suggestions!


Tom and Francesco
NumPy-Discussion mailing list