Skip to content

Commit 7c07771

Browse files
Natasha ChetwyndNatasha Chetwynd
authored andcommitted
added in rounding function
1 parent cf6ed1e commit 7c07771

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

codonPython/suppression.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
def round_value(valuein: int, base = 5)->int:
2+
"""
3+
Round values to nearest 5
4+
5+
This function will round metric values to the nearest 5.
6+
7+
Parameters
8+
----------
9+
valuein : int
10+
Metric value
11+
base :
12+
number which we are rounding to i.e. to the nearest 5
13+
14+
Returns
15+
----------
16+
out : int
17+
Rounded value
18+
19+
Examples
20+
----------
21+
>>> round_value(8)
22+
'10'
23+
>>> round_value(20)
24+
'20'
25+
>>> round_value(46)
26+
'45'
27+
"""
28+
29+
return base * round(valuein/base)
30+
131
def suppress_value(valuein: int, rc:str = '*')->str:
232
"""
333
Suppress values less than or equal to 7
@@ -33,4 +63,5 @@ def suppress_value(valuein: int, rc:str = '*')->str:
3363
valueout = rc
3464
if valuein > 7:
3565
valueout = str(valuein)
36-
return valueout
66+
return valueout
67+

0 commit comments

Comments
 (0)