refining BarChartDescriptionTablesTest
This commit is contained in:
@@ -18,8 +18,7 @@ class BarChartDescriptionTables:
|
||||
|
||||
@staticmethod
|
||||
def hasMinSizeOfGuessedHistogram(barChartDescription, minSizeOfGuessedHistogram):
|
||||
sizeOfGuessedHistogram = sum(
|
||||
barChartDescription['Adverse Reaction Reports guessed'])
|
||||
sizeOfGuessedHistogram = sum(barChartDescription['Adverse Reaction Reports guessed'])
|
||||
return sizeOfGuessedHistogram >= minSizeOfGuessedHistogram
|
||||
|
||||
@staticmethod
|
||||
@@ -27,3 +26,9 @@ class BarChartDescriptionTables:
|
||||
guessedBarChart = barChartDescription['Adverse Reaction Reports guessed']
|
||||
knownBarChart = barChartDescription['Adverse Reaction Reports known']
|
||||
return np.any(np.asarray(guessedBarChart) > np.asarray(knownBarChart))
|
||||
|
||||
@staticmethod
|
||||
def isGuessedGreaterThanKnown(barChartDescription):
|
||||
sizeOfGuessedHistogram = sum(barChartDescription['Adverse Reaction Reports guessed'])
|
||||
sizeOfKnownHistogram = sum(barChartDescription['Adverse Reaction Reports known'])
|
||||
return sizeOfGuessedHistogram >= sizeOfKnownHistogram
|
||||
|
||||
@@ -193,3 +193,58 @@ class BarChartDescriptionTablesTest(unittest.TestCase):
|
||||
],
|
||||
name='VAX_LOT')),
|
||||
check_dtype=True)
|
||||
|
||||
def test_filterIsGuessedGreaterThanKnown(self):
|
||||
# Given
|
||||
barChartDescriptionTable = TestHelper.createDataFrame(
|
||||
columns=['BAR_CHART_DESCRIPTION'],
|
||||
data=[
|
||||
[
|
||||
{
|
||||
'countries': ['Germany', 'Hungary'],
|
||||
'Adverse Reaction Reports guessed': [250, 1],
|
||||
'Adverse Reaction Reports known': [240, 9],
|
||||
'Jensen-Shannon distance': 0.4711
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
'countries': ['Germany', 'America'],
|
||||
'Adverse Reaction Reports guessed': [25, 2000],
|
||||
'Adverse Reaction Reports known': [5000, 200],
|
||||
'Jensen-Shannon distance': 0.815
|
||||
}
|
||||
]],
|
||||
index=pd.Index(
|
||||
[
|
||||
'!D0181',
|
||||
'some batch code'
|
||||
],
|
||||
name='VAX_LOT'))
|
||||
|
||||
# When
|
||||
barChartDescriptionTableResult = BarChartDescriptionTables.filter(
|
||||
barChartDescriptionTable,
|
||||
BarChartDescriptionTables.isGuessedGreaterThanKnown)
|
||||
|
||||
# Then
|
||||
assert_frame_equal(
|
||||
barChartDescriptionTableResult,
|
||||
TestHelper.createDataFrame(
|
||||
columns=['BAR_CHART_DESCRIPTION'],
|
||||
data=[
|
||||
[
|
||||
{
|
||||
'countries': ['Germany', 'Hungary'],
|
||||
'Adverse Reaction Reports guessed': [250, 1],
|
||||
'Adverse Reaction Reports known': [240, 9],
|
||||
'Jensen-Shannon distance': 0.4711
|
||||
}
|
||||
]
|
||||
],
|
||||
index=pd.Index(
|
||||
[
|
||||
'!D0181'
|
||||
],
|
||||
name='VAX_LOT')),
|
||||
check_dtype=True)
|
||||
|
||||
Reference in New Issue
Block a user