From dc9c08dee71fff7b2fb7b54ed8b949dfef884980 Mon Sep 17 00:00:00 2001 From: Bradley Alford Date: Wed, 27 Nov 2024 06:56:47 -0500 Subject: [PATCH] lint fixes --- examples/additive_voxels.ipynb | 4 +- examples/basic_multiplanar.ipynb | 25 ++++++---- examples/example_sideview.ipynb | 26 ++++++---- examples/mesh_layers.ipynb | 5 +- examples/widgets.ipynb | 79 ++++++++++++++++--------------- package-lock.json | 2 +- scripts/generate_options_mixin.py | 2 +- src/ipyniivue/_constants.py | 2 +- src/ipyniivue/_widget.py | 1 + 9 files changed, 81 insertions(+), 65 deletions(-) diff --git a/examples/additive_voxels.ipynb b/examples/additive_voxels.ipynb index f460dfd..f431698 100644 --- a/examples/additive_voxels.ipynb +++ b/examples/additive_voxels.ipynb @@ -7,7 +7,7 @@ "outputs": [], "source": [ "!mkdir -p ../images/\n", - "path=\"https://github.com/niivue/niivue/raw/main/demos/images/\"\n", + "path = \"https://github.com/niivue/niivue/raw/main/demos/images/\"\n", "!wget {path}narps-4735_50GV-hypo1_unthresh.nii.gz -P ../images/\n", "!wget {path}narps-4965_9U7M-hypo1_unthresh.nii.gz -P ../images/\n", "!wget {path}mni152.nii.gz -P ../images/" @@ -24,7 +24,7 @@ "# based on https://niivue.github.io/niivue/features/additive.voxels.html\n", "\n", "volumes = [\n", - " { \"path\": \"../images/mni152.nii.gz\" },\n", + " {\"path\": \"../images/mni152.nii.gz\"},\n", " {\n", " \"path\": \"../images/narps-4965_9U7M-hypo1_unthresh.nii.gz\",\n", " \"colormap\": \"red\",\n", diff --git a/examples/basic_multiplanar.ipynb b/examples/basic_multiplanar.ipynb index 72581bd..7a6a89d 100644 --- a/examples/basic_multiplanar.ipynb +++ b/examples/basic_multiplanar.ipynb @@ -7,7 +7,7 @@ "outputs": [], "source": [ "!mkdir -p ../images/\n", - "path=\"https://github.com/niivue/niivue/raw/main/demos/images/\"\n", + "path = \"https://github.com/niivue/niivue/raw/main/demos/images/\"\n", "!wget {path}mni152.nii.gz -P ../images/\n", "!wget {path}hippo.nii.gz -P ../images/" ] @@ -23,11 +23,18 @@ "# based on https://niivue.github.io/niivue/features/basic.multiplanar.html\n", "\n", "volumes = [\n", - " { \"path\": \"../images/mni152.nii.gz\", \"colormap\": \"gray\",\n", - " \"visible\": True, \"opacity\": 1.0 },\n", - " { \"path\": \"../images/hippo.nii.gz\", \"colormap\": \"red\",\n", - " \"visible\": True, \"opacity\": 1 },\n", - "\n", + " {\n", + " \"path\": \"../images/mni152.nii.gz\",\n", + " \"colormap\": \"gray\",\n", + " \"visible\": True,\n", + " \"opacity\": 1.0,\n", + " },\n", + " {\n", + " \"path\": \"../images/hippo.nii.gz\",\n", + " \"colormap\": \"red\",\n", + " \"visible\": True,\n", + " \"opacity\": 1,\n", + " },\n", "]\n", "nv = NiiVue(slice_type=SliceType.MULTIPLANAR)\n", "nv.load_volumes(volumes)\n", @@ -51,9 +58,9 @@ "outputs": [], "source": [ "nv.show_3d_crosshair = True\n", - "nv.crosshair_color = [0,1,1,1]\n", - "nv.back_color = [1,1,1,1]\n", - "nv.clip_plane_color = [0,1,1,1]\n", + "nv.crosshair_color = [0, 1, 1, 1]\n", + "nv.back_color = [1, 1, 1, 1]\n", + "nv.clip_plane_color = [0, 1, 1, 1]\n", "nv.is_colorbar = True\n", "nv.view_mode_hot_key = \"KeyN\"" ] diff --git a/examples/example_sideview.ipynb b/examples/example_sideview.ipynb index ae0f85a..0abf64b 100644 --- a/examples/example_sideview.ipynb +++ b/examples/example_sideview.ipynb @@ -132,7 +132,7 @@ ], "source": [ "!mkdir -p ../images/\n", - "path=\"https://github.com/niivue/niivue/raw/main/demos/images/\"\n", + "path = \"https://github.com/niivue/niivue/raw/main/demos/images/\"\n", "!wget {path}mni152.nii.gz -P ../images/\n", "!wget {path}hippo.nii.gz -P ../images/" ] @@ -158,27 +158,33 @@ "from ipyniivue import NiiVue, SliceType\n", "\n", "volumes = [\n", - " { \"path\": \"../images/mni152.nii.gz\", \"colormap\": \"gray\",\n", - " \"visible\": True, \"opacity\": 1.0 },\n", - " { \"path\": \"../images/hippo.nii.gz\", \"colormap\": \"red\",\n", - " \"visible\": True, \"opacity\": 1 },\n", - "\n", + " {\n", + " \"path\": \"../images/mni152.nii.gz\",\n", + " \"colormap\": \"gray\",\n", + " \"visible\": True,\n", + " \"opacity\": 1.0,\n", + " },\n", + " {\n", + " \"path\": \"../images/hippo.nii.gz\",\n", + " \"colormap\": \"red\",\n", + " \"visible\": True,\n", + " \"opacity\": 1,\n", + " },\n", "]\n", "nv = NiiVue(slice_type=SliceType.MULTIPLANAR)\n", "nv.load_volumes(volumes)\n", "\n", "\n", - "\n", "app = JupyterFrontEnd()\n", "split_panel = SplitPanel()\n", "\n", "# add the widgets to the split panel\n", "split_panel.children = [nv]\n", "\n", - "split_panel.title.label = 'NiiVue SplitPanel'\n", - "split_panel.title.icon_class = 'jp-PythonIcon'\n", + "split_panel.title.label = \"NiiVue SplitPanel\"\n", + "split_panel.title.icon_class = \"jp-PythonIcon\"\n", "split_panel.title.closable = True\n", - "app.shell.add(split_panel, 'main', { 'mode': 'split-right' })\n", + "app.shell.add(split_panel, \"main\", {\"mode\": \"split-right\"})\n", "print(\"Split panel created!\")" ] }, diff --git a/examples/mesh_layers.ipynb b/examples/mesh_layers.ipynb index 2f96cd6..cb56e90 100644 --- a/examples/mesh_layers.ipynb +++ b/examples/mesh_layers.ipynb @@ -8,7 +8,7 @@ "outputs": [], "source": [ "!mkdir -p ../images/\n", - "path=\"https://github.com/niivue/niivue/raw/main/demos/images/\"\n", + "path = \"https://github.com/niivue/niivue/raw/main/demos/images/\"\n", "!wget {path}BrainMesh_ICBM152.lh.mz3 -P ../images/\n", "!wget {path}CIT168.mz3 -P ../images/\n", "!wget {path}BrainMesh_ICBM152.lh.motor.mz3 -P ../images/" @@ -24,8 +24,7 @@ "from ipyniivue import NiiVue\n", "\n", "nv = NiiVue(\n", - " show_3d_crosshair=True, back_color=(1, 1, 1, 1),\n", - " mesh_x_ray=0.3, is_colorbar=True\n", + " show_3d_crosshair=True, back_color=(1, 1, 1, 1), mesh_x_ray=0.3, is_colorbar=True\n", ")\n", "\n", "mesh_layer = {\n", diff --git a/examples/widgets.ipynb b/examples/widgets.ipynb index da2f09c..e1c468c 100644 --- a/examples/widgets.ipynb +++ b/examples/widgets.ipynb @@ -8,7 +8,7 @@ "outputs": [], "source": [ "!mkdir -p ../images/\n", - "path=\"https://github.com/niivue/niivue/raw/main/demos/images/\"\n", + "path = \"https://github.com/niivue/niivue/raw/main/demos/images/\"\n", "!wget {path}mni152.nii.gz -P ../images/\n", "!wget {path}hippo.nii.gz -P ../images/" ] @@ -25,10 +25,18 @@ "from ipyniivue import NiiVue, SliceType, WidgetObserver\n", "\n", "volumes = [\n", - " { \"path\": \"../images/mni152.nii.gz\", \"colormap\": \"gray\",\n", - " \"visible\": True, \"opacity\": 1.0 },\n", - " { \"path\": \"../images/hippo.nii.gz\", \"colormap\": \"red\",\n", - " \"visible\": True, \"opacity\": 1.0 },\n", + " {\n", + " \"path\": \"../images/mni152.nii.gz\",\n", + " \"colormap\": \"gray\",\n", + " \"visible\": True,\n", + " \"opacity\": 1.0,\n", + " },\n", + " {\n", + " \"path\": \"../images/hippo.nii.gz\",\n", + " \"colormap\": \"red\",\n", + " \"visible\": True,\n", + " \"opacity\": 1.0,\n", + " },\n", "]\n", "\n", "nv = NiiVue(slice_type=SliceType.MULTIPLANAR)\n", @@ -37,74 +45,69 @@ "widgetArray = []\n", "\n", "widget_slice_type = {\n", - "\n", " \"widget\": ipywidgets.RadioButtons(\n", - " options=[('Axial', 0), ('Coronal', 1), ('Sagittal', 2),\n", - " ('Multiplanar', 3), ('Render', 4)],\n", + " options=[\n", + " (\"Axial\", 0),\n", + " (\"Coronal\", 1),\n", + " (\"Sagittal\", 2),\n", + " (\"Multiplanar\", 3),\n", + " (\"Render\", 4),\n", + " ],\n", " value=3,\n", - " description='Slice Type:'),\n", - "\n", + " description=\"Slice Type:\",\n", + " ),\n", " \"object\": nv,\n", - "\n", - " \"attribute\": \"slice_type\"\n", + " \"attribute\": \"slice_type\",\n", "}\n", "widgetArray.append(widget_slice_type)\n", "\n", "widget_scan_opacity = {\n", - "\n", " \"widget\": ipywidgets.FloatSlider(\n", " value=1.0,\n", " min=0.0,\n", " max=1.0,\n", " step=0.1,\n", - " description='Scan Opacity:',\n", - " orientation='horizontal'),\n", - "\n", + " description=\"Scan Opacity:\",\n", + " orientation=\"horizontal\",\n", + " ),\n", " \"object\": nv.volumes[0],\n", - "\n", - " \"attribute\": \"opacity\"\n", + " \"attribute\": \"opacity\",\n", "}\n", "widgetArray.append(widget_scan_opacity)\n", "\n", "widget_hippo_opacity = {\n", - "\n", " \"widget\": ipywidgets.FloatSlider(\n", " value=1.0,\n", " min=0.0,\n", " max=1.0,\n", " step=0.1,\n", - " description='Hippocampus Opacity:',\n", - " orientation='horizontal'),\n", - "\n", + " description=\"Hippocampus Opacity:\",\n", + " orientation=\"horizontal\",\n", + " ),\n", " \"object\": nv.volumes[1],\n", - "\n", - " \"attribute\": \"opacity\"\n", + " \"attribute\": \"opacity\",\n", "}\n", "widgetArray.append(widget_hippo_opacity)\n", "\n", "widget_scan_colormap = {\n", - "\n", " \"widget\": ipywidgets.Select(\n", - " options=['Gray', 'Red', 'Blue', 'Green'],\n", - " value='Gray',\n", - " description='Scan Colormap:'),\n", - "\n", + " options=[\"Gray\", \"Red\", \"Blue\", \"Green\"],\n", + " value=\"Gray\",\n", + " description=\"Scan Colormap:\",\n", + " ),\n", " \"object\": nv.volumes[0],\n", - "\n", - " \"attribute\": \"colormap\"\n", + " \"attribute\": \"colormap\",\n", "}\n", "widgetArray.append(widget_scan_colormap)\n", "\n", "widget_hippo_colormap = {\n", - "\n", " \"widget\": ipywidgets.Select(\n", - " options=['Red', 'Blue', 'Green', 'Gray'],\n", - " value='Red',\n", - " description='Hippocampus Colormap:'),\n", - "\n", + " options=[\"Red\", \"Blue\", \"Green\", \"Gray\"],\n", + " value=\"Red\",\n", + " description=\"Hippocampus Colormap:\",\n", + " ),\n", " \"object\": nv.volumes[1],\n", - "\n", - " \"attribute\": \"colormap\"\n", + " \"attribute\": \"colormap\",\n", "}\n", "widgetArray.append(widget_hippo_colormap)\n", "\n", diff --git a/package-lock.json b/package-lock.json index fa2b96d..b2d5f06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "ipyniivue", + "name": "bca-ipyniivue", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/scripts/generate_options_mixin.py b/scripts/generate_options_mixin.py index 3957964..8cc6208 100644 --- a/scripts/generate_options_mixin.py +++ b/scripts/generate_options_mixin.py @@ -58,7 +58,7 @@ def get_value(value: typing.Any): return repr(value) -def generate_mixin(options: typing.Dict[str, typing.Any]): +def generate_mixin(options: typing.dict[str, typing.Any]): lines = [ "# This file is automatically generated by scripts/generate_options_mixin.py", "# Do not edit this file directly", diff --git a/src/ipyniivue/_constants.py b/src/ipyniivue/_constants.py index fc4ebc7..6ea1a49 100644 --- a/src/ipyniivue/_constants.py +++ b/src/ipyniivue/_constants.py @@ -1,9 +1,9 @@ import enum __all__ = [ - "SliceType", "DragMode", "MuliplanarType", + "SliceType", ] diff --git a/src/ipyniivue/_widget.py b/src/ipyniivue/_widget.py index 2c67df6..41e8e43 100644 --- a/src/ipyniivue/_widget.py +++ b/src/ipyniivue/_widget.py @@ -111,6 +111,7 @@ def meshes(self): """Returns the list of meshes.""" return list(self._meshes) + class WidgetObserver: """Sets an observed for `widget` on the `attribute` of `object`."""