displacing "Lower Confidence Limit of Proportional Reporting Ratio"
This commit is contained in:
@@ -2,17 +2,11 @@ class PrrSeriesTransformer:
|
||||
|
||||
@staticmethod
|
||||
def filterByNonZeroPrrs(prrByVaccineBySymptom):
|
||||
return PrrSeriesTransformer._filterPrrsBy(
|
||||
return PrrSeriesTransformer.filterPrrs(
|
||||
prrByVaccineBySymptom,
|
||||
lambda prr: prr != 0)
|
||||
|
||||
@staticmethod
|
||||
def filterByHighPrrs(prrBySymptomByVaccine):
|
||||
return PrrSeriesTransformer._filterPrrsBy(
|
||||
prrBySymptomByVaccine,
|
||||
lambda prr: prr > 1)
|
||||
|
||||
@staticmethod
|
||||
def _filterPrrsBy(prrByKeyByOtherKey, prrFilter):
|
||||
def filterPrrs(prrByKeyByOtherKey, prrFilter):
|
||||
return prrByKeyByOtherKey.map(
|
||||
lambda prrByKey: {key: prr for key, prr in prrByKey.items() if prrFilter(prr)})
|
||||
|
||||
@@ -25,22 +25,22 @@ class PrrSeriesTransformerTest(unittest.TestCase):
|
||||
'17-hydroxyprogesterone': {'6VAX-F': 1.5}
|
||||
}))
|
||||
|
||||
def test_filterByHighPrrs(self):
|
||||
def test_filterPrrs(self):
|
||||
# Given
|
||||
prrBySymptomByVaccine = pd.Series(
|
||||
{
|
||||
'6VAX-F': {'11-beta-hydroxylase deficiency': 0.6, '17-hydroxyprogesterone': 1.5},
|
||||
'ADEN': {'11-beta-hydroxylase deficiency': 1.3, '17-hydroxyprogesterone': 0.9}
|
||||
'6VAX-F': {'11-beta-hydroxylase deficiency': 2.6, '17-hydroxyprogesterone': 1.5},
|
||||
'ADEN': {'11-beta-hydroxylase deficiency': 1.3, '17-hydroxyprogesterone': 2.9}
|
||||
})
|
||||
|
||||
# When
|
||||
prrBySymptomByVaccineWithHighPrrs = PrrSeriesTransformer.filterByHighPrrs(prrBySymptomByVaccine)
|
||||
prrBySymptomByVaccineWithHighPrrs = PrrSeriesTransformer.filterPrrs(prrBySymptomByVaccine, lambda prr: prr >= 2)
|
||||
|
||||
# Then
|
||||
assert_series_equal(
|
||||
prrBySymptomByVaccineWithHighPrrs,
|
||||
pd.Series(
|
||||
{
|
||||
'6VAX-F': {'17-hydroxyprogesterone': 1.5},
|
||||
'ADEN': {'11-beta-hydroxylase deficiency': 1.3}
|
||||
'6VAX-F': {'11-beta-hydroxylase deficiency': 2.6},
|
||||
'ADEN': {'17-hydroxyprogesterone': 2.9}
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user