Spaces:
Running
Running
File size: 2,438 Bytes
630d650 |
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
from mcp_tox_calc.equations import (
calculate_epa_elcr_csf,
calculate_epa_elcr_iur,
calculate_fda_ctp_elcr,
run_batch_cancer_risk,
)
def test_calculate_epa_elcr_csf_basic():
out = calculate_epa_elcr_csf(
{
"route": "oral",
"exposure_value": 0.01,
"exposure_unit": "mg/kg-day",
"body_weight_kg": 70,
"csf_value": 1.5,
"csf_unit": "(mg/kg-day)^-1",
}
)
assert round(out["result_value"], 8) == 0.015
def test_calculate_epa_elcr_iur_basic():
out = calculate_epa_elcr_iur(
{
"route": "inhalation",
"air_conc_value": 100,
"air_conc_unit": "ug/m3",
"iur_value": 1e-6,
"iur_unit": "(ug/m3)^-1",
}
)
assert round(out["result_value"], 8) == 0.0001
def test_fda_wrapper_aggregates_components():
out = calculate_fda_ctp_elcr(
{
"constituents": [
{
"route": "oral",
"exposure_value": 0.01,
"exposure_unit": "mg/kg-day",
"body_weight_kg": 70,
"csf_value": 1.0,
"csf_unit": "(mg/kg-day)^-1",
},
{
"route": "inhalation",
"air_conc_value": 50,
"air_conc_unit": "ug/m3",
"iur_value": 1e-6,
"iur_unit": "(ug/m3)^-1",
},
]
}
)
assert out["result_value"] > 0
assert len(out["component_results"]) == 2
def test_batch_handles_mixed_rows():
out = run_batch_cancer_risk(
{
"rows": [
{
"record_id": "r1",
"chemical_name": "ChemA",
"route": "oral",
"exposure_value": 0.02,
"exposure_unit": "mg/kg-day",
"body_weight_kg": 70,
"csf_value": 1.1,
"csf_unit": "(mg/kg-day)^-1",
},
{
"record_id": "r2",
"chemical_name": "ChemB",
"route": "oral"
},
]
}
)
assert out["summary"]["total_rows"] == 2
assert out["summary"]["ok_rows"] == 1
assert out["summary"]["error_rows"] == 1
|