Describe the feature you want to add
Refactor the simulation-data validation logic in DrugReleaseModel so that the checks for available simulation data and sufficient release-profile length are implemented in a single reusable method.
Currently, _validate_plot(), get_release_rate(), and time_for_release() independently check whether simulation data exists. This duplicates validation logic and makes the code harder to maintain consistently.
Describe your proposed solution
Add a private helper method named _require_simulation_data() to DrugReleaseModel.
The method should:
- Check that
_time_points and _release_profile are available.
- Raise
ERROR_NO_SIMULATION_DATA when simulation data is unavailable.
- Check that the release profile contains at least two points.
- Raise
ERROR_RELEASE_PROFILE_TOO_SHORT when fewer than two points are available.
Update _validate_plot(), get_release_rate(), and time_for_release() to call _require_simulation_data() instead of implementing these checks independently.
This keeps the existing behavior and error messages while removing duplicated validation code.
Describe alternatives you've considered, if relevant
An alternative would be to leave the validation logic duplicated in each method. However, this could lead to inconsistent behavior if the validation requirements change in the future.
Another alternative would be to expose the validation method publicly, but simulation-data validation is an internal implementation concern, so a private _require_simulation_data() method is more appropriate.
Additional context
No response
Describe the feature you want to add
Refactor the simulation-data validation logic in
DrugReleaseModelso that the checks for available simulation data and sufficient release-profile length are implemented in a single reusable method.Currently,
_validate_plot(),get_release_rate(), andtime_for_release()independently check whether simulation data exists. This duplicates validation logic and makes the code harder to maintain consistently.Describe your proposed solution
Add a private helper method named
_require_simulation_data()toDrugReleaseModel.The method should:
_time_pointsand_release_profileare available.ERROR_NO_SIMULATION_DATAwhen simulation data is unavailable.ERROR_RELEASE_PROFILE_TOO_SHORTwhen fewer than two points are available.Update
_validate_plot(),get_release_rate(), andtime_for_release()to call_require_simulation_data()instead of implementing these checks independently.This keeps the existing behavior and error messages while removing duplicated validation code.
Describe alternatives you've considered, if relevant
An alternative would be to leave the validation logic duplicated in each method. However, this could lead to inconsistent behavior if the validation requirements change in the future.
Another alternative would be to expose the validation method publicly, but simulation-data validation is an internal implementation concern, so a private
_require_simulation_data()method is more appropriate.Additional context
No response