Skip to content

[Task]: Centralize simulation-data validation #57

Description

@sepandhaghighi

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions