refactoring
This commit is contained in:
@@ -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)
|
||||
createBatchCodeTableForCountry = lambda country: batchCodeTableFactory.createBatchCodeTableByCountry(country),
|
||||
countries = getCountries(internationalVaersCovid19),
|
||||
minADRsForLethality = minADRsForLethality,
|
||||
onCountryProcessed = onCountryProcessed)
|
||||
_createAndSaveBatchCodeTableForCountry(
|
||||
createBatchCodeTableForCountry=lambda country: batchCodeTableFactory.createGlobalBatchCodeTable(),
|
||||
country='Global',
|
||||
minADRsForLethality=minADRsForLethality)
|
||||
createBatchCodeTableForCountry = lambda country: batchCodeTableFactory.createGlobalBatchCodeTable(),
|
||||
country = 'Global',
|
||||
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)
|
||||
|
||||
@@ -203,7 +203,10 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"createAndSaveBatchCodeTables(internationalVaersCovid19, minADRsForLethality=100)"
|
||||
"createAndSaveBatchCodeTables(\n",
|
||||
" internationalVaersCovid19,\n",
|
||||
" minADRsForLethality = 100,\n",
|
||||
" onCountryProcessed = display)"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user