adjust mypy conf + requirements.txt
This commit is contained in:
		
							parent
							
								
									70ac7d1bb7
								
							
						
					
					
						commit
						4818d78cfe
					
				
							
								
								
									
										29
									
								
								drees.py
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								drees.py
									
									
									
									
									
								
							| @ -104,7 +104,7 @@ def get_enum_field(value): | |||||||
|             return field.value |             return field.value | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def group_by_age_date(data: Dict[str, Any], fields: List[str]) -> Dict[dt, Any]: | def group_by_age_date(data: Dict[str, Any]) -> Dict[dt, Any]: | ||||||
|     """ |     """ | ||||||
|     group the original dictionnary into a more readable one |     group the original dictionnary into a more readable one | ||||||
|     'date': { |     'date': { | ||||||
| @ -131,8 +131,10 @@ def group_by_age_date(data: Dict[str, Any], fields: List[str]) -> Dict[dt, Any]: | |||||||
|             dic_data_grouped[date][age] = OrderedDict() |             dic_data_grouped[date][age] = OrderedDict() | ||||||
|         if vac_status not in dic_data_grouped[date][age]: |         if vac_status not in dic_data_grouped[date][age]: | ||||||
|             dic_data_grouped[date][age][vac_status] = OrderedDict() |             dic_data_grouped[date][age][vac_status] = OrderedDict() | ||||||
|         for field in fields: |         for field in Field: | ||||||
|             dic_data_grouped[date][age][vac_status][field] = row_fields[field] |             dic_data_grouped[date][age][vac_status][field.label] = row_fields[ | ||||||
|  |                 field.label | ||||||
|  |             ] | ||||||
|     logging.info("data restructured") |     logging.info("data restructured") | ||||||
|     return dic_data_grouped |     return dic_data_grouped | ||||||
| 
 | 
 | ||||||
| @ -209,8 +211,8 @@ def plot_cumulative_field( | |||||||
|         np_cumulate_unvac: np.ndarray = np.cumsum( |         np_cumulate_unvac: np.ndarray = np.cumsum( | ||||||
|             np_data_unvac[:, age_group.value, field.value], axis=0 |             np_data_unvac[:, age_group.value, field.value], axis=0 | ||||||
|         ) |         ) | ||||||
|         plt.plot(np_date, np_cumulate_vac, label=f"{age_group.label} vaccinate") |         plt.plot(np_date, np_cumulate_vac, label=f"{age_group.label} vax") | ||||||
|         plt.plot(np_date, np_cumulate_unvac, label=f"{age_group.label} unvaccinate") |         plt.plot(np_date, np_cumulate_unvac, label=f"{age_group.label} no vax") | ||||||
| 
 | 
 | ||||||
|     plt.title(f"nombre de {field.label} cumulé par age") |     plt.title(f"nombre de {field.label} cumulé par age") | ||||||
|     plt.xlabel("date") |     plt.xlabel("date") | ||||||
| @ -266,6 +268,7 @@ def plot_bar_data_by_age_field( | |||||||
|     a limit days period is set to have an readable plot |     a limit days period is set to have an readable plot | ||||||
|     """ |     """ | ||||||
|     np_percent_vac, np_percent_unvac = get_vaccine_percent(np_data) |     np_percent_vac, np_percent_unvac = get_vaccine_percent(np_data) | ||||||
|  |     # adjust the fig size to display correctly bars and labels | ||||||
|     fig, ax = get_plot_fig(figsize=(22, 8)) |     fig, ax = get_plot_fig(figsize=(22, 8)) | ||||||
| 
 | 
 | ||||||
|     for idx_date in range(len(np_date)): |     for idx_date in range(len(np_date)): | ||||||
| @ -275,15 +278,15 @@ def plot_bar_data_by_age_field( | |||||||
|         unvac_percent = np.round( |         unvac_percent = np.round( | ||||||
|             np_percent_unvac[idx_date, age_group.value, field.value] * 100 |             np_percent_unvac[idx_date, age_group.value, field.value] * 100 | ||||||
|         ) |         ) | ||||||
|         bar_vac = ax.bar(idx_date, vac_percent, color="b", label="vac") |         bar_vac = ax.bar(idx_date, vac_percent, color="b", label="vax") | ||||||
|         bar_unvac = ax.bar( |         ax.bar(idx_date, unvac_percent, bottom=vac_percent, color="r", label="no vax") | ||||||
|             idx_date, unvac_percent, bottom=vac_percent, color="r", label="novac" |  | ||||||
|         ) |  | ||||||
|         ax.bar_label(bar_vac, label_type="edge", color="black", fontsize="8") |         ax.bar_label(bar_vac, label_type="edge", color="black", fontsize="8") | ||||||
|         ax.set_ylim(top=105) |         ax.set_ylim(top=105)  # to display 100% label | ||||||
| 
 | 
 | ||||||
|     ax.set_ylabel("%") |     ax.set_ylabel("%") | ||||||
|     ax.set_title(f"{age_group.label} - {field.label}") |     ax.set_title(f"{age_group.label} - {field.label}") | ||||||
|  | 
 | ||||||
|  |     # avoid displaying all dates | ||||||
|     ax.set( |     ax.set( | ||||||
|         xticks=range(len(np_date)), |         xticks=range(len(np_date)), | ||||||
|         xticklabels=[ |         xticklabels=[ | ||||||
| @ -291,7 +294,7 @@ def plot_bar_data_by_age_field( | |||||||
|             for idx, d in enumerate(np_date.astype(dt)) |             for idx, d in enumerate(np_date.astype(dt)) | ||||||
|         ], |         ], | ||||||
|     ) |     ) | ||||||
|     plt.legend(["vaccinate", "unvaccinate"], loc=0, frameon=True) |     plt.legend(["vax", "no vax"], loc=0, frameon=True) | ||||||
| 
 | 
 | ||||||
|     save_and_close_fig( |     save_and_close_fig( | ||||||
|         fig, |         fig, | ||||||
| @ -351,9 +354,7 @@ if __name__ == "__main__": | |||||||
|     dic_data: Dict[str, Any] = get_data( |     dic_data: Dict[str, Any] = get_data( | ||||||
|         file_path=os.path.join(DATA_REPOSITORY, "dress.json"), refresh=args.refresh |         file_path=os.path.join(DATA_REPOSITORY, "dress.json"), refresh=args.refresh | ||||||
|     ) |     ) | ||||||
|     dic_data_grouped: Dict[dt, Any] = group_by_age_date( |     dic_data_grouped: Dict[dt, Any] = group_by_age_date(dic_data) | ||||||
|         dic_data, [x.label for x in Field] |  | ||||||
|     ) |  | ||||||
| 
 | 
 | ||||||
|     np_data, np_date = get_np_data(dic_data_grouped) |     np_data, np_date = get_np_data(dic_data_grouped) | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										4
									
								
								mypy.ini
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								mypy.ini
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | |||||||
|  | [mypy] | ||||||
|  | python_version = 3.8 | ||||||
|  | ignore_missing_imports = True | ||||||
|  | disable_error_code = attr-defined | ||||||
| @ -5,16 +5,22 @@ chardet==4.0.0 | |||||||
| click==8.0.1 | click==8.0.1 | ||||||
| cycler==0.10.0 | cycler==0.10.0 | ||||||
| idna==2.10 | idna==2.10 | ||||||
|  | isort==5.10.1 | ||||||
| kiwisolver==1.3.1 | kiwisolver==1.3.1 | ||||||
| matplotlib==3.4.2 | matplotlib==3.4.2 | ||||||
|  | mypy==0.920 | ||||||
| mypy-extensions==0.4.3 | mypy-extensions==0.4.3 | ||||||
| numpy==1.20.3 | numpy==1.20.3 | ||||||
| pathspec==0.8.1 | pathspec==0.8.1 | ||||||
| Pillow==8.2.0 | Pillow==8.2.0 | ||||||
| pyparsing==2.4.7 | pyparsing==2.4.7 | ||||||
| python-dateutil==2.8.1 | python-dateutil==2.8.1 | ||||||
|  | pytz==2021.3 | ||||||
| regex==2021.4.4 | regex==2021.4.4 | ||||||
| requests==2.25.1 | requests==2.25.1 | ||||||
| six==1.16.0 | six==1.16.0 | ||||||
| toml==0.10.2 | toml==0.10.2 | ||||||
|  | tomli==2.0.0 | ||||||
|  | types-requests==2.26.2 | ||||||
|  | typing-extensions==4.0.1 | ||||||
| urllib3==1.26.4 | urllib3==1.26.4 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user