Skip to content

Commit

Permalink
collected all exceptions to raise single exception, bump version to 0…
Browse files Browse the repository at this point in the history
….1.7ba
  • Loading branch information
lshpaner committed Jun 11, 2024
1 parent e342fe5 commit c214b12
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
21 changes: 13 additions & 8 deletions src/kfre/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c214b12

Please sign in to comment.