mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
more helpful error message for dose_coefficients (#3534)
This commit is contained in:
parent
f8fa751da0
commit
14d51e0eba
2 changed files with 26 additions and 1 deletions
|
|
@ -82,7 +82,12 @@ def dose_coefficients(particle, geometry='AP', data_source='icrp116'):
|
|||
cv.check_value('data_source', data_source, {'icrp74', 'icrp116'})
|
||||
|
||||
if (data_source, particle) not in _FILES:
|
||||
raise ValueError(f"{particle} has no dose data in data source {data_source}.")
|
||||
available_particles = sorted({p for (ds, p) in _FILES if ds == data_source})
|
||||
msg = (
|
||||
f"'{particle}' has no dose data in data source {data_source}. "
|
||||
f"Available particles for {data_source} are: {available_particles}"
|
||||
)
|
||||
raise ValueError(msg)
|
||||
elif (data_source, particle) not in _DOSE_TABLES:
|
||||
_load_dose_icrp(data_source, particle)
|
||||
|
||||
|
|
|
|||
|
|
@ -41,3 +41,23 @@ def test_dose_coefficients():
|
|||
dose_coefficients('neutron', 'ZZ')
|
||||
with raises(ValueError):
|
||||
dose_coefficients('neutron', data_source='icrp7000')
|
||||
with raises(ValueError) as excinfo:
|
||||
dose_coefficients("photons", data_source="icrp116")
|
||||
expected_particles = [
|
||||
"electron",
|
||||
"helium",
|
||||
"mu+",
|
||||
"mu-",
|
||||
"neutron",
|
||||
"photon",
|
||||
"photon kerma",
|
||||
"pi+",
|
||||
"pi-",
|
||||
"positron",
|
||||
"proton",
|
||||
]
|
||||
expected_msg = (
|
||||
"'photons' has no dose data in data source icrp116. "
|
||||
f"Available particles for icrp116 are: {expected_particles}"
|
||||
)
|
||||
assert str(excinfo.value) == expected_msg
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue