Skip to content

Commit

Permalink
Fix SonarCloud suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
romina1601 committed Sep 12, 2024
1 parent a6ba79e commit 898f6d0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
3 changes: 2 additions & 1 deletion notebooks/DicomWidget.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@
"outputs": [],
"source": [
"# create demo array just to demonstrate the usage of the API\n",
"data = np.random.rand(255,255,255)"
"rng = np.random.default_rng()\n",
"data = rng.random((255,255,255))"
]
},
{
Expand Down
27 changes: 14 additions & 13 deletions notebooks/TimeSeriesArray.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "56d5c4b6-7804-46d6-931f-fcc5593977d1",
"metadata": {},
"outputs": [],
Expand All @@ -38,21 +38,13 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "28420169-2274-4e0e-a73d-c1ab54e6da9c",
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"12-05-2023 03:15:02 - INFO - tvbwidgets.core.pse.parameters - ImportError: Dask dependency is not included, so this functionality won't be available\n"
]
}
],
"outputs": [],
"source": [
"import numpy as np\n",
"from tvbwidgets.api import plot_timeseries"
Expand All @@ -73,7 +65,8 @@
"metadata": {},
"outputs": [],
"source": [
"raw = np.random.rand(30000, 50)"
"rng = np.random.default_rng()\n",
"raw = rng.random((30000, 50))"
]
},
{
Expand Down Expand Up @@ -103,6 +96,14 @@
"source": [
"tsw = plot_timeseries(data=raw, sample_freq=0.1, ch_idx=1, backend=backend)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a26933b8-b43f-4442-8af1-b79565293e9b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -121,7 +122,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.9.18"
}
},
"nbformat": 4,
Expand Down
9 changes: 7 additions & 2 deletions tvbwidgets/ui/connectivity_matrix_editor_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
import matplotlib.colors as mcolors
from IPython.display import display
from tvb.datatypes.connectivity import Connectivity

from tvbwidgets import get_logger
from tvbwidgets.ui.base_widget import TVBWidget

LOGGER = get_logger(__name__)


class ConnectivityMatrixEditor(TVBWidget):
def __init__(self, connectivity, size=None, **kwargs):
Expand Down Expand Up @@ -49,7 +53,7 @@ def _make_header(self):

self.change_button = widgets.Button(description="Change",
layout=widgets.Layout(width="80px", visibility="hidden"))
self.change_button.on_click(lambda change: self.on_apply_change(change))
self.change_button.on_click(self.on_apply_change)

self.save_button = widgets.Button(description="Save",
layout=widgets.Layout(width="100px", margin='0 0 0 auto'))
Expand Down Expand Up @@ -239,7 +243,8 @@ def on_apply_change(self, change):
matrix_ui = getattr(self, matrix_name)
try:
value = float(self.cell_value.value)
except:
except (ValueError, TypeError):
LOGGER.error(f'An exception occurred when retrieving the cell value.')
value = None

if value is not None:
Expand Down
2 changes: 1 addition & 1 deletion tvbwidgets/ui/spacetime_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _prepare_slices(self):


def _create_graph_slice(self, i):
z_coordinate = -i*3 + 14 if i is 0 else -i*2 + 11 - 0.1*i*i
z_coordinate = -i*3 + 14 if i == 0 else -i*2 + 11 - 0.1*i*i
return p3.Mesh(
p3.BoxBufferGeometry(width=7, height=7, depth=0.1),
p3.MeshPhysicalMaterial(),
Expand Down

0 comments on commit 898f6d0

Please sign in to comment.