refactoring

This commit is contained in:
frankknoll
2023-04-03 00:39:00 +02:00
parent 53797cb3a0
commit c4beab12ee
2 changed files with 6 additions and 21 deletions

View File

@@ -2,19 +2,8 @@ from IOUtils import IOUtils
import numpy as np import numpy as np
def createAndSaveBatchCodeTables( def createAndSaveGlobalBatchCodeTable(minADRsForLethality, batchCodeTableFactory):
minADRsForLethality, batchCodeTable = batchCodeTableFactory.createGlobalBatchCodeTable()
batchCodeTableFactory,
onCountryProcessed = lambda country: None):
_createAndSaveBatchCodeTableForCountry(
createBatchCodeTableForCountry = lambda country: batchCodeTableFactory.createGlobalBatchCodeTable(),
country = 'Global',
minADRsForLethality = minADRsForLethality,
onCountryProcessed = onCountryProcessed)
def _createAndSaveBatchCodeTableForCountry(createBatchCodeTableForCountry, country, minADRsForLethality, onCountryProcessed):
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:
batchCodeTable.loc[ batchCodeTable.loc[
@@ -33,7 +22,4 @@ def _createAndSaveBatchCodeTableForCountry(createBatchCodeTableForCountry, count
'Severe reports', 'Severe reports',
'Lethality' 'Lethality'
]] ]]
IOUtils.saveDataFrameAsJson( IOUtils.saveDataFrameAsJson(batchCodeTable, '../docs/data/batchCodeTables/Global.json')
batchCodeTable,
'../docs/data/batchCodeTables/' + country + '.json')
onCountryProcessed(country)

View File

@@ -18,7 +18,7 @@
"from DateProvider import DateProvider\n", "from DateProvider import DateProvider\n",
"from InternationalVaersCovid19Provider import getInternationalVaersCovid19, get_international_VAERSVAX_VAERSSYMPTOMS_Covid19\n", "from InternationalVaersCovid19Provider import getInternationalVaersCovid19, get_international_VAERSVAX_VAERSSYMPTOMS_Covid19\n",
"from BatchCodeTableHtmlUpdater import updateBatchCodeTableHtmlFile\n", "from BatchCodeTableHtmlUpdater import updateBatchCodeTableHtmlFile\n",
"from BatchCodeTablePersister import createAndSaveBatchCodeTables\n", "from BatchCodeTablePersister import createAndSaveGlobalBatchCodeTable\n",
"from SymptomByBatchcodeTableFactory import SymptomByBatchcodeTableFactory\n", "from SymptomByBatchcodeTableFactory import SymptomByBatchcodeTableFactory\n",
"from HistogramFactoryAndPersister import createAndSaveGlobalHistograms\n", "from HistogramFactoryAndPersister import createAndSaveGlobalHistograms\n",
"from BatchCodeTableFactory import BatchCodeTableFactory" "from BatchCodeTableFactory import BatchCodeTableFactory"
@@ -149,10 +149,9 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"createAndSaveBatchCodeTables(\n", "createAndSaveGlobalBatchCodeTable(\n",
" minADRsForLethality = 100,\n", " minADRsForLethality = 100,\n",
" batchCodeTableFactory = BatchCodeTableFactory(internationalVaersCovid19),\n", " batchCodeTableFactory = BatchCodeTableFactory(internationalVaersCovid19))"
" onCountryProcessed = display)"
] ]
}, },
{ {