im Barchart gibt es mindestens N Guessed-Einträge
This commit is contained in:
@@ -1,12 +1,26 @@
|
||||
import math
|
||||
|
||||
|
||||
class BarChartDescriptionTables:
|
||||
|
||||
@staticmethod
|
||||
def filterValidJensenShannonDistances(barChartDescriptionTable):
|
||||
return barChartDescriptionTable[barChartDescriptionTable.apply(BarChartDescriptionTables._isValidJensenShannonDistance, axis = 'columns')]
|
||||
return barChartDescriptionTable[barChartDescriptionTable.apply(BarChartDescriptionTables._isValidJensenShannonDistance, axis='columns')]
|
||||
|
||||
@staticmethod
|
||||
def _isValidJensenShannonDistance(barChartDescription):
|
||||
jensenShannonDistance = barChartDescription['BAR_CHART_DESCRIPTION']['Jensen-Shannon distance']
|
||||
return not math.isnan(jensenShannonDistance)
|
||||
|
||||
@staticmethod
|
||||
def filterHasMinSizeOfGuessedHistogram(barChartDescriptionTable, minSizeOfGuessedHistogram):
|
||||
return barChartDescriptionTable[
|
||||
barChartDescriptionTable.apply(
|
||||
lambda barChartDescription: BarChartDescriptionTables._hasMinSizeOfGuessedHistogram(
|
||||
barChartDescription, minSizeOfGuessedHistogram),
|
||||
axis='columns')]
|
||||
|
||||
@staticmethod
|
||||
def _hasMinSizeOfGuessedHistogram(barChartDescription, minSizeOfGuessedHistogram):
|
||||
sizeOfGuessedHistogram = sum(barChartDescription['BAR_CHART_DESCRIPTION']['Adverse Reaction Reports guessed'])
|
||||
return sizeOfGuessedHistogram >= minSizeOfGuessedHistogram
|
||||
|
||||
@@ -60,3 +60,66 @@ class BarChartDescriptionTablesTest(unittest.TestCase):
|
||||
],
|
||||
name = 'VAX_LOT')),
|
||||
check_dtype = True)
|
||||
|
||||
def test_filterHasMinSizeOfGuessedHistogram(self):
|
||||
# Given
|
||||
barChartDescriptionTable = TestHelper.createDataFrame(
|
||||
columns = ['BAR_CHART_DESCRIPTION'],
|
||||
data = [
|
||||
[
|
||||
{
|
||||
'countries': ['Germany', 'Hungary'],
|
||||
'Adverse Reaction Reports guessed': [10, 20],
|
||||
'Adverse Reaction Reports known': [20, 30],
|
||||
'Jensen-Shannon distance': 0.4711
|
||||
}
|
||||
]
|
||||
],
|
||||
index = pd.Index(
|
||||
[
|
||||
'!D0181'
|
||||
],
|
||||
name = 'VAX_LOT'))
|
||||
|
||||
# When
|
||||
barChartDescriptionTableResult = BarChartDescriptionTables.filterHasMinSizeOfGuessedHistogram(barChartDescriptionTable, 20)
|
||||
|
||||
# Then
|
||||
assert_frame_equal(
|
||||
barChartDescriptionTableResult,
|
||||
barChartDescriptionTable,
|
||||
check_dtype = True)
|
||||
|
||||
def test_filterHasMinSizeOfGuessedHistogram2(self):
|
||||
# Given
|
||||
barChartDescriptionTable = TestHelper.createDataFrame(
|
||||
columns = ['BAR_CHART_DESCRIPTION'],
|
||||
data = [
|
||||
[
|
||||
{
|
||||
'countries': ['Germany', 'Hungary'],
|
||||
'Adverse Reaction Reports guessed': [10, 20],
|
||||
'Adverse Reaction Reports known': [20, 30],
|
||||
'Jensen-Shannon distance': 0.4711
|
||||
}
|
||||
]
|
||||
],
|
||||
index = pd.Index(
|
||||
[
|
||||
'!D0181'
|
||||
],
|
||||
name = 'VAX_LOT'))
|
||||
|
||||
# When
|
||||
barChartDescriptionTableResult = BarChartDescriptionTables.filterHasMinSizeOfGuessedHistogram(barChartDescriptionTable, 31)
|
||||
|
||||
# Then
|
||||
assert_frame_equal(
|
||||
barChartDescriptionTableResult,
|
||||
TestHelper.createDataFrame(
|
||||
columns = ['BAR_CHART_DESCRIPTION'],
|
||||
data = [],
|
||||
index = pd.Index(
|
||||
[],
|
||||
name = 'VAX_LOT')),
|
||||
check_dtype = True)
|
||||
|
||||
@@ -6,7 +6,6 @@ FK-TODO:
|
||||
- add google captcha to batchCodeTable.html
|
||||
- Symptomhistogramm
|
||||
- Filter für ein Barchart:
|
||||
- im Barchart gibt es mindestens N Guessed-Einträge
|
||||
- im Barchart gibt es mindestens ein Country mit Guessed > Known
|
||||
|
||||
anacron job:
|
||||
|
||||
Reference in New Issue
Block a user