From 8aa743a1e62e806f2a495a7e48d9989900c098ba Mon Sep 17 00:00:00 2001 From: frankknoll Date: Mon, 9 Oct 2023 11:18:04 +0200 Subject: [PATCH] starting AnalyzerTest --- .gitignore | 1 + src/SymptomsCausedByVaccines/Analyzer.py | 9 ++++++ src/SymptomsCausedByVaccines/AnalyzerTest.py | 33 ++++++++++++++++++++ src/SymptomsCausedByVaccines/__init__.py | 0 4 files changed, 43 insertions(+) create mode 100644 src/SymptomsCausedByVaccines/Analyzer.py create mode 100644 src/SymptomsCausedByVaccines/AnalyzerTest.py create mode 100644 src/SymptomsCausedByVaccines/__init__.py diff --git a/.gitignore b/.gitignore index fb12341fb23..0a12bc1c9c5 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ src/intensivstationen/__pycache__/ google-chrome-stable_current_amd64* src/captcha/__pycache__ src/GoogleAnalytics/__pycache__ +src/SymptomsCausedByVaccines/__pycache__ diff --git a/src/SymptomsCausedByVaccines/Analyzer.py b/src/SymptomsCausedByVaccines/Analyzer.py new file mode 100644 index 00000000000..36b5577d978 --- /dev/null +++ b/src/SymptomsCausedByVaccines/Analyzer.py @@ -0,0 +1,9 @@ +import pandas as pd + +class Analyzer: + + def __init__(self, symptomByVaccine: pd.DataFrame): + self.symptomByVaccine = symptomByVaccine + + def getSymptomsForVaccine(self, vaxType): + return self.symptomByVaccine.loc[vaxType] diff --git a/src/SymptomsCausedByVaccines/AnalyzerTest.py b/src/SymptomsCausedByVaccines/AnalyzerTest.py new file mode 100644 index 00000000000..6988d9c14c9 --- /dev/null +++ b/src/SymptomsCausedByVaccines/AnalyzerTest.py @@ -0,0 +1,33 @@ +import unittest +from pandas.testing import assert_series_equal +from TestHelper import TestHelper +import pandas as pd +from SymptomsCausedByVaccines.Analyzer import Analyzer + +class AnalyzerTest(unittest.TestCase): + + # input a vaccine name, and see which symptoms are strongest for it. + def test_getSymptomsForVaccine(self): + # Given + symptomByVaccine = TestHelper.createDataFrame( + columns = ['11-beta-hydroxylase deficiency', '17-hydroxyprogesterone'], + data = [ [0.6, 0.4]], + index = pd.Index( + name = 'VAX_TYPE', + data = ['6VAX-F'])) + + analyzer = Analyzer(symptomByVaccine) + + # When + symptomsForVaccine = analyzer.getSymptomsForVaccine('6VAX-F') + + # Then + assert_series_equal( + symptomsForVaccine, + pd.Series( + name = '6VAX-F', + data = { + '11-beta-hydroxylase deficiency': 0.6, + '17-hydroxyprogesterone': 0.4 + })) + diff --git a/src/SymptomsCausedByVaccines/__init__.py b/src/SymptomsCausedByVaccines/__init__.py new file mode 100644 index 00000000000..e69de29bb2d