refactoring

This commit is contained in:
frankknoll
2022-02-20 21:22:04 +01:00
parent e2bc81bce1
commit ca5c232c45

View File

@@ -1464,18 +1464,17 @@
"metadata": {},
"outputs": [],
"source": [
"def createAndSaveAndDisplayBatchCodeTableByCountry(createBatchCodeTable, country, minADRsForLethality = None):\n",
" batchCodeTable = createBatchCodeTable(country)\n",
"def createAndSaveBatchCodeTableForCountry(createBatchCodeTableForCountry, country, minADRsForLethality = None):\n",
" batchCodeTable = createBatchCodeTableForCountry(country)\n",
" batchCodeTable.index.set_names(\"Batch\", inplace = True)\n",
" if minADRsForLethality is not None:\n",
" batchCodeTable.loc[batchCodeTable['Adverse Reaction Reports'] < minADRsForLethality, ['Severe reports', 'Lethality']] = [np.nan, np.nan]\n",
" IOUtils.saveDataFrame(batchCodeTable, '../docs/data/' + country)\n",
" display(country + \":\", batchCodeTable)\n",
"\n",
"def createAndSaveAndDisplayBatchCodeTablesByCountry(vaers, countries, minADRsForLethality = None):\n",
" internationalLotTableFactory = InternationalLotTableFactory(vaers)\n",
"def createAndSaveBatchCodeTablesForCountries(createBatchCodeTableForCountry, countries, minADRsForLethality = None):\n",
" for country in countries:\n",
" createAndSaveAndDisplayBatchCodeTableByCountry(lambda country: internationalLotTableFactory.createBatchCodeTableByCountry(country), country, minADRsForLethality)"
" createAndSaveBatchCodeTableForCountry(createBatchCodeTableForCountry, country, minADRsForLethality)"
]
},
{
@@ -1520,34 +1519,18 @@
"metadata": {},
"outputs": [],
"source": [
"createAndSaveAndDisplayBatchCodeTablesByCountry(\n",
" internationalVaers,\n",
" countries,\n",
" minADRsForLethality = 100)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "106c0d91",
"metadata": {},
"outputs": [],
"source": [
"globalBatchCodeTable = InternationalLotTableFactory(internationalVaers).createGlobalBatchCodeTable()\n",
"globalBatchCodeTable"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e75bd993",
"metadata": {},
"outputs": [],
"source": [
"createAndSaveAndDisplayBatchCodeTableByCountry(\n",
" createBatchCodeTable = lambda country: globalBatchCodeTable,\n",
"minADRsForLethality = 100\n",
"internationalLotTableFactory = InternationalLotTableFactory(internationalVaers)\n",
"\n",
"createAndSaveBatchCodeTablesForCountries(\n",
" createBatchCodeTableForCountry = lambda country: internationalLotTableFactory.createBatchCodeTableByCountry(country),\n",
" countries = countries,\n",
" minADRsForLethality = minADRsForLethality)\n",
"\n",
"createAndSaveBatchCodeTableForCountry(\n",
" createBatchCodeTableForCountry = lambda country: internationalLotTableFactory.createGlobalBatchCodeTable(),\n",
" country = 'Global',\n",
" minADRsForLethality = 100)\n"
" minADRsForLethality = minADRsForLethality)\n"
]
},
{