Am 2013-07-16 11:41, schrieb Cédric Krier:
> On 16/07/13 12:12 +0300, Giedrius Slavinskas wrote:
>> > 2013/7/15 Cédric Krier <cedric.kr...@b2ck.com>
>>> > > On 15/07/13 10:25 +0300, Giedrius Slavinskas wrote:
>>> > > So let's introduce it.
>>> > >
>>> > >
>>> > > class Measure(namedtuple('Measure', ['quantity', 'unit'])):
>>> > >     __slots__ = ()
>>> > >
>>> > >     def convert_to(self, uom, round=True):
>>> > >         Uom = Pool().get('product.uom')
>>> > >         return Measure(Uom.compute_qty(self.unit, self.quantity, uom,
>>> > >                 round=round), uom)
>>> > >
>>> > >
>>> > > Which will make:
>>> > >
>>> > >     Measure(1000, gr).convert_to(kg) == Measure(1, kg)
>> > 
>> > 
>> > I suggest more intuitive interface/naming. Here is just the idea,
>> > nothing mean to work.
>> > 
>> > class Quantity(namedtuple('Quantity', ['units', 'uom'])):
> I don't understand why using "units" ? For me, it sounds wrong.
> unit is what is called uom == Unit of Measure.
>
> Quantity sounds like it is a scalar, when measure sounds better
> especially because we already use "Unit of Measure".
nitpicking:

uom should be "unit of measurement".

"measure" is something different than "measurement", see [1], I would
associate it with set-theory and calculus.

"quantity" seems to be the correct term (according to wikipedia). Thus I
propose:

class Quantity(namedtuple('Quantity', ['amount', 'uom'])):

boost_units c++-library[2] also uses "quantity" for dimensionful numbers, but 
I'm not sure if this should be given much weight ;)

mfg
  Robert

[1] http://en.wikipedia.org/wiki/Measure
[2] http://www.boost.org/doc/libs/1_54_0/doc/html/boost/units/quantity.html

Reply via email to