type-checking support in Python?

dg.google.groups at thesamovar.net dg.google.groups at thesamovar.net
Tue Oct 7 21:48:04 CEST 2008

I also wrote a units package which I'm using for a project of my own
(a spiking neural network simulator package called 'Brian'), released
separately as a package called Piquant which you can get at


I'm also looking for people to help improve it (get in touch!). The
way the package works is to have a Quantity class derived from float,
with extra operations. One thing that is different from the other
packages out there (and the reason I went to the effort of writing my
own package rather than using unum or scalar) is that we also have a
QuantityArray or qarray class that derives from numpy.ndarray. There
are at the moment two supported types of qarray, with homogeneous
units (one unit for the whole array), and heterogeneous units
(different unit for each item in the array). At the moment the
heterogeneous units implementation is horrible and very slow, but I
have a plan for a nicer version at some point (based on numpy's
broadcasting rules, so allowing you to have one unit for each row or
each column in a matrix for example).

Actually I think it would be a really good idea for someone at some
point to make a standardised system for units and add it to numpy/
scipy. I'd love to do it myself, but at the moment I have grant
applications, papers to finish, etc... :-(


Sebastien Binet wrote:
> hi,
> On Oct 7, 3:24�am, Bas <wegw... at gmail.com> wrote:
> > I have heard about some python package which overloads numbers and
> > calculations to include units (quick google found unum, not sure if
> > that is the only one). I guess that unless you are dealing with life-
> > critical equipment or are using extreme programming, this is overkill
> > (but I guess python is not really the right language for that anyway,
> > imagine a garbage collection just when you want to launch your
> > shuttle).
> FWIW, the python papers volume 3 issue 1 is mentionning another
> package, 'scalar':
>  http://archive.pythonpapers.org/ThePythonPapersVolume3Issue1.pdf
>  http://russp.us/scalar.htm
> cheers,
> sebastien.

More information about the Python-list mailing list