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

Log entry for EquipmentEverUsed_ByFacilityID non-deterministic #1435

Closed
matt-graham opened this issue Jul 26, 2024 · 0 comments · Fixed by #1446
Closed

Log entry for EquipmentEverUsed_ByFacilityID non-deterministic #1435

matt-graham opened this issue Jul 26, 2024 · 0 comments · Fixed by #1446
Labels
bug Something isn't working

Comments

@matt-graham
Copy link
Collaborator

Somewhat analogous to #1434

In

set_of_equipment_ever_used_at_each_facility_id = pd.Series({
fac_id: set_of_keys_or_empty_set(self._record_of_equipment_used_by_facility_id.get(fac_id, set()))
for fac_id in mfl['Facility_ID']
}, name='EquipmentEverUsed').astype(str)
output = mfl.merge(
set_of_equipment_ever_used_at_each_facility_id,
left_on='Facility_ID',
right_index=True,
how='left',
).drop(columns=['Facility_ID', 'Facility_Name'])
# Log multi-row data-frame
for row_index in output.index:
logger_summary.info(
key='EquipmentEverUsed_ByFacilityID',
description='For each facility_id (the set of facilities of the same level in a district), the set of'
'equipment items that are ever used.',
data=get_dataframe_row_as_dict_for_logging(output, row_index)
)

a dictionary is constructed for each row of a dataframe output and logged under the key EquipmentEverUsed_ByFacilityID. In each dictionary the EquipmentEverUsed key (from the corresponding column in the dataframe) maps to a string representation of a set of the equipment item (codes?) used in the simulation. As sets do not have a fixed iteration order in Python, over multiple runs of the same simulation the ordering of items in the string representations of these sets and so in the log entries will change. We should ideally sort the set entries before logging / converting to a string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant