Skip to content

Commit dc6e773

Browse files
authored
Add stone unit of measuring weight (#5730)
* Add stone unit of measuring weight And some tests in the docs using an external calculator. Not yet tested if they pass. * Fix rounding descrepencies in doctests to pass tests
1 parent 74f4967 commit dc6e773

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

Diff for: conversions/weight_conversion.py

+27-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
__author__ = "Anubhav Solanki"
55
__license__ = "MIT"
6-
__version__ = "1.0.0"
6+
__version__ = "1.1.0"
77
__maintainer__ = "Anubhav Solanki"
88
__email__ = "[email protected]"
99
@@ -27,6 +27,7 @@
2727
-> Wikipedia reference: https://en.wikipedia.org/wiki/Ounce
2828
-> Wikipedia reference: https://en.wikipedia.org/wiki/Fineness#Karat
2929
-> Wikipedia reference: https://en.wikipedia.org/wiki/Dalton_(unit)
30+
-> Wikipedia reference: https://en.wikipedia.org/wiki/Stone_(unit)
3031
"""
3132

3233
KILOGRAM_CHART: dict[str, float] = {
@@ -37,6 +38,7 @@
3738
"long-ton": 0.0009842073,
3839
"short-ton": 0.0011023122,
3940
"pound": 2.2046244202,
41+
"stone": 0.1574731728,
4042
"ounce": 35.273990723,
4143
"carrat": 5000,
4244
"atomic-mass-unit": 6.022136652e26,
@@ -50,6 +52,7 @@
5052
"long-ton": 1016.04608,
5153
"short-ton": 907.184,
5254
"pound": 0.453592,
55+
"stone": 6.35029,
5356
"ounce": 0.0283495,
5457
"carrat": 0.0002,
5558
"atomic-mass-unit": 1.660540199e-27,
@@ -67,6 +70,7 @@ def weight_conversion(from_type: str, to_type: str, value: float) -> float:
6770
"long-ton" : 0.0009842073,
6871
"short-ton" : 0.0011023122,
6972
"pound" : 2.2046244202,
73+
"stone": 0.1574731728,
7074
"ounce" : 35.273990723,
7175
"carrat" : 5000,
7276
"atomic-mass-unit" : 6.022136652E+26
@@ -85,6 +89,8 @@ def weight_conversion(from_type: str, to_type: str, value: float) -> float:
8589
0.0011023122
8690
>>> weight_conversion("kilogram","pound",4)
8791
8.8184976808
92+
>>> weight_conversion("kilogram","stone",5)
93+
0.7873658640000001
8894
>>> weight_conversion("kilogram","ounce",4)
8995
141.095962892
9096
>>> weight_conversion("kilogram","carrat",3)
@@ -105,6 +111,8 @@ def weight_conversion(from_type: str, to_type: str, value: float) -> float:
105111
3.3069366000000003e-06
106112
>>> weight_conversion("gram","pound",3)
107113
0.0066138732606
114+
>>> weight_conversion("gram","stone",4)
115+
0.0006298926912000001
108116
>>> weight_conversion("gram","ounce",1)
109117
0.035273990723
110118
>>> weight_conversion("gram","carrat",2)
@@ -211,6 +219,24 @@ def weight_conversion(from_type: str, to_type: str, value: float) -> float:
211219
2267.96
212220
>>> weight_conversion("pound","atomic-mass-unit",4)
213221
1.0926372033015936e+27
222+
>>> weight_conversion("stone","kilogram",5)
223+
31.751450000000002
224+
>>> weight_conversion("stone","gram",2)
225+
12700.58
226+
>>> weight_conversion("stone","milligram",3)
227+
19050870.0
228+
>>> weight_conversion("stone","metric-ton",3)
229+
0.01905087
230+
>>> weight_conversion("stone","long-ton",3)
231+
0.018750005325351003
232+
>>> weight_conversion("stone","short-ton",3)
233+
0.021000006421614002
234+
>>> weight_conversion("stone","pound",2)
235+
28.00000881870372
236+
>>> weight_conversion("stone","ounce",1)
237+
224.00007054835967
238+
>>> weight_conversion("stone","carrat",2)
239+
63502.9
214240
>>> weight_conversion("ounce","kilogram",3)
215241
0.0850485
216242
>>> weight_conversion("ounce","gram",3)

0 commit comments

Comments
 (0)