Skip to content
Snippets Groups Projects
Commit 5643abc5 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

no subset means select everything

parent a8019dc5
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -19,8 +19,6 @@ class CorrelationTask(AnalyticTask):
raise ValueError("X or Y are malformed.")
if method not in ['pearson', 'spearman', 'kendall']:
raise ValueError("Unknown method '{}'".format(method))
if len(subsets) == 0:
raise ValueError("No subsets specified.")
df = pd.merge(x, y, on='id')
df = df.dropna()
......@@ -32,6 +30,9 @@ class CorrelationTask(AnalyticTask):
if df.shape[0] == 0:
raise ValueError("The current selection does not match any data.")
if not subsets:
subsets = [df['id']]
output = {
'subsets': {}
}
......@@ -55,6 +56,7 @@ class CorrelationTask(AnalyticTask):
output.update(global_stats)
output['method'] = method
output['data'] = df.to_json()
df = df.drop('id', 1)
output['x_label'] = list(df)[0]
output['y_label'] = list(df)[1]
return output
......
......@@ -23,10 +23,10 @@ class TestCorrelation:
assert result['slope']
assert result['intercept']
assert result['subsets']
assert result['method']
assert result['method'] == 'pearson'
assert result['data']
assert result['x_label']
assert result['y_label']
assert result['x_label'] == 'A'
assert result['y_label'] == 'B'
def test_returns_expected_output_2(self):
task = CorrelationTask()
......@@ -45,9 +45,11 @@ class TestCorrelation:
arr_2 = np.c_[range(20), np.random.randint(0, 100, size=(20, 1))]
x = pd.DataFrame(arr_1, columns=['id', 'A'])
y = pd.DataFrame(arr_2, columns=['id', 'B'])
with pytest.raises(ValueError):
task.main(x=x, y=y, id_filter=list(range(20)),
method='pearson', subsets=[])
result_1 = task.main(x=x, y=y, id_filter=list(range(20)),
method='pearson', subsets=[])
result_2 = task.main(x=x, y=y, id_filter=list(range(20)),
method='pearson', subsets=[list(range(20))])
assert result_1 == result_2
def test_returns_expected_output_4(self):
task = CorrelationTask()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment