refactoring

This commit is contained in:
frankknoll
2023-01-29 18:00:55 +01:00
parent b4c01afa76
commit 81d91b6368
2 changed files with 20 additions and 15 deletions

View File

@@ -4,19 +4,24 @@ import numpy as np
from HtmlUtils import getCountries
def createAndSaveBatchCodeTables(internationalVaersCovid19, minADRsForLethality):
def createAndSaveBatchCodeTables(
internationalVaersCovid19,
minADRsForLethality,
onCountryProcessed = lambda country: None):
batchCodeTableFactory = BatchCodeTableFactory(internationalVaersCovid19)
_createAndSaveBatchCodeTablesForCountries(
createBatchCodeTableForCountry = lambda country: batchCodeTableFactory.createBatchCodeTableByCountry(country),
countries = getCountries(internationalVaersCovid19),
minADRsForLethality=minADRsForLethality)
minADRsForLethality = minADRsForLethality,
onCountryProcessed = onCountryProcessed)
_createAndSaveBatchCodeTableForCountry(
createBatchCodeTableForCountry = lambda country: batchCodeTableFactory.createGlobalBatchCodeTable(),
country = 'Global',
minADRsForLethality=minADRsForLethality)
minADRsForLethality = minADRsForLethality,
onCountryProcessed = onCountryProcessed)
def _createAndSaveBatchCodeTableForCountry(createBatchCodeTableForCountry, country, minADRsForLethality=None):
def _createAndSaveBatchCodeTableForCountry(createBatchCodeTableForCountry, country, minADRsForLethality, onCountryProcessed):
batchCodeTable = createBatchCodeTableForCountry(country)
batchCodeTable.index.set_names("Batch", inplace=True)
if minADRsForLethality is not None:
@@ -40,12 +45,9 @@ def _createAndSaveBatchCodeTableForCountry(createBatchCodeTableForCountry, count
IOUtils.saveDataFrame(
batchCodeTable,
'../docs/data/batchCodeTables/' + country)
# display(country + ":", batchCodeTable)
# FK-TODO: display in einem noch nicht vorhandenen Callback aufrufen
display(country)
onCountryProcessed(country)
def _createAndSaveBatchCodeTablesForCountries(createBatchCodeTableForCountry, countries, minADRsForLethality=None):
def _createAndSaveBatchCodeTablesForCountries(createBatchCodeTableForCountry, countries, minADRsForLethality, onCountryProcessed):
for country in countries:
_createAndSaveBatchCodeTableForCountry(
createBatchCodeTableForCountry, country, minADRsForLethality)
_createAndSaveBatchCodeTableForCountry(createBatchCodeTableForCountry, country, minADRsForLethality, onCountryProcessed)

View File

@@ -203,7 +203,10 @@
"metadata": {},
"outputs": [],
"source": [
"createAndSaveBatchCodeTables(internationalVaersCovid19, minADRsForLethality=100)"
"createAndSaveBatchCodeTables(\n",
" internationalVaersCovid19,\n",
" minADRsForLethality = 100,\n",
" onCountryProcessed = display)"
]
}
],