[EMAIL PROTECTED] wrote:

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
sourceforge:

http://sourceforge.net/projects/piquant

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).

I have a unit system module (unity) in progress as well (it's working but it's as yet unreleased), but which takes a different approach which I think has more promise. Instead of having multiple united types derived from different fundamental types, it has its own type Quantity which takes two arguments: the amount and the units (which are further data structures). That way, the amount and the units are kept separately and the unit system doesn't know anything specific about the amount and only deals with the unit system. Operations between quantities enforce the type system (either combining the units for operations like multiplication, or requiring that they be compatible for operations like addition or comparison), and simply perform the appropriate operations on the amount without enforcing any type. This allows you to have united operations on integers, floating point numbers, decimals, vectors, matrices, quaternions -- whatever values you may want to support units.

Mine is more of a dimensional analysis tool (as well as a general unit converter) since it allows you to define a basis of units, then define units within that basis and manipulate them -- thus it remembers the definitions of all the units it has encountered. You can define whole new unit systems (e.g., c.g.s. vs. SI) and have them all relate to each other, or even define brand new unit systems (e.g., man-day-widgets for questions like, "If it takes one man three days to make two widgets, how many widgets can five men make in two weeks?").

--
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
 San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
  Those who forget the past are condemned to repeat it.
   -- George Santayana
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to