From c214b12c67071e0baa7bfe0a8ee9c66ea545f6ac Mon Sep 17 00:00:00 2001 From: lshpaner Date: Mon, 10 Jun 2024 17:25:49 -0700 Subject: [PATCH] collected all exceptions to raise single exception, bump version to 0.1.7ba --- setup.py | 2 +- src/kfre/main.py | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index 7b57814..8a17fa7 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="kfre", - version="0.1.7b", + version="0.1.7ba", author="Leonid Shpaner", author_email="lshpaner@ucla.edu", description="A Python library for estimating kidney failure risk using the KFRE model developed by Tangri et al.", diff --git a/src/kfre/main.py b/src/kfre/main.py index 2c5e9c8..70edb51 100644 --- a/src/kfre/main.py +++ b/src/kfre/main.py @@ -194,29 +194,34 @@ def kfre_person( Returns: - float: The computed risk of developing CKD. """ + errors = [] + if age is None: - raise ValueError("Must supply a value for age.") + errors.append("Must supply a value for age.") if is_male is None: - raise ValueError("Must specify sex using True or False for is_male.") + errors.append("Must specify sex using True or False for is_male.") if eGFR is None: - raise ValueError("Must supply a value for eGFR.") + errors.append("Must supply a value for eGFR.") if uACR is None: - raise ValueError("Must supply a value for uACR.") + errors.append("Must supply a value for uACR.") if years not in [2, 5]: - raise ValueError("Value must be 2 or 5 for 2-year risk or 5-year risk.") + errors.append("Value must be 2 or 5 for 2-year risk or 5-year risk.") if dm is not None and dm not in [0, 1, True, False]: - raise ValueError("The dm parameter must be either 0, 1, True, or False.") + errors.append("The dm parameter must be either 0, 1, True, or False.") if htn is not None and htn not in [0, 1, True, False]: - raise ValueError("The htn parameter must be either 0, 1, True, or False.") + errors.append("The htn parameter must be either 0, 1, True, or False.") if is_north_american is None: - raise ValueError("Must specify True or False for is_north_american.") + errors.append("Must specify True or False for is_north_american.") + + if errors: + raise ValueError(" ; ".join(errors)) # Use is_male directly, since it's already a boolean # Call the risk prediction function with the parameters