refactoring

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

View File

@@ -1464,8 +1464,8 @@
"metadata": {},
"outputs": [],
"source": [
"def createAndSaveAndDisplayBatchCodeTableByCountry(internationalLotTableFactory, country, minADRsForLethality = None):\n",
" batchCodeTable = internationalLotTableFactory.createBatchCodeTableByCountry(country)\n",
"def createAndSaveAndDisplayBatchCodeTableByCountry(createBatchCodeTable, country, minADRsForLethality = None):\n",
" batchCodeTable = createBatchCodeTable(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",
@@ -1475,7 +1475,7 @@
"def createAndSaveAndDisplayBatchCodeTablesByCountry(vaers, countries, minADRsForLethality = None):\n",
" internationalLotTableFactory = InternationalLotTableFactory(vaers)\n",
" for country in countries:\n",
" createAndSaveAndDisplayBatchCodeTableByCountry(internationalLotTableFactory, country, minADRsForLethality)"
" createAndSaveAndDisplayBatchCodeTableByCountry(lambda country: internationalLotTableFactory.createBatchCodeTableByCountry(country), country, minADRsForLethality)"
]
},
{
@@ -1533,8 +1533,8 @@
"metadata": {},
"outputs": [],
"source": [
"internationalLotTableFactory = InternationalLotTableFactory(internationalVaers)\n",
"globalBatchCodeTable = internationalLotTableFactory.createGlobalBatchCodeTable()"
"globalBatchCodeTable = InternationalLotTableFactory(internationalVaers).createGlobalBatchCodeTable()\n",
"globalBatchCodeTable"
]
},
{
@@ -1544,13 +1544,10 @@
"metadata": {},
"outputs": [],
"source": [
" # FK-TODO: DRY with createAndSaveAndDisplayBatchCodeTableByCountry()\n",
" minADRsForLethality = 100\n",
" globalBatchCodeTable.index.set_names(\"Batch\", inplace = True)\n",
" if minADRsForLethality is not None:\n",
" globalBatchCodeTable.loc[globalBatchCodeTable['Adverse Reaction Reports'] < minADRsForLethality, ['Severe reports', 'Lethality']] = [np.nan, np.nan]\n",
" IOUtils.saveDataFrame(globalBatchCodeTable, '../docs/data/Global')\n",
" display('Global' + \":\", globalBatchCodeTable)\n"
"createAndSaveAndDisplayBatchCodeTableByCountry(\n",
" createBatchCodeTable = lambda country: globalBatchCodeTable,\n",
" country = 'Global',\n",
" minADRsForLethality = 100)\n"
]
},
{