Commit 0a6d4fe7 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

fixed a bug in the heatmap code

parent e370b0f3
Pipeline #2265 failed with stage
in 1 minute and 2 seconds
...@@ -33,7 +33,7 @@ class HeatmapTask(AnalyticTask): ...@@ -33,7 +33,7 @@ class HeatmapTask(AnalyticTask):
df = reduce(lambda a, b: a.append(b), numerical_arrays) df = reduce(lambda a, b: a.append(b), numerical_arrays)
if not subsets: if not subsets:
# empty subsets equals all samples in one subset # empty subsets equals all samples in one subset
subsets = df['id'].unique() subsets = [df['id'].unique().tolist()]
else: else:
# if subsets are defined we drop the rows that are not part of one # if subsets are defined we drop the rows that are not part of one
flattened_subsets = [x for subset in subsets for x in subset] flattened_subsets = [x for subset in subsets for x in subset]
......
...@@ -61,3 +61,25 @@ class TestHeatmap: ...@@ -61,3 +61,25 @@ class TestHeatmap:
id_filter=[], id_filter=[],
subsets=subsets) subsets=subsets)
assert 'specified subsets does not match' in e assert 'specified subsets does not match' in e
def test_empty_subset_equals_full_subset(self):
numerical_arrays = [
pd.DataFrame([[101, 'foo', 5], [101, 'bar', 6], [102, 'foo', 10],
[102, 'bar', 11], [103, 'foo', 15], [103, 'bar', 16],
[104, 'foo', 20], [104, 'bar', 21]],
columns=['id', 'feature', 'value'])
]
result_1 = self.task.main(numerical_arrays=numerical_arrays,
numericals=[],
categoricals=[],
ranking_method='mean',
id_filter=[],
subsets=[])
result_2 = self.task.main(numerical_arrays=numerical_arrays,
numericals=[],
categoricals=[],
ranking_method='mean',
id_filter=[],
subsets=[[101, 102, 103, 104]])
assert result_1 == result_2
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment