-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BedDays
availability switch now correctly updates capacities
#1352
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @willGraham01
def switch_beddays_availability( | ||
self, | ||
new_availability: Literal["all", "none", "default"], | ||
effective_on_and_from: Date, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way in which we expect to use this (i.e., from HealthSystemChangeParameters
) I think we can always assume that this is equal to today's date. This is the way in which other things (consumables, equipment) have their availability updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With regards to this and the below comment - I think exposing effective_on_and_from
and model_to_data_popsize_ratio
as arguments has an advantage in terms of making it easier to test (as we can pass in relevant values directly rather than having to manipulate the other objects they would be instead read from) and keeping it's implementation decoupled from implementation details of other classes, however we can possibly still achieve this by making the current switch_beddays_availability
method instead _switch_beddays_availability
to indicate for internal use only, and exposing a 'public' method
def switch_beddays_availability(self, new_availability: Literal["all", "none", "default"]) -> None:
"""..."""
self._switch_beddays_availability(
new_availability=new_availability,
effective_on_and_from=self.sim.date,
model_to_data_popsize_ratio=self.sim.modules["Demography"].initial_model_to_data_popsize_ratio
)
This would still allow using the current _switch_beddays_availability
implementation in tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to make a public/private method like is suggested above, though I'd quite like to avoid spreading the self.sim.modules...
cross-class-coupling into the bed-days class if possible. switch_beddays_availability
is already called by classes that have this cross-class-coupling anyway, so it might as well stay isolated to there?
self, | ||
new_availability: Literal["all", "none", "default"], | ||
effective_on_and_from: Date, | ||
model_to_data_popsize_ratio: float = 1.0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be nicer (I think) if the user didn't need to pass this. It hasn't changed since the beginning of the simulation, so it seems awkward to pass it in just to instruct a change in availability to all/none/default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not super familiar with bed days system but this generally looks sensible from what I can tell. Added a couple of minor comments.
def switch_beddays_availability( | ||
self, | ||
new_availability: Literal["all", "none", "default"], | ||
effective_on_and_from: Date, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With regards to this and the below comment - I think exposing effective_on_and_from
and model_to_data_popsize_ratio
as arguments has an advantage in terms of making it easier to test (as we can pass in relevant values directly rather than having to manipulate the other objects they would be instead read from) and keeping it's implementation decoupled from implementation details of other classes, however we can possibly still achieve this by making the current switch_beddays_availability
method instead _switch_beddays_availability
to indicate for internal use only, and exposing a 'public' method
def switch_beddays_availability(self, new_availability: Literal["all", "none", "default"]) -> None:
"""..."""
self._switch_beddays_availability(
new_availability=new_availability,
effective_on_and_from=self.sim.date,
model_to_data_popsize_ratio=self.sim.modules["Demography"].initial_model_to_data_popsize_ratio
)
This would still allow using the current _switch_beddays_availability
implementation in tests.
Fixes #1346
switch_beddays_availability
has been created to handle all steps necessary when switching the availability of beds.availability
, but this in itself should be covered if we are already testing theset_scaled_capacity
method which the new method depends on.