-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.py
35 lines (25 loc) · 893 Bytes
/
helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import math
# this function originates from my AMULATOR_offline
# https://github.com/LangeTo/AMULATOR_offline/blob/main/couplex_functions.py
def add_pos_par(well, doubles, df):
doubles = doubles + df[df["Well"] == well]["Count categories"].tolist()[0]
return doubles
# https://www.knowledgehut.com/blog/programming/python-rounding-numbers
def round_up(n, decimals=0):
"""
Round up a number to a specified number of decimal places.
Parameters:
n (float): The number to be rounded up.
decimals (int): The number of decimal places to round up to. Default is 0.
Returns:
float: The number rounded up to the specified number of decimal places.
Example:
>>> round_up(2.123, 2)
2.13
>>> round_up(2.125, 2)
2.13
>>> round_up(2.125, 0)
3.0
"""
multiplier = 10**decimals
return math.ceil(n * multiplier) / multiplier