-
Notifications
You must be signed in to change notification settings - Fork 7
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
Pull HSI_Event
class into its own submodule
#1289
Conversation
to avoid circular references. - update tlo/method imports - update test imports
HSI_Event
class into its own submodule
/run profiling This PR should be performance agnostic compared to |
Profiled run of the model succeeded ✅🆔 22554782937 |
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 these all looks like sensible changes to make. I have made a few small suggestions though none are vital.
Just so its recorded somewhere, Will and I discussed in person the changes to the imports of HSI_Event
in other modules, which are not strictly necessary as HSI_Event
is imported from the new tlo.methods.hsi_event
module in tlo.methods.healthsystem
and so could technically still be imported from there, which would keep the changes in this PR confined to the healthsystem
and new hsi_event
modules. Will pointed out changing the imports helps avoid circular imports between disease modules and healthsystem and should simplify importing HSI_Event
to use just for type hinting purposes without needing any if TYPE_CHECKING
blocks, which I felt was a good enough justification to outweigh the increased probability of needing to deal with some merge conflicts in disease modules on other branches when this is merged in (though as this only touches imports shouldn't be too much of a problem).
Co-authored-by: Matt Graham <matthew.m.graham@gmail.com>
Have adapted the type-hinting to use |
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 for doing the updates
This pull request moves the
HSI_Event
class (and related supporting classes) out of thehealthsystem
module and into its own submodule (hsi_event
). This allows us to:HSI_Event
class.do_at_generic_first_appt_non_emergency
due to repeated dataframe access #1237 simpler and slightly less noisy.There are no functionality changes that are introduced by this PR.
Key changes
HSI_Event
class and related container classes have been moved into thesrc/tlo/methods/hsi_event.py
file, to make them accessible without needing to import the entirehealthcaresystem.py
module.HSI_Event
class has been simplified slightly in places:Module
,Simulation
, andPopulation
.Module
.self.sim
property to avoid storing it as a class attribute.self.healthsystem
property.target_is_alive
property is used in place of tracking the population dataframe as a class attribute. We were only looking up one value from the dataframe, and otherwise not using it at all.return_item_codes_in_dict
function every time theget_consumables
method is run.return_item_codes_in_dict
is now a stand-alone method.adjust_facility_level_to_merge_1b_and_2
has been made into a class method since it is not used outside of theHSI_Event
class.