aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-04-11 14:05:57 +0300
committerFrederick Muriuki Muriithi2022-04-11 14:05:57 +0300
commitec30480a7121956b0ccde353180d1656fce866af (patch)
tree83ef572bfddf1a308b1fcfc9df31a53e40b9088e
parent7bd0a4c58dc1d238027c593b24c2d783e88b8f49 (diff)
downloadgn-uploader-ec30480a7121956b0ccde353180d1656fce866af.tar.gz
Implement MVP for valid_value functions
* Implement the minimum viable functions for the average and standard error `valid_value` functions.
-rw-r--r--quality_control/average.py7
-rw-r--r--quality_control/standard_error.py7
2 files changed, 12 insertions, 2 deletions
diff --git a/quality_control/average.py b/quality_control/average.py
index 6ed0da7..1a7bf5f 100644
--- a/quality_control/average.py
+++ b/quality_control/average.py
@@ -4,4 +4,9 @@ import re
from .errors import InvalidValue
def valid_value(val):
- return None
+ if re.search("^[0-9]+\.[0-9]{3}$", val):
+ return float(val)
+ raise InvalidValue(
+ f"Invalid value '{val}'.\n"
+ "Expected string representing a number with exactly three decimal "
+ "places.")
diff --git a/quality_control/standard_error.py b/quality_control/standard_error.py
index 9a91d1b..ae1e378 100644
--- a/quality_control/standard_error.py
+++ b/quality_control/standard_error.py
@@ -4,4 +4,9 @@ import re
from .errors import InvalidValue
def valid_value(val):
- return None
+ if re.search("^[0-9]+\.[0-9]{6,}$", val):
+ return float(val)
+ raise InvalidValue(
+ f"Invalid value '{val}'.\n"
+ "Expected string representing a number with at least six decimal "
+ "places.")