From ecf4bd7075a16337fc133f8adae6fbcbc7194325 Mon Sep 17 00:00:00 2001 From: James Turk Date: Tue, 24 Mar 2015 17:01:24 -0400 Subject: [PATCH] stop using __class__ --- bia/units.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bia/units.py b/bia/units.py index d98d777..9beded3 100644 --- a/bia/units.py +++ b/bia/units.py @@ -81,9 +81,9 @@ class UnitValue(object): def as_unit(self, unit): unit = Unit.unit(unit) if self.unit == unit: - return self.__class__(self.scalar, self.unit) + return UnitValue(self.scalar, self.unit) - return self.__class__(self.scalar * self.unit.conversion_factor(unit), unit) + return UnitValue(self.scalar * self.unit.conversion_factor(unit), unit) def __str__(self): return '{}{}'.format(self.scalar, self.unit) @@ -100,25 +100,25 @@ class UnitValue(object): def __add__(self, other): if self.unit != other.unit: other = other.as_unit(self.unit) - return self.__class__(self.scalar + other.scalar, self.unit) + return UnitValue(self.scalar + other.scalar, self.unit) def __sub__(self, other): if self.unit != other.unit: other = other.as_unit(self.unit) - return self.__class__(self.scalar - other.scalar, self.unit) + return UnitValue(self.scalar - other.scalar, self.unit) def __mul__(self, other): if isinstance(other, UnitValue): if self.unit != other.unit: other = other.as_unit(self.unit) - return self.__class__(self.scalar * other.scalar, self.unit * other.unit) + return UnitValue(self.scalar * other.scalar, self.unit * other.unit) else: - return self.__class__(self.scalar * other, self.unit) + return UnitValue(self.scalar * other, self.unit) def __div__(self, other): if isinstance(other, UnitValue): if self.unit != other.unit: other = other.as_unit(self.unit) - return self.__class__(self.scalar / other.scalar, self.unit / other.unit) + return UnitValue(self.scalar / other.scalar, self.unit / other.unit) else: - return self.__class__(self.scalar / other, self.unit) + return UnitValue(self.scalar / other, self.unit)