diff options
author | German M. Bravo <german.mb@deipi.com> | 2013-08-13 19:03:54 -0500 |
---|---|---|
committer | German M. Bravo <german.mb@deipi.com> | 2013-08-13 19:03:54 -0500 |
commit | 3f621f32d2a25bbc51a12b59aa2261e068b3e8de (patch) | |
tree | 8e9449678dc21f20663b6e34b8e00d03ffbf7924 | |
parent | 74574e7b2fa23e7ffe7952463b27ea0b60df74fe (diff) | |
download | pyscss-3f621f32d2a25bbc51a12b59aa2261e068b3e8de.tar.gz |
Special case for zero (0) with no units
-rw-r--r-- | scss/types.py | 10 |
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) |