add function to check timesteps in numpy date array

This commit is contained in:
landrigun 2022-04-13 13:59:48 +00:00
parent 5c499bebee
commit 689aed305e

View File

@ -547,6 +547,13 @@ def plot_bar_vaccine_status_distribution_by_age_field(
) )
def check_timestep(np_date: np.ndarray):
# get the difference between each element (return timedelta64 array)
np_diff = np.diff(np_date)
# check if all timestep are equals
assert np.all(np_diff == np_diff[0]), "some timesteps missing !"
def get_age_vac_args() -> List[Tuple[AgeGroup, VacStatus]]: def get_age_vac_args() -> List[Tuple[AgeGroup, VacStatus]]:
""" """
build pool age and vac status arguments build pool age and vac status arguments
@ -669,6 +676,7 @@ if __name__ == "__main__":
np_data, np_date = get_np_data(dic_data) np_data, np_date = get_np_data(dic_data)
lst_analyse_data = analyse(np_data) lst_analyse_data = analyse(np_data)
check_timestep(np_date)
if not args.no_plot: if not args.no_plot:
os.makedirs(OUTPUT_REPOSITORY, exist_ok=True) os.makedirs(OUTPUT_REPOSITORY, exist_ok=True)