refactoring
This commit is contained in:
@@ -433,7 +433,6 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from SymptomsCausedByVaccines.HtmlUpdater import updateHtmlFile\n",
|
||||
"from SymptomsCausedByVaccines.PrrByVaccineTableFactory import PrrByVaccineTableFactory\n",
|
||||
"import pandas as pd"
|
||||
]
|
||||
},
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class PrrByVaccineBySymptomFactory:
|
||||
|
||||
@staticmethod
|
||||
def getPrrByVaccineBySymptom(prrByVaccineAndSymptom):
|
||||
return prrByVaccineAndSymptom.apply(lambda prrByVaccine: prrByVaccine.to_dict())
|
||||
@@ -0,0 +1,32 @@
|
||||
import unittest
|
||||
from pandas.testing import assert_series_equal
|
||||
from TestHelper import TestHelper
|
||||
import pandas as pd
|
||||
from SymptomsCausedByVaccines.PrrByVaccineBySymptomFactory import PrrByVaccineBySymptomFactory
|
||||
|
||||
class PrrByVaccineBySymptomFactoryTest(unittest.TestCase):
|
||||
|
||||
def test_getPrrByVaccineBySymptom(self):
|
||||
# Given
|
||||
prrByVaccineAndSymptom = TestHelper.createDataFrame(
|
||||
columns = ['11-beta-hydroxylase deficiency', '17-hydroxyprogesterone'],
|
||||
data = [ [0.6, 1.5],
|
||||
[0.3, 3.0]],
|
||||
index = pd.Index(
|
||||
name = 'VAX_TYPE',
|
||||
data = [
|
||||
'6VAX-F',
|
||||
'ADEN'
|
||||
]))
|
||||
|
||||
# When
|
||||
prrByVaccineBySymptom = PrrByVaccineBySymptomFactory.getPrrByVaccineBySymptom(prrByVaccineAndSymptom)
|
||||
|
||||
# Then
|
||||
assert_series_equal(
|
||||
prrByVaccineBySymptom,
|
||||
pd.Series(
|
||||
{
|
||||
'11-beta-hydroxylase deficiency': {'6VAX-F': 0.6, 'ADEN': 0.3},
|
||||
'17-hydroxyprogesterone': {'6VAX-F': 1.5, 'ADEN': 3.0}
|
||||
}))
|
||||
@@ -1,11 +0,0 @@
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PrrByVaccineTableFactory:
|
||||
|
||||
@staticmethod
|
||||
def getPrrByVaccineTable(prrByVaccineAndSymptom):
|
||||
return pd.DataFrame(
|
||||
columns = ['11-beta-hydroxylase deficiency'],
|
||||
data = [ [prrByVaccineAndSymptom['11-beta-hydroxylase deficiency'].to_dict()]],
|
||||
index = pd.Index(['PrrByVaccine']))
|
||||
@@ -1,31 +0,0 @@
|
||||
import unittest
|
||||
from pandas.testing import assert_frame_equal
|
||||
from TestHelper import TestHelper
|
||||
import pandas as pd
|
||||
from SymptomsCausedByVaccines.PrrByVaccineTableFactory import PrrByVaccineTableFactory
|
||||
|
||||
class PrrByVaccineTableFactoryTest(unittest.TestCase):
|
||||
|
||||
def test_getPrrByVaccineTable(self):
|
||||
# Given
|
||||
prrByVaccineAndSymptom = TestHelper.createDataFrame(
|
||||
columns = ['11-beta-hydroxylase deficiency'],
|
||||
data = [ [0.6],
|
||||
[0.3]],
|
||||
index = pd.Index(
|
||||
name = 'VAX_TYPE',
|
||||
data = [
|
||||
'6VAX-F',
|
||||
'ADEN'
|
||||
]))
|
||||
|
||||
# When
|
||||
prrByVaccineTable = PrrByVaccineTableFactory.getPrrByVaccineTable(prrByVaccineAndSymptom)
|
||||
|
||||
# Then
|
||||
assert_frame_equal(
|
||||
prrByVaccineTable,
|
||||
TestHelper.createDataFrame(
|
||||
columns = ['11-beta-hydroxylase deficiency'],
|
||||
data = [ [{'6VAX-F': 0.6, 'ADEN': 0.3}]],
|
||||
index = pd.Index(['PrrByVaccine'])))
|
||||
Reference in New Issue
Block a user