On 16/07/13 12:17 +0200, Robert Schöftner wrote:
> 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 <[email protected]>
> >>> > > 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.

Yes probably I'm confuse with the french.
But it doesn't seem to be incorrect:
https://en.wikipedia.org/wiki/Unit_of_measure

> "quantity" seems to be the correct term (according to wikipedia). Thus I
> propose:
> 
> class Quantity(namedtuple('Quantity', ['amount', 'uom'])):

For me, the definition is not so clear about what is the quantity. Is it
the couple or the part in front of the unit?

Anyway, I'm in favor of consistency and as quantity is already used in
many places. It will be confusing to introduce a new Object with the
same name for something different.

So for me, this new object must be named to describe the result of a
measurement (and not generate collisions).

-- 
Cédric Krier

B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email/Jabber: [email protected]
Website: http://www.b2ck.com/

Attachment: pgpAf4awHSlev.pgp
Description: PGP signature

Reply via email to