-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EBR-43: resolve sonar warnings #70
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
# (c) 2022-2023, TVB Widgets Team | ||
# | ||
|
||
import math | ||
import numpy as np | ||
import pytest | ||
import logging | ||
|
@@ -43,7 +44,7 @@ | |
# =========================================== WIDGET CREATION ========================================================== | ||
def test_get_widget(tsw_tvb_data): | ||
tsw_tvb_data.get_widget() | ||
assert type(tsw_tvb_data) == TimeSeriesWidgetMNE | ||
assert isinstance(tsw_tvb_data, TimeSeriesWidgetMNE) | ||
|
||
|
||
def test_create_ts_widget(tsw): | ||
|
@@ -67,7 +68,7 @@ | |
|
||
assert tsw.data == wrapper_tvb | ||
assert tsw.sample_freq == 4000 | ||
assert tsw.displayed_period == 0.75 | ||
assert math.isclose(tsw.displayed_period, 0.75) | ||
assert len(tsw.ch_names) == len(tsw.ch_order) == len(tsw.ch_types) == 76 | ||
assert tsw.raw.get_data().shape == (76, 4000) | ||
|
||
|
@@ -104,7 +105,8 @@ | |
|
||
def test_dimensions_selection_update(tsw_tvb_data): | ||
# simulate unchecking of some checkboxes | ||
false_cb_idx = list(np.random.choice(76, size=3, replace=False)) | ||
rng = np.random.default_rng() | ||
Check notice Code scanning / SonarCloud Results that depend on random number generation should be reproducible Low test
Provide a seed for this random generator. See more on SonarCloud
|
||
false_cb_idx = list(rng.choice(76, size=3, replace=False)) | ||
false_cb_names = [f'sig {x}' for x in false_cb_idx] | ||
for cb_name in false_cb_names: | ||
tsw_tvb_data.checkboxes[cb_name].value = False | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,8 +97,9 @@ | |
|
||
def _generate_connectivity(no_of_regions): | ||
labels = np.array(['sig ' + str(i) for i in range(no_of_regions)]) | ||
conn = connectivity.Connectivity(centres=np.random.rand(no_of_regions, 3), | ||
rng = np.random.default_rng() | ||
Check notice Code scanning / SonarCloud Results that depend on random number generation should be reproducible Low test
Provide a seed for this random generator. See more on SonarCloud
|
||
conn = connectivity.Connectivity(centres=rng.random(size=(no_of_regions, 3)), | ||
region_labels=labels, | ||
weights=np.random.rand(no_of_regions, no_of_regions), | ||
tract_lengths=np.random.rand(no_of_regions, no_of_regions)) | ||
weights=rng.random(size=(no_of_regions, no_of_regions)), | ||
tract_lengths=rng.random(size=(no_of_regions, no_of_regions))) | ||
return conn |
Check notice
Code scanning / SonarCloud
Results that depend on random number generation should be reproducible Low test