diff --git a/src/BatchCodeTablePersister.py b/src/BatchCodeTablePersister.py index f20c451dd7e..f89aeffdb8b 100644 --- a/src/BatchCodeTablePersister.py +++ b/src/BatchCodeTablePersister.py @@ -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) diff --git a/src/HowBadIsMyBatch.ipynb b/src/HowBadIsMyBatch.ipynb index 2683881c0a4..04d0288e81e 100644 --- a/src/HowBadIsMyBatch.ipynb +++ b/src/HowBadIsMyBatch.ipynb @@ -203,7 +203,10 @@ "metadata": {}, "outputs": [], "source": [ - "createAndSaveBatchCodeTables(internationalVaersCovid19, minADRsForLethality=100)" + "createAndSaveBatchCodeTables(\n", + " internationalVaersCovid19,\n", + " minADRsForLethality = 100,\n", + " onCountryProcessed = display)" ] } ],