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

View File

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