Skip to content
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

Use more robust casting of column to datetime type #937

Merged
merged 2 commits into from
Apr 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/test_control_order_of_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ def initialise_simulation(self, sim):
events = parse_log_file(sim.log_filepath)['tlo.simulation']['event'].reset_index()

# Check that order is as expected: Start -> Middle --> End
events['date'] = pd.to_datetime(events['date']).dt.date
events['date'] = events['date'].astype("datetime64[ns]")
order_on_day_one = tuple(events.loc[events['date'] == Date(2010, 1, 1), 'id'])
assert order_on_day_one == ("EventForStartOfDay",
"EventForMiddleOfDay",
"EventForSecondToLastAtEndOfDay",
"EventForEndOfDay")

# Check order is the same every day
dates = pd.to_datetime(events['date']).dt.date.drop_duplicates()
dates = events['date'].drop_duplicates()
for day in dates:
assert order_on_day_one == tuple(events.loc[events['date'] == day, 'id'])

Expand Down
7 changes: 5 additions & 2 deletions tests/test_healthcareseeking.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,8 +908,11 @@ def on_birth(self, mother, child):
sim.modules['HealthSeekingBehaviour'].theHealthSeekingBehaviourPoll.run()

# See what HSI are scheduled to occur for the person on the same day
evs = [x[1].TREATMENT_ID for x in
sim.modules['HealthSystem'].find_events_for_person(0) if x[0].date() == start_date]
evs = [
event.TREATMENT_ID
for date, event in sim.modules['HealthSystem'].find_events_for_person(0)
if date == start_date
]

return 'FirstAttendance_NonEmergency' in evs

Expand Down