starting PrrByVaccineBySymptomTransformerTest
This commit is contained in:
@@ -433,6 +433,8 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"from SymptomsCausedByVaccines.HtmlUpdater import updateHtmlFile\n",
|
"from SymptomsCausedByVaccines.HtmlUpdater import updateHtmlFile\n",
|
||||||
|
"from SymptomsCausedByVaccines.PrrByVaccineBySymptomFactory import PrrByVaccineBySymptomFactory\n",
|
||||||
|
"from SymptomsCausedByVaccines.PrrByVaccineBySymptomTransformer import PrrByVaccineBySymptomTransformer\n",
|
||||||
"import pandas as pd"
|
"import pandas as pd"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -450,6 +452,38 @@
|
|||||||
"prrByVaccineAndSymptom"
|
"prrByVaccineAndSymptom"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "640868c7",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"prrByVaccineBySymptom = PrrByVaccineBySymptomFactory.getPrrByVaccineBySymptom(prrByVaccineAndSymptom)\n",
|
||||||
|
"prrByVaccineBySymptom"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "760ac423",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"prrByVaccineBySymptomWithoutZeroPrrs = PrrByVaccineBySymptomTransformer.removeNonZeroPrrs(prrByVaccineBySymptom)\n",
|
||||||
|
"prrByVaccineBySymptomWithoutZeroPrrs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "d863007f",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"prrByVaccineBySymptomWithoutZeroPrrs.to_excel('tmp/prrByVaccineBySymptomWithoutZeroPrrs.xlsx')"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
class PrrByVaccineBySymptomTransformer:
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def removeNonZeroPrrs(prrByVaccineBySymptom):
|
||||||
|
return prrByVaccineBySymptom.map(
|
||||||
|
lambda prrByVaccine: {vaccine: prr for vaccine, prr in prrByVaccine.items() if prr != 0})
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import unittest
|
||||||
|
from pandas.testing import assert_series_equal
|
||||||
|
import pandas as pd
|
||||||
|
from SymptomsCausedByVaccines.PrrByVaccineBySymptomTransformer import PrrByVaccineBySymptomTransformer
|
||||||
|
|
||||||
|
class PrrByVaccineBySymptomTransformerTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_filterByNonZeroPrrs(self):
|
||||||
|
# Given
|
||||||
|
prrByVaccineBySymptom = pd.Series(
|
||||||
|
{
|
||||||
|
'11-beta-hydroxylase deficiency': {'6VAX-F': 0.0, 'ADEN': 0.3},
|
||||||
|
'17-hydroxyprogesterone': {'6VAX-F': 1.5, 'ADEN': 0.0}
|
||||||
|
})
|
||||||
|
|
||||||
|
# When
|
||||||
|
prrByVaccineBySymptomWithoutZeroPrrs = PrrByVaccineBySymptomTransformer.removeNonZeroPrrs(prrByVaccineBySymptom)
|
||||||
|
|
||||||
|
# Then
|
||||||
|
assert_series_equal(
|
||||||
|
prrByVaccineBySymptomWithoutZeroPrrs,
|
||||||
|
pd.Series(
|
||||||
|
{
|
||||||
|
'11-beta-hydroxylase deficiency': {'ADEN': 0.3},
|
||||||
|
'17-hydroxyprogesterone': {'6VAX-F': 1.5}
|
||||||
|
}))
|
||||||
Reference in New Issue
Block a user