summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerman M. Bravo <german.mb@deipi.com>2013-08-13 19:03:54 -0500
committerGerman M. Bravo <german.mb@deipi.com>2013-08-13 19:03:54 -0500
commit3f621f32d2a25bbc51a12b59aa2261e068b3e8de (patch)
tree8e9449678dc21f20663b6e34b8e00d03ffbf7924
parent74574e7b2fa23e7ffe7952463b27ea0b60df74fe (diff)
downloadpyscss-3f621f32d2a25bbc51a12b59aa2261e068b3e8de.tar.gz
Special case for zero (0) with no units
-rw-r--r--scss/types.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/scss/types.py b/scss/types.py
index 47cf728..4f0984b 100644
--- a/scss/types.py
+++ b/scss/types.py
@@ -218,8 +218,9 @@ class Number(Value):
left = self.to_base_units()
right = other.to_base_units()
- if left.unit_numer != right.unit_numer or left.unit_denom != right.unit_denom:
- raise ValueError("Can't reconcile units: %r and %r" % (self, other))
+ if (left.value != 0 or left.unit_numer or left.unit_denom) and (right.value != 0 or right.unit_numer or right.unit_denom):
+ if left.unit_numer != right.unit_numer or left.unit_denom != right.unit_denom:
+ raise ValueError("Can't reconcile units: %r and %r" % (self, other))
return op(round(left.value, 5), round(right.value, 5))
@@ -281,8 +282,9 @@ class Number(Value):
left = self.to_base_units()
right = other.to_base_units()
- if left.unit_numer != right.unit_numer or left.unit_denom != right.unit_denom:
- raise ValueError("Can't reconcile units: %r and %r" % (self, other))
+ if (left.value != 0 or left.unit_numer or left.unit_denom) and (right.value != 0 or right.unit_numer or right.unit_denom):
+ if left.unit_numer != right.unit_numer or left.unit_denom != right.unit_denom:
+ raise ValueError("Can't reconcile units: %r and %r" % (self, other))
new_amount = op(left.value, right.value)