<div dir="ltr"><div>Hi all,</div><div><br></div><div>This might be useful for us. Both numtraits and traitlets are pure python packages that would not be difficult to add as dependencies.</div><div><br></div><div>-Nathan</div><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Thomas Robitaille</b> <span dir="ltr"><<a href="mailto:thomas.robitaille@gmail.com">thomas.robitaille@gmail.com</a>></span><br>Date: Wed, Sep 23, 2015 at 11:39 AM<br>Subject: [Numpy-discussion] ANN: numtraits v0.2<br>To: "Discussions about using IPython. <a href="http://ipython.org">http://ipython.org</a>" <<a href="mailto:ipython-user@scipy.org">ipython-user@scipy.org</a>>, Discussion of Numerical Python <<a href="mailto:numpy-discussion@scipy.org">numpy-discussion@scipy.org</a>>, SciPy Users List <<a href="mailto:scipy-user@scipy.org">scipy-user@scipy.org</a>><br><br><br>Hi everyone,<br>
<br>
We have released a small experimental package called numtraits that<br>
builds on top of the traitlets package and provides a NumericalTrait<br>
class that can be used to validate properties such as:<br>
<br>
* number of dimension (for arrays)<br>
* shape (for arrays)<br>
* domain (e.g. positive, negative, range of values)<br>
* units (with support for astropy.units, pint, and quantities)<br>
<br>
The idea is to be able to write a class like:<br>
<br>
    class Sphere(HasTraits):<br>
<br>
        radius = NumericalTrait(domain='strictly-positive', ndim=0)<br>
        position = NumericalTrait(shape=(3,))<br>
<br>
and all the validation will then be done automatically when the user<br>
sets 'radius' or 'position'.<br>
<br>
In addition, tuples and lists can get automatically converted to<br>
arrays, and default values can be specified. You can read more about<br>
the package and see examples of it in use here:<br>
<br>
  <a href="https://github.com/astrofrog/numtraits" rel="noreferrer" target="_blank">https://github.com/astrofrog/numtraits</a><br>
<br>
and it can be easily installed with<br>
<br>
  pip install numtraits<br>
<br>
The package supports both Python 3.3+ and Legacy Python (2.7) :)<br>
<br>
At this point, we would be very interested in feedback - the package<br>
is still very young and we can still change the API if needed. Please<br>
open issues with suggestions!<br>
<br>
Cheers,<br>
<br>
Tom and Francesco<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="https://mail.scipy.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div><br></div>