Skip to content

Commit 20beeaa

Browse files
author
Darren Dale
committed
use UncertainQuantity for constants, where appropriate
1 parent 635c0b4 commit 20beeaa

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

quantities/constants/constants.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44

55
import math as _math
66
from .codata import physical_constants as _pc
7-
from quantities.quantity import Quantity
7+
from quantities.quantity import Quantity, UncertainQuantity
88

99
def _cd(name):
1010
entry = _pc[name]
11-
q = Quantity(entry['value'], entry['units'], 'd')
12-
q.precision = entry['precision']
13-
return q
11+
if entry['precision']:
12+
return UncertainQuantity(
13+
entry['value'], entry['units'], entry['precision']
14+
)
15+
else:
16+
return Quantity(entry['value'], entry['units'])
1417

1518
#mathematical constants
1619
pi = _math.pi

0 commit comments

Comments
 (0)