autoprotocol/autoprotocol-python

TODO: Change Unit() to support compound units

bmiles opened this issue · 2 comments

It is often the case that a user may want to work in terms of concentration say µg/mL. Currently Unit() does not support dimensional division nor multiplication.

Some ideas have been batted around to integrate Pint https://pint.readthedocs.org/en/0.6/ into the Autoprotocol-python library to build out the Unit() class with this support. It would be ideal to not introduce breaking changes.

It would be great to have some discussion about this here.

One of the main reasons I didn't build it that way in the first place is that the autoprotocol specification doesn't have a way to encode arbitrary units (see http://autoprotocol.org/specification/#b-conventions for the supported units). So e.g. if you express a quantity in foot-meters^2 per fortnight there will have to be some translation into a supported unit such as microliter/second. Also, there are plenty of dimensions which are simply not present in autoprotocol; for example, there is no autoprotocol instruction that takes a length^-1 unit of any kind. It might be useful internally to the autoprotocol-python library to work with those units, though.

Another reason I avoided Pint and its brethren initially was to minimize dependencies. That may be less of a concern now, though.

A note that we can get around the issue of arbitrary units with Pint, as there's the concept of a UnitRegistry (see https://pint.readthedocs.org/en/0.6/defining.html#defining), which allows us to define a supported list of units (and their corresponding conversions).
It is true that there may still be other integration issues, but from what I've seen, it should be possible to integrate with Pint while maintaining backwards compatibility. While it may require some work, the features added will be generally useful.