diff --git a/examples/GettersAndSetters.ipynb b/examples/GettersAndSetters.ipynb index 4af965a5..97f8d834 100644 --- a/examples/GettersAndSetters.ipynb +++ b/examples/GettersAndSetters.ipynb @@ -10,29 +10,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "fe98672b-e45e-4335-8774-b640f03b42fc", "metadata": {}, "outputs": [], "source": [ "import sys\n", "\n", - "!{sys.executable} -m pip install -q imageio \"itkwidgets[all]>=1.0a16\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ec4b0fcb-f530-41ac-bf8a-c416abe81f80", - "metadata": {}, - "outputs": [], - "source": [ - "!pip list | grep itkwidgets" + "!{sys.executable} -m pip install -q imageio \"itkwidgets[all]>=1.0a40\"" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "0b473680-9fd6-4fe3-bba6-9ec1f7629f95", "metadata": {}, "outputs": [], @@ -48,17 +38,63 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "7034b25e-0819-44de-921e-01e3d1f9c8d6", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/javascript": [ + "window.connectPlugin && window.connectPlugin(\"fc421889-e285-44fd-83ac-82032cc5c75d\")" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "viewer = view()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "0e461bcb-d716-445a-b94e-83e2280bdd1e", "metadata": {}, "outputs": [], @@ -68,7 +104,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "e22dc371-0fd4-4e43-822d-17bc986346df", "metadata": {}, "outputs": [], @@ -81,17 +117,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "489acf98-23c5-4fe8-943f-6ddda2a15b02", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[0, 0, 0]\n" + ] + } + ], "source": [ "print(bgcolor)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "f222da3b-905a-41ec-a2fa-98462697f2d6", "metadata": {}, "outputs": [], @@ -104,17 +148,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "40a146ac-ebbe-4aeb-ab5d-ec678af2ef8c", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False True\n" + ] + } + ], "source": [ "print(annotations, axes)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "id": "f669acad-490e-4249-a380-ddd4dbc08ba5", "metadata": {}, "outputs": [], @@ -128,17 +180,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "id": "0326096b-6f24-4793-b3a5-655c746c1a36", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Composite Inferno (matplotlib)\n" + ] + } + ], "source": [ "print(blend, cmap)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "id": "5992da8e-012a-41ab-95a8-eb1dc1d2219c", "metadata": {}, "outputs": [], @@ -150,17 +210,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "id": "dae864ed-50d1-4a88-a930-c05fbc43896a", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "None None\n" + ] + } + ], "source": [ "print(color_range, color_range_bounds)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "id": "1167bc55-8f15-43d5-9ab8-c2b43cfacc4d", "metadata": {}, "outputs": [], @@ -174,7 +242,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "25d5cf6f-79c0-43bd-8f9c-aeb7e6092763", "metadata": {}, "outputs": [], @@ -184,10 +252,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "id": "371c4281-e13d-4b64-8858-724c07af5c21", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "TypeError", + "evalue": "get_image_component_visibility() missing 1 required positional argument: 'component'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[16], line 4\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# THIS CELL *SHOULD* RAISE AN EXCEPTION\u001b[39;00m\n\u001b[1;32m 3\u001b[0m viewer\u001b[38;5;241m.\u001b[39mset_image_component_visibility(\u001b[38;5;28;01mFalse\u001b[39;00m)\n\u001b[0;32m----> 4\u001b[0m vis \u001b[38;5;241m=\u001b[39m \u001b[43mviewer\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_image_component_visibility\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# This getter needs a component value passed in\u001b[39;00m\n\u001b[1;32m 5\u001b[0m viewer\u001b[38;5;241m.\u001b[39mset_image_gradient_opacity(\u001b[38;5;241m0.5\u001b[39m)\n\u001b[1;32m 6\u001b[0m opacity \u001b[38;5;241m=\u001b[39m viewer\u001b[38;5;241m.\u001b[39mget_image_gradient_opacity()\n", + "File \u001b[0;32m~/itkwidgets/itkwidgets/viewer.py:166\u001b[0m, in \u001b[0;36mViewer.fetch_value.._fetch_value\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 164\u001b[0m \u001b[38;5;129m@functools\u001b[39m\u001b[38;5;241m.\u001b[39mwraps(func)\n\u001b[1;32m 165\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_fetch_value\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[0;32m--> 166\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 167\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m isawaitable(result):\n\u001b[1;32m 168\u001b[0m future \u001b[38;5;241m=\u001b[39m asyncio\u001b[38;5;241m.\u001b[39mensure_future(result)\n", + "\u001b[0;31mTypeError\u001b[0m: get_image_component_visibility() missing 1 required positional argument: 'component'" + ] + } + ], "source": [ "# THIS CELL *SHOULD* RAISE AN EXCEPTION\n", "\n", @@ -199,7 +280,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "id": "db939e10-724e-4725-bfa1-4f1e27bd06e7", "metadata": {}, "outputs": [], @@ -214,17 +295,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "id": "0fb27984-2947-4955-89ff-bbe41432c5d9", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True 0.5\n" + ] + } + ], "source": [ "print(vis, opacity)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "id": "86c0d8f1-019f-48f6-8990-9ff0f6130e35", "metadata": {}, "outputs": [], @@ -237,17 +326,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "id": "4bb6898e-293b-4958-916d-8ac642256348", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.3 True\n" + ] + } + ], "source": [ "print(grad_op_scale, interp)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "id": "27f35c0c-b5d5-4e4a-ac87-c0e4aee24234", "metadata": {}, "outputs": [], @@ -259,17 +356,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "id": "90886287-1458-496b-8bc2-1e7589dffc55", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "None False\n" + ] + } + ], "source": [ "print(gauss, shadow)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "id": "8096f9e4-5589-4089-8a37-8dbac4c7509b", "metadata": {}, "outputs": [], @@ -282,17 +387,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "id": "84396cd6-f292-43be-b09d-d55cecef6d8a", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.5 0.5\n" + ] + } + ], "source": [ "print(sample_dist, scatter)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "id": "287a3c46-b0aa-4ccd-8e6a-a91a9a465bc1", "metadata": {}, "outputs": [], @@ -303,17 +416,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "id": "f88d8ca5-01a6-4d63-9d22-70dc778b6507", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n" + ] + } + ], "source": [ "print(layer_vis)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "id": "f904feb6-814f-431f-92a2-25a7bd838a00", "metadata": {}, "outputs": [], @@ -325,17 +446,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "id": "8e2cc630-978c-4cdc-9e27-379b10b4fb8b", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'position': 'relative', 'width': '100%', 'height': 'auto', 'minHeight': '200px', 'minWidth': '450px', 'margin': '0', 'padding': '0', 'top': '0', 'left': '0', 'flex': '1 1 0px', 'overflow': 'hidden'} True\n" + ] + } + ], "source": [ "print(container, rotate)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "id": "cf5fd544-fac0-4f8d-ab22-7721abd5ae1d", "metadata": {}, "outputs": [], @@ -346,17 +475,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "id": "bd49c232-ae23-4f56-80a2-1b26b307c458", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'position': 'relative', 'width': '75%', 'height': 'auto', 'minHeight': '200px', 'minWidth': '450px', 'margin': '0', 'padding': '0', 'top': '0', 'left': '0', 'flex': '1 1 0px', 'overflow': 'hidden'}\n" + ] + } + ], "source": [ "print(container)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "id": "0573093a-04a0-4199-b061-ecad857d0cee", "metadata": {}, "outputs": [], @@ -369,17 +506,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "id": "31731d41-a581-4661-86d1-af9cf49a6282", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False mm\n" + ] + } + ], "source": [ "print(collapsed, units)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 33, "id": "aca37e1b-d920-48d4-90ca-fda100b97175", "metadata": {}, "outputs": [], @@ -392,17 +537,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 34, "id": "cf94e432-3583-4f84-97ca-4815d5c40336", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "YPlane ['Image']\n" + ] + } + ], "source": [ "print(view_mode, layers)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 35, "id": "88802dec-461f-4a91-a19d-db8f3ea8a626", "metadata": {}, "outputs": [], @@ -418,13 +571,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 36, "id": "bbcda0e3-251c-41f0-842a-2f8b95cabbfb", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "59.5 49.5 153.5\n" + ] + } + ], "source": [ "print(x_slice, y_slice, z_slice)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "32b3bfa9-df32-460b-9f0c-405b14769bfb", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": {