displacing "Lower Confidence Limit of Proportional Reporting Ratio"

This commit is contained in:
frankknoll
2023-11-24 00:12:53 +01:00
parent c834126726
commit fa058a30fd
8 changed files with 18766 additions and 252 deletions

View File

@@ -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)})

View File

@@ -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}
}))