diff options
author | Frederick Muriuki Muriithi | 2022-04-11 14:05:57 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-04-11 14:05:57 +0300 |
commit | ec30480a7121956b0ccde353180d1656fce866af (patch) | |
tree | 83ef572bfddf1a308b1fcfc9df31a53e40b9088e | |
parent | 7bd0a4c58dc1d238027c593b24c2d783e88b8f49 (diff) | |
download | gn-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.py | 7 | ||||
-rw-r--r-- | quality_control/standard_error.py | 7 |
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.") |