Skip to content

Commit 07a74d4

Browse files
author
Dylan
committed
update 0.1.5
1 parent 659e79d commit 07a74d4

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = unit_parse
3-
version = 0.1.4
3+
version = 0.1.5
44
description = Parse units from strings. From mess to order!
55
long_description = file: README.md
66
long_description_content_type = text/markdown

src/unit_parse/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ def quantity_difference(quantity1: Quantity, quantity2: Quantity) -> Union[int,
3232
quantity1.dimensionality != quantity2.dimensionality:
3333
return 1
3434

35+
if quantity2.to_base_units().m == 0: # avoid divide by zero error
36+
if quantity1.to_base_units().m == 0:
37+
return True
38+
return False
39+
3540
return abs((quantity1 - quantity2) / quantity2)
3641

3742

0 commit comments

Comments
 (0)