diff --git a/docs/readme_link.rst b/docs/readme_link.rst
index 7592303f..bdff72a8 100644
--- a/docs/readme_link.rst
+++ b/docs/readme_link.rst
@@ -1 +1 @@
-.. include:: ../../README.md
+.. include:: ../README.md
diff --git a/docs/tutorials/CONFTYPES.ipynb b/docs/tutorials/CONFTYPES.ipynb
index 4cc24620..607532da 100644
--- a/docs/tutorials/CONFTYPES.ipynb
+++ b/docs/tutorials/CONFTYPES.ipynb
@@ -22,9 +22,7 @@
"metadata": {},
"outputs": [],
"source": [
- "import larvaworld\n",
- "\n",
- "from larvaworld.lib import util, reg, process, sim"
+ "from larvaworld.lib import reg, sim, util"
]
},
{
@@ -106,7 +104,7 @@
"metadata": {},
"outputs": [],
"source": [
- "print(f\"The number of stored configurations per conftype & some example IDs:\")\n",
+ "print(\"The number of stored configurations per conftype & some example IDs:\")\n",
"print()\n",
"for k in reg.CONFTYPES:\n",
" ct = reg.conf[k]\n",
diff --git a/docs/tutorials/LabFormat.ipynb b/docs/tutorials/LabFormat.ipynb
index aba3c791..e07c4cce 100644
--- a/docs/tutorials/LabFormat.ipynb
+++ b/docs/tutorials/LabFormat.ipynb
@@ -16,7 +16,6 @@
"outputs": [],
"source": [
"%load_ext param.ipython\n",
- "from param.ipython import ParamPager\n",
"import panel as pn"
]
},
@@ -35,7 +34,7 @@
"metadata": {},
"outputs": [],
"source": [
- "from larvaworld.lib import reg, process\n",
+ "from larvaworld.lib import reg\n",
"\n",
"reg.VERBOSE = 1"
]
diff --git a/docs/tutorials/environment_configuration.ipynb b/docs/tutorials/environment_configuration.ipynb
index c1b4b9c8..b27c0160 100644
--- a/docs/tutorials/environment_configuration.ipynb
+++ b/docs/tutorials/environment_configuration.ipynb
@@ -51,426 +51,16 @@
},
{
"data": {
- "application/javascript": [
- "(function(root) {\n",
- " function now() {\n",
- " return new Date();\n",
- " }\n",
- "\n",
- " var force = true;\n",
- "\n",
- " if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n",
- " root._bokeh_onload_callbacks = [];\n",
- " root._bokeh_is_loading = undefined;\n",
- " }\n",
- "\n",
- " if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
- " root._bokeh_timeout = Date.now() + 5000;\n",
- " root._bokeh_failed_load = false;\n",
- " }\n",
- "\n",
- " function run_callbacks() {\n",
- " try {\n",
- " root._bokeh_onload_callbacks.forEach(function(callback) {\n",
- " if (callback != null)\n",
- " callback();\n",
- " });\n",
- " } finally {\n",
- " delete root._bokeh_onload_callbacks\n",
- " }\n",
- " console.debug(\"Bokeh: all callbacks have finished\");\n",
- " }\n",
- "\n",
- " function load_libs(css_urls, js_urls, js_modules, callback) {\n",
- " if (css_urls == null) css_urls = [];\n",
- " if (js_urls == null) js_urls = [];\n",
- " if (js_modules == null) js_modules = [];\n",
- "\n",
- " root._bokeh_onload_callbacks.push(callback);\n",
- " if (root._bokeh_is_loading > 0) {\n",
- " console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
- " return null;\n",
- " }\n",
- " if (js_urls.length === 0 && js_modules.length === 0) {\n",
- " run_callbacks();\n",
- " return null;\n",
- " }\n",
- " console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
- "\n",
- " function on_load() {\n",
- " root._bokeh_is_loading--;\n",
- " if (root._bokeh_is_loading === 0) {\n",
- " console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n",
- " run_callbacks()\n",
- " }\n",
- " }\n",
- "\n",
- " function on_error() {\n",
- " console.error(\"failed to load \" + url);\n",
- " }\n",
- "\n",
- " for (var i = 0; i < css_urls.length; i++) {\n",
- " var url = css_urls[i];\n",
- " const element = document.createElement(\"link\");\n",
- " element.onload = on_load;\n",
- " element.onerror = on_error;\n",
- " element.rel = \"stylesheet\";\n",
- " element.type = \"text/css\";\n",
- " element.href = url;\n",
- " console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n",
- " document.body.appendChild(element);\n",
- " }\n",
- "\n",
- " var skip = [];\n",
- " if (window.requirejs) {\n",
- " window.requirejs.config({'packages': {}, 'paths': {'gridstack': 'https://cdn.jsdelivr.net/npm/gridstack@4.2.5/dist/gridstack-h5', 'notyf': 'https://cdn.jsdelivr.net/npm/notyf@3/notyf.min'}, 'shim': {'gridstack': {'exports': 'GridStack'}}});\n",
- " require([\"gridstack\"], function(GridStack) {\n",
- "\twindow.GridStack = GridStack\n",
- "\ton_load()\n",
- " })\n",
- " require([\"notyf\"], function() {\n",
- "\ton_load()\n",
- " })\n",
- " root._bokeh_is_loading = css_urls.length + 2;\n",
- " } else {\n",
- " root._bokeh_is_loading = css_urls.length + js_urls.length + js_modules.length;\n",
- " } if (((window['GridStack'] !== undefined) && (!(window['GridStack'] instanceof HTMLElement))) || window.requirejs) {\n",
- " var urls = ['https://cdn.holoviz.org/panel/0.14.4/dist/bundled/gridstack/gridstack@4.2.5/dist/gridstack-h5.js'];\n",
- " for (var i = 0; i < urls.length; i++) {\n",
- " skip.push(urls[i])\n",
- " }\n",
- " } if (((window['Notyf'] !== undefined) && (!(window['Notyf'] instanceof HTMLElement))) || window.requirejs) {\n",
- " var urls = ['https://cdn.holoviz.org/panel/0.14.4/dist/bundled/notificationarea/notyf@3/notyf.min.js'];\n",
- " for (var i = 0; i < urls.length; i++) {\n",
- " skip.push(urls[i])\n",
- " }\n",
- " } for (var i = 0; i < js_urls.length; i++) {\n",
- " var url = js_urls[i];\n",
- " if (skip.indexOf(url) >= 0) {\n",
- "\tif (!window.requirejs) {\n",
- "\t on_load();\n",
- "\t}\n",
- "\tcontinue;\n",
- " }\n",
- " var element = document.createElement('script');\n",
- " element.onload = on_load;\n",
- " element.onerror = on_error;\n",
- " element.async = false;\n",
- " element.src = url;\n",
- " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
- " document.head.appendChild(element);\n",
- " }\n",
- " for (var i = 0; i < js_modules.length; i++) {\n",
- " var url = js_modules[i];\n",
- " if (skip.indexOf(url) >= 0) {\n",
- "\tif (!window.requirejs) {\n",
- "\t on_load();\n",
- "\t}\n",
- "\tcontinue;\n",
- " }\n",
- " var element = document.createElement('script');\n",
- " element.onload = on_load;\n",
- " element.onerror = on_error;\n",
- " element.async = false;\n",
- " element.src = url;\n",
- " element.type = \"module\";\n",
- " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
- " document.head.appendChild(element);\n",
- " }\n",
- " if (!js_urls.length && !js_modules.length) {\n",
- " on_load()\n",
- " }\n",
- " };\n",
- "\n",
- " function inject_raw_css(css) {\n",
- " const element = document.createElement(\"style\");\n",
- " element.appendChild(document.createTextNode(css));\n",
- " document.body.appendChild(element);\n",
- " }\n",
- "\n",
- " var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-2.4.3.min.js\", \"https://unpkg.com/@holoviz/panel@0.14.4/dist/panel.min.js\"];\n",
- " var js_modules = [];\n",
- " var css_urls = [\"https://cdn.holoviz.org/panel/0.14.4/dist/css/markdown.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/card.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/dataframe.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/alerts.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/debugger.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/loading.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/widgets.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/json.css\"];\n",
- " var inline_js = [ function(Bokeh) {\n",
- " inject_raw_css(\"\\n .bk.pn-loading.arc:before {\\n background-image: url(\\\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHN0eWxlPSJtYXJnaW46IGF1dG87IGJhY2tncm91bmQ6IG5vbmU7IGRpc3BsYXk6IGJsb2NrOyBzaGFwZS1yZW5kZXJpbmc6IGF1dG87IiB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQiPiAgPGNpcmNsZSBjeD0iNTAiIGN5PSI1MCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjYzNjM2MzIiBzdHJva2Utd2lkdGg9IjEwIiByPSIzNSIgc3Ryb2tlLWRhc2hhcnJheT0iMTY0LjkzMzYxNDMxMzQ2NDE1IDU2Ljk3Nzg3MTQzNzgyMTM4Ij4gICAgPGFuaW1hdGVUcmFuc2Zvcm0gYXR0cmlidXRlTmFtZT0idHJhbnNmb3JtIiB0eXBlPSJyb3RhdGUiIHJlcGVhdENvdW50PSJpbmRlZmluaXRlIiBkdXI9IjFzIiB2YWx1ZXM9IjAgNTAgNTA7MzYwIDUwIDUwIiBrZXlUaW1lcz0iMDsxIj48L2FuaW1hdGVUcmFuc2Zvcm0+ICA8L2NpcmNsZT48L3N2Zz4=\\\");\\n background-size: auto calc(min(50%, 400px));\\n }\\n \");\n",
- " }, function(Bokeh) {\n",
- " Bokeh.set_log_level(\"info\");\n",
- " },\n",
- "function(Bokeh) {} // ensure no trailing comma for IE\n",
- " ];\n",
- "\n",
- " function run_inline_js() {\n",
- " if ((root.Bokeh !== undefined) || (force === true)) {\n",
- " for (var i = 0; i < inline_js.length; i++) {\n",
- " inline_js[i].call(root, root.Bokeh);\n",
- " }} else if (Date.now() < root._bokeh_timeout) {\n",
- " setTimeout(run_inline_js, 100);\n",
- " } else if (!root._bokeh_failed_load) {\n",
- " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
- " root._bokeh_failed_load = true;\n",
- " }\n",
- " }\n",
- "\n",
- " if (root._bokeh_is_loading === 0) {\n",
- " console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
- " run_inline_js();\n",
- " } else {\n",
- " load_libs(css_urls, js_urls, js_modules, function() {\n",
- " console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n",
- " run_inline_js();\n",
- " });\n",
- " }\n",
- "}(window));"
- ],
- "application/vnd.holoviews_load.v0+json": "(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, js_modules, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n if (js_modules == null) js_modules = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls.length === 0 && js_modules.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error() {\n console.error(\"failed to load \" + url);\n }\n\n for (var i = 0; i < css_urls.length; i++) {\n var url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n var skip = [];\n if (window.requirejs) {\n window.requirejs.config({'packages': {}, 'paths': {'gridstack': 'https://cdn.jsdelivr.net/npm/gridstack@4.2.5/dist/gridstack-h5', 'notyf': 'https://cdn.jsdelivr.net/npm/notyf@3/notyf.min'}, 'shim': {'gridstack': {'exports': 'GridStack'}}});\n require([\"gridstack\"], function(GridStack) {\n\twindow.GridStack = GridStack\n\ton_load()\n })\n require([\"notyf\"], function() {\n\ton_load()\n })\n root._bokeh_is_loading = css_urls.length + 2;\n } else {\n root._bokeh_is_loading = css_urls.length + js_urls.length + js_modules.length;\n } if (((window['GridStack'] !== undefined) && (!(window['GridStack'] instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://cdn.holoviz.org/panel/0.14.4/dist/bundled/gridstack/gridstack@4.2.5/dist/gridstack-h5.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(urls[i])\n }\n } if (((window['Notyf'] !== undefined) && (!(window['Notyf'] instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://cdn.holoviz.org/panel/0.14.4/dist/bundled/notificationarea/notyf@3/notyf.min.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(urls[i])\n }\n } for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n if (skip.indexOf(url) >= 0) {\n\tif (!window.requirejs) {\n\t on_load();\n\t}\n\tcontinue;\n }\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n for (var i = 0; i < js_modules.length; i++) {\n var url = js_modules[i];\n if (skip.indexOf(url) >= 0) {\n\tif (!window.requirejs) {\n\t on_load();\n\t}\n\tcontinue;\n }\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n element.type = \"module\";\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n if (!js_urls.length && !js_modules.length) {\n on_load()\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-2.4.3.min.js\", \"https://unpkg.com/@holoviz/panel@0.14.4/dist/panel.min.js\"];\n var js_modules = [];\n var css_urls = [\"https://cdn.holoviz.org/panel/0.14.4/dist/css/markdown.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/card.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/dataframe.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/alerts.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/debugger.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/loading.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/widgets.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/json.css\"];\n var inline_js = [ function(Bokeh) {\n inject_raw_css(\"\\n .bk.pn-loading.arc:before {\\n background-image: url(\\\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHN0eWxlPSJtYXJnaW46IGF1dG87IGJhY2tncm91bmQ6IG5vbmU7IGRpc3BsYXk6IGJsb2NrOyBzaGFwZS1yZW5kZXJpbmc6IGF1dG87IiB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQiPiAgPGNpcmNsZSBjeD0iNTAiIGN5PSI1MCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjYzNjM2MzIiBzdHJva2Utd2lkdGg9IjEwIiByPSIzNSIgc3Ryb2tlLWRhc2hhcnJheT0iMTY0LjkzMzYxNDMxMzQ2NDE1IDU2Ljk3Nzg3MTQzNzgyMTM4Ij4gICAgPGFuaW1hdGVUcmFuc2Zvcm0gYXR0cmlidXRlTmFtZT0idHJhbnNmb3JtIiB0eXBlPSJyb3RhdGUiIHJlcGVhdENvdW50PSJpbmRlZmluaXRlIiBkdXI9IjFzIiB2YWx1ZXM9IjAgNTAgNTA7MzYwIDUwIDUwIiBrZXlUaW1lcz0iMDsxIj48L2FuaW1hdGVUcmFuc2Zvcm0+ICA8L2NpcmNsZT48L3N2Zz4=\\\");\\n background-size: auto calc(min(50%, 400px));\\n }\\n \");\n }, function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {} // ensure no trailing comma for IE\n ];\n\n function run_inline_js() {\n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, js_modules, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));"
+ "application/javascript": "(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, js_modules, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n if (js_modules == null) js_modules = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls.length === 0 && js_modules.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error() {\n console.error(\"failed to load \" + url);\n }\n\n for (var i = 0; i < css_urls.length; i++) {\n var url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n var skip = [];\n if (window.requirejs) {\n window.requirejs.config({'packages': {}, 'paths': {'gridstack': 'https://cdn.jsdelivr.net/npm/gridstack@4.2.5/dist/gridstack-h5', 'notyf': 'https://cdn.jsdelivr.net/npm/notyf@3/notyf.min'}, 'shim': {'gridstack': {'exports': 'GridStack'}}});\n require([\"gridstack\"], function(GridStack) {\n\twindow.GridStack = GridStack\n\ton_load()\n })\n require([\"notyf\"], function() {\n\ton_load()\n })\n root._bokeh_is_loading = css_urls.length + 2;\n } else {\n root._bokeh_is_loading = css_urls.length + js_urls.length + js_modules.length;\n } if (((window['GridStack'] !== undefined) && (!(window['GridStack'] instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://cdn.holoviz.org/panel/0.14.4/dist/bundled/gridstack/gridstack@4.2.5/dist/gridstack-h5.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(urls[i])\n }\n } if (((window['Notyf'] !== undefined) && (!(window['Notyf'] instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://cdn.holoviz.org/panel/0.14.4/dist/bundled/notificationarea/notyf@3/notyf.min.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(urls[i])\n }\n } for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n if (skip.indexOf(url) >= 0) {\n\tif (!window.requirejs) {\n\t on_load();\n\t}\n\tcontinue;\n }\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n for (var i = 0; i < js_modules.length; i++) {\n var url = js_modules[i];\n if (skip.indexOf(url) >= 0) {\n\tif (!window.requirejs) {\n\t on_load();\n\t}\n\tcontinue;\n }\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n element.type = \"module\";\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n if (!js_urls.length && !js_modules.length) {\n on_load()\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-2.4.3.min.js\", \"https://unpkg.com/@holoviz/panel@0.14.4/dist/panel.min.js\"];\n var js_modules = [];\n var css_urls = [\"https://cdn.holoviz.org/panel/0.14.4/dist/css/markdown.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/card.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/dataframe.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/alerts.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/debugger.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/loading.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/widgets.css\", \"https://cdn.holoviz.org/panel/0.14.4/dist/css/json.css\"];\n var inline_js = [ function(Bokeh) {\n inject_raw_css(\"\\n .bk.pn-loading.arc:before {\\n background-image: url(\\\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHN0eWxlPSJtYXJnaW46IGF1dG87IGJhY2tncm91bmQ6IG5vbmU7IGRpc3BsYXk6IGJsb2NrOyBzaGFwZS1yZW5kZXJpbmc6IGF1dG87IiB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQiPiAgPGNpcmNsZSBjeD0iNTAiIGN5PSI1MCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjYzNjM2MzIiBzdHJva2Utd2lkdGg9IjEwIiByPSIzNSIgc3Ryb2tlLWRhc2hhcnJheT0iMTY0LjkzMzYxNDMxMzQ2NDE1IDU2Ljk3Nzg3MTQzNzgyMTM4Ij4gICAgPGFuaW1hdGVUcmFuc2Zvcm0gYXR0cmlidXRlTmFtZT0idHJhbnNmb3JtIiB0eXBlPSJyb3RhdGUiIHJlcGVhdENvdW50PSJpbmRlZmluaXRlIiBkdXI9IjFzIiB2YWx1ZXM9IjAgNTAgNTA7MzYwIDUwIDUwIiBrZXlUaW1lcz0iMDsxIj48L2FuaW1hdGVUcmFuc2Zvcm0+ICA8L2NpcmNsZT48L3N2Zz4=\\\");\\n background-size: auto calc(min(50%, 400px));\\n }\\n \");\n }, function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {} // ensure no trailing comma for IE\n ];\n\n function run_inline_js() {\n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, js_modules, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));",
+ "application/vnd.holoviews_load.v0+json": ""
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
- "application/javascript": [
- "\n",
- "if ((window.PyViz === undefined) || (window.PyViz instanceof HTMLElement)) {\n",
- " window.PyViz = {comms: {}, comm_status:{}, kernels:{}, receivers: {}, plot_index: []}\n",
- "}\n",
- "\n",
- "\n",
- " function JupyterCommManager() {\n",
- " }\n",
- "\n",
- " JupyterCommManager.prototype.register_target = function(plot_id, comm_id, msg_handler) {\n",
- " if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n",
- " var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n",
- " comm_manager.register_target(comm_id, function(comm) {\n",
- " comm.on_msg(msg_handler);\n",
- " });\n",
- " } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n",
- " window.PyViz.kernels[plot_id].registerCommTarget(comm_id, function(comm) {\n",
- " comm.onMsg = msg_handler;\n",
- " });\n",
- " } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n",
- " google.colab.kernel.comms.registerTarget(comm_id, (comm) => {\n",
- " var messages = comm.messages[Symbol.asyncIterator]();\n",
- " function processIteratorResult(result) {\n",
- " var message = result.value;\n",
- " console.log(message)\n",
- " var content = {data: message.data, comm_id};\n",
- " var buffers = []\n",
- " for (var buffer of message.buffers || []) {\n",
- " buffers.push(new DataView(buffer))\n",
- " }\n",
- " var metadata = message.metadata || {};\n",
- " var msg = {content, buffers, metadata}\n",
- " msg_handler(msg);\n",
- " return messages.next().then(processIteratorResult);\n",
- " }\n",
- " return messages.next().then(processIteratorResult);\n",
- " })\n",
- " }\n",
- " }\n",
- "\n",
- " JupyterCommManager.prototype.get_client_comm = function(plot_id, comm_id, msg_handler) {\n",
- " if (comm_id in window.PyViz.comms) {\n",
- " return window.PyViz.comms[comm_id];\n",
- " } else if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n",
- " var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n",
- " var comm = comm_manager.new_comm(comm_id, {}, {}, {}, comm_id);\n",
- " if (msg_handler) {\n",
- " comm.on_msg(msg_handler);\n",
- " }\n",
- " } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n",
- " var comm = window.PyViz.kernels[plot_id].connectToComm(comm_id);\n",
- " comm.open();\n",
- " if (msg_handler) {\n",
- " comm.onMsg = msg_handler;\n",
- " }\n",
- " } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n",
- " var comm_promise = google.colab.kernel.comms.open(comm_id)\n",
- " comm_promise.then((comm) => {\n",
- " window.PyViz.comms[comm_id] = comm;\n",
- " if (msg_handler) {\n",
- " var messages = comm.messages[Symbol.asyncIterator]();\n",
- " function processIteratorResult(result) {\n",
- " var message = result.value;\n",
- " var content = {data: message.data};\n",
- " var metadata = message.metadata || {comm_id};\n",
- " var msg = {content, metadata}\n",
- " msg_handler(msg);\n",
- " return messages.next().then(processIteratorResult);\n",
- " }\n",
- " return messages.next().then(processIteratorResult);\n",
- " }\n",
- " }) \n",
- " var sendClosure = (data, metadata, buffers, disposeOnDone) => {\n",
- " return comm_promise.then((comm) => {\n",
- " comm.send(data, metadata, buffers, disposeOnDone);\n",
- " });\n",
- " };\n",
- " var comm = {\n",
- " send: sendClosure\n",
- " };\n",
- " }\n",
- " window.PyViz.comms[comm_id] = comm;\n",
- " return comm;\n",
- " }\n",
- " window.PyViz.comm_manager = new JupyterCommManager();\n",
- " \n",
- "\n",
- "\n",
- "var JS_MIME_TYPE = 'application/javascript';\n",
- "var HTML_MIME_TYPE = 'text/html';\n",
- "var EXEC_MIME_TYPE = 'application/vnd.holoviews_exec.v0+json';\n",
- "var CLASS_NAME = 'output';\n",
- "\n",
- "/**\n",
- " * Render data to the DOM node\n",
- " */\n",
- "function render(props, node) {\n",
- " var div = document.createElement(\"div\");\n",
- " var script = document.createElement(\"script\");\n",
- " node.appendChild(div);\n",
- " node.appendChild(script);\n",
- "}\n",
- "\n",
- "/**\n",
- " * Handle when a new output is added\n",
- " */\n",
- "function handle_add_output(event, handle) {\n",
- " var output_area = handle.output_area;\n",
- " var output = handle.output;\n",
- " if ((output.data == undefined) || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
- " return\n",
- " }\n",
- " var id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
- " var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
- " if (id !== undefined) {\n",
- " var nchildren = toinsert.length;\n",
- " var html_node = toinsert[nchildren-1].children[0];\n",
- " html_node.innerHTML = output.data[HTML_MIME_TYPE];\n",
- " var scripts = [];\n",
- " var nodelist = html_node.querySelectorAll(\"script\");\n",
- " for (var i in nodelist) {\n",
- " if (nodelist.hasOwnProperty(i)) {\n",
- " scripts.push(nodelist[i])\n",
- " }\n",
- " }\n",
- "\n",
- " scripts.forEach( function (oldScript) {\n",
- " var newScript = document.createElement(\"script\");\n",
- " var attrs = [];\n",
- " var nodemap = oldScript.attributes;\n",
- " for (var j in nodemap) {\n",
- " if (nodemap.hasOwnProperty(j)) {\n",
- " attrs.push(nodemap[j])\n",
- " }\n",
- " }\n",
- " attrs.forEach(function(attr) { newScript.setAttribute(attr.name, attr.value) });\n",
- " newScript.appendChild(document.createTextNode(oldScript.innerHTML));\n",
- " oldScript.parentNode.replaceChild(newScript, oldScript);\n",
- " });\n",
- " if (JS_MIME_TYPE in output.data) {\n",
- " toinsert[nchildren-1].children[1].textContent = output.data[JS_MIME_TYPE];\n",
- " }\n",
- " output_area._hv_plot_id = id;\n",
- " if ((window.Bokeh !== undefined) && (id in Bokeh.index)) {\n",
- " window.PyViz.plot_index[id] = Bokeh.index[id];\n",
- " } else {\n",
- " window.PyViz.plot_index[id] = null;\n",
- " }\n",
- " } else if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
- " var bk_div = document.createElement(\"div\");\n",
- " bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
- " var script_attrs = bk_div.children[0].attributes;\n",
- " for (var i = 0; i < script_attrs.length; i++) {\n",
- " toinsert[toinsert.length - 1].childNodes[1].setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
- " }\n",
- " // store reference to server id on output_area\n",
- " output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
- " }\n",
- "}\n",
- "\n",
- "/**\n",
- " * Handle when an output is cleared or removed\n",
- " */\n",
- "function handle_clear_output(event, handle) {\n",
- " var id = handle.cell.output_area._hv_plot_id;\n",
- " var server_id = handle.cell.output_area._bokeh_server_id;\n",
- " if (((id === undefined) || !(id in PyViz.plot_index)) && (server_id !== undefined)) { return; }\n",
- " var comm = window.PyViz.comm_manager.get_client_comm(\"hv-extension-comm\", \"hv-extension-comm\", function () {});\n",
- " if (server_id !== null) {\n",
- " comm.send({event_type: 'server_delete', 'id': server_id});\n",
- " return;\n",
- " } else if (comm !== null) {\n",
- " comm.send({event_type: 'delete', 'id': id});\n",
- " }\n",
- " delete PyViz.plot_index[id];\n",
- " if ((window.Bokeh !== undefined) & (id in window.Bokeh.index)) {\n",
- " var doc = window.Bokeh.index[id].model.document\n",
- " doc.clear();\n",
- " const i = window.Bokeh.documents.indexOf(doc);\n",
- " if (i > -1) {\n",
- " window.Bokeh.documents.splice(i, 1);\n",
- " }\n",
- " }\n",
- "}\n",
- "\n",
- "/**\n",
- " * Handle kernel restart event\n",
- " */\n",
- "function handle_kernel_cleanup(event, handle) {\n",
- " delete PyViz.comms[\"hv-extension-comm\"];\n",
- " window.PyViz.plot_index = {}\n",
- "}\n",
- "\n",
- "/**\n",
- " * Handle update_display_data messages\n",
- " */\n",
- "function handle_update_output(event, handle) {\n",
- " handle_clear_output(event, {cell: {output_area: handle.output_area}})\n",
- " handle_add_output(event, handle)\n",
- "}\n",
- "\n",
- "function register_renderer(events, OutputArea) {\n",
- " function append_mime(data, metadata, element) {\n",
- " // create a DOM node to render to\n",
- " var toinsert = this.create_output_subarea(\n",
- " metadata,\n",
- " CLASS_NAME,\n",
- " EXEC_MIME_TYPE\n",
- " );\n",
- " this.keyboard_manager.register_events(toinsert);\n",
- " // Render to node\n",
- " var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
- " render(props, toinsert[0]);\n",
- " element.append(toinsert);\n",
- " return toinsert\n",
- " }\n",
- "\n",
- " events.on('output_added.OutputArea', handle_add_output);\n",
- " events.on('output_updated.OutputArea', handle_update_output);\n",
- " events.on('clear_output.CodeCell', handle_clear_output);\n",
- " events.on('delete.Cell', handle_clear_output);\n",
- " events.on('kernel_ready.Kernel', handle_kernel_cleanup);\n",
- "\n",
- " OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
- " safe: true,\n",
- " index: 0\n",
- " });\n",
- "}\n",
- "\n",
- "if (window.Jupyter !== undefined) {\n",
- " try {\n",
- " var events = require('base/js/events');\n",
- " var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
- " if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
- " register_renderer(events, OutputArea);\n",
- " }\n",
- " } catch(err) {\n",
- " }\n",
- "}\n"
- ],
- "application/vnd.holoviews_load.v0+json": "\nif ((window.PyViz === undefined) || (window.PyViz instanceof HTMLElement)) {\n window.PyViz = {comms: {}, comm_status:{}, kernels:{}, receivers: {}, plot_index: []}\n}\n\n\n function JupyterCommManager() {\n }\n\n JupyterCommManager.prototype.register_target = function(plot_id, comm_id, msg_handler) {\n if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n comm_manager.register_target(comm_id, function(comm) {\n comm.on_msg(msg_handler);\n });\n } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n window.PyViz.kernels[plot_id].registerCommTarget(comm_id, function(comm) {\n comm.onMsg = msg_handler;\n });\n } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n google.colab.kernel.comms.registerTarget(comm_id, (comm) => {\n var messages = comm.messages[Symbol.asyncIterator]();\n function processIteratorResult(result) {\n var message = result.value;\n console.log(message)\n var content = {data: message.data, comm_id};\n var buffers = []\n for (var buffer of message.buffers || []) {\n buffers.push(new DataView(buffer))\n }\n var metadata = message.metadata || {};\n var msg = {content, buffers, metadata}\n msg_handler(msg);\n return messages.next().then(processIteratorResult);\n }\n return messages.next().then(processIteratorResult);\n })\n }\n }\n\n JupyterCommManager.prototype.get_client_comm = function(plot_id, comm_id, msg_handler) {\n if (comm_id in window.PyViz.comms) {\n return window.PyViz.comms[comm_id];\n } else if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n var comm = comm_manager.new_comm(comm_id, {}, {}, {}, comm_id);\n if (msg_handler) {\n comm.on_msg(msg_handler);\n }\n } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n var comm = window.PyViz.kernels[plot_id].connectToComm(comm_id);\n comm.open();\n if (msg_handler) {\n comm.onMsg = msg_handler;\n }\n } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n var comm_promise = google.colab.kernel.comms.open(comm_id)\n comm_promise.then((comm) => {\n window.PyViz.comms[comm_id] = comm;\n if (msg_handler) {\n var messages = comm.messages[Symbol.asyncIterator]();\n function processIteratorResult(result) {\n var message = result.value;\n var content = {data: message.data};\n var metadata = message.metadata || {comm_id};\n var msg = {content, metadata}\n msg_handler(msg);\n return messages.next().then(processIteratorResult);\n }\n return messages.next().then(processIteratorResult);\n }\n }) \n var sendClosure = (data, metadata, buffers, disposeOnDone) => {\n return comm_promise.then((comm) => {\n comm.send(data, metadata, buffers, disposeOnDone);\n });\n };\n var comm = {\n send: sendClosure\n };\n }\n window.PyViz.comms[comm_id] = comm;\n return comm;\n }\n window.PyViz.comm_manager = new JupyterCommManager();\n \n\n\nvar JS_MIME_TYPE = 'application/javascript';\nvar HTML_MIME_TYPE = 'text/html';\nvar EXEC_MIME_TYPE = 'application/vnd.holoviews_exec.v0+json';\nvar CLASS_NAME = 'output';\n\n/**\n * Render data to the DOM node\n */\nfunction render(props, node) {\n var div = document.createElement(\"div\");\n var script = document.createElement(\"script\");\n node.appendChild(div);\n node.appendChild(script);\n}\n\n/**\n * Handle when a new output is added\n */\nfunction handle_add_output(event, handle) {\n var output_area = handle.output_area;\n var output = handle.output;\n if ((output.data == undefined) || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n return\n }\n var id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n if (id !== undefined) {\n var nchildren = toinsert.length;\n var html_node = toinsert[nchildren-1].children[0];\n html_node.innerHTML = output.data[HTML_MIME_TYPE];\n var scripts = [];\n var nodelist = html_node.querySelectorAll(\"script\");\n for (var i in nodelist) {\n if (nodelist.hasOwnProperty(i)) {\n scripts.push(nodelist[i])\n }\n }\n\n scripts.forEach( function (oldScript) {\n var newScript = document.createElement(\"script\");\n var attrs = [];\n var nodemap = oldScript.attributes;\n for (var j in nodemap) {\n if (nodemap.hasOwnProperty(j)) {\n attrs.push(nodemap[j])\n }\n }\n attrs.forEach(function(attr) { newScript.setAttribute(attr.name, attr.value) });\n newScript.appendChild(document.createTextNode(oldScript.innerHTML));\n oldScript.parentNode.replaceChild(newScript, oldScript);\n });\n if (JS_MIME_TYPE in output.data) {\n toinsert[nchildren-1].children[1].textContent = output.data[JS_MIME_TYPE];\n }\n output_area._hv_plot_id = id;\n if ((window.Bokeh !== undefined) && (id in Bokeh.index)) {\n window.PyViz.plot_index[id] = Bokeh.index[id];\n } else {\n window.PyViz.plot_index[id] = null;\n }\n } else if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n var bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n var script_attrs = bk_div.children[0].attributes;\n for (var i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].childNodes[1].setAttribute(script_attrs[i].name, script_attrs[i].value);\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n}\n\n/**\n * Handle when an output is cleared or removed\n */\nfunction handle_clear_output(event, handle) {\n var id = handle.cell.output_area._hv_plot_id;\n var server_id = handle.cell.output_area._bokeh_server_id;\n if (((id === undefined) || !(id in PyViz.plot_index)) && (server_id !== undefined)) { return; }\n var comm = window.PyViz.comm_manager.get_client_comm(\"hv-extension-comm\", \"hv-extension-comm\", function () {});\n if (server_id !== null) {\n comm.send({event_type: 'server_delete', 'id': server_id});\n return;\n } else if (comm !== null) {\n comm.send({event_type: 'delete', 'id': id});\n }\n delete PyViz.plot_index[id];\n if ((window.Bokeh !== undefined) & (id in window.Bokeh.index)) {\n var doc = window.Bokeh.index[id].model.document\n doc.clear();\n const i = window.Bokeh.documents.indexOf(doc);\n if (i > -1) {\n window.Bokeh.documents.splice(i, 1);\n }\n }\n}\n\n/**\n * Handle kernel restart event\n */\nfunction handle_kernel_cleanup(event, handle) {\n delete PyViz.comms[\"hv-extension-comm\"];\n window.PyViz.plot_index = {}\n}\n\n/**\n * Handle update_display_data messages\n */\nfunction handle_update_output(event, handle) {\n handle_clear_output(event, {cell: {output_area: handle.output_area}})\n handle_add_output(event, handle)\n}\n\nfunction register_renderer(events, OutputArea) {\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n var toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[0]);\n element.append(toinsert);\n return toinsert\n }\n\n events.on('output_added.OutputArea', handle_add_output);\n events.on('output_updated.OutputArea', handle_update_output);\n events.on('clear_output.CodeCell', handle_clear_output);\n events.on('delete.Cell', handle_clear_output);\n events.on('kernel_ready.Kernel', handle_kernel_cleanup);\n\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n safe: true,\n index: 0\n });\n}\n\nif (window.Jupyter !== undefined) {\n try {\n var events = require('base/js/events');\n var OutputArea = require('notebook/js/outputarea').OutputArea;\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n } catch(err) {\n }\n}\n"
+ "application/javascript": "\nif ((window.PyViz === undefined) || (window.PyViz instanceof HTMLElement)) {\n window.PyViz = {comms: {}, comm_status:{}, kernels:{}, receivers: {}, plot_index: []}\n}\n\n\n function JupyterCommManager() {\n }\n\n JupyterCommManager.prototype.register_target = function(plot_id, comm_id, msg_handler) {\n if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n comm_manager.register_target(comm_id, function(comm) {\n comm.on_msg(msg_handler);\n });\n } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n window.PyViz.kernels[plot_id].registerCommTarget(comm_id, function(comm) {\n comm.onMsg = msg_handler;\n });\n } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n google.colab.kernel.comms.registerTarget(comm_id, (comm) => {\n var messages = comm.messages[Symbol.asyncIterator]();\n function processIteratorResult(result) {\n var message = result.value;\n console.log(message)\n var content = {data: message.data, comm_id};\n var buffers = []\n for (var buffer of message.buffers || []) {\n buffers.push(new DataView(buffer))\n }\n var metadata = message.metadata || {};\n var msg = {content, buffers, metadata}\n msg_handler(msg);\n return messages.next().then(processIteratorResult);\n }\n return messages.next().then(processIteratorResult);\n })\n }\n }\n\n JupyterCommManager.prototype.get_client_comm = function(plot_id, comm_id, msg_handler) {\n if (comm_id in window.PyViz.comms) {\n return window.PyViz.comms[comm_id];\n } else if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n var comm = comm_manager.new_comm(comm_id, {}, {}, {}, comm_id);\n if (msg_handler) {\n comm.on_msg(msg_handler);\n }\n } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n var comm = window.PyViz.kernels[plot_id].connectToComm(comm_id);\n comm.open();\n if (msg_handler) {\n comm.onMsg = msg_handler;\n }\n } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n var comm_promise = google.colab.kernel.comms.open(comm_id)\n comm_promise.then((comm) => {\n window.PyViz.comms[comm_id] = comm;\n if (msg_handler) {\n var messages = comm.messages[Symbol.asyncIterator]();\n function processIteratorResult(result) {\n var message = result.value;\n var content = {data: message.data};\n var metadata = message.metadata || {comm_id};\n var msg = {content, metadata}\n msg_handler(msg);\n return messages.next().then(processIteratorResult);\n }\n return messages.next().then(processIteratorResult);\n }\n }) \n var sendClosure = (data, metadata, buffers, disposeOnDone) => {\n return comm_promise.then((comm) => {\n comm.send(data, metadata, buffers, disposeOnDone);\n });\n };\n var comm = {\n send: sendClosure\n };\n }\n window.PyViz.comms[comm_id] = comm;\n return comm;\n }\n window.PyViz.comm_manager = new JupyterCommManager();\n \n\n\nvar JS_MIME_TYPE = 'application/javascript';\nvar HTML_MIME_TYPE = 'text/html';\nvar EXEC_MIME_TYPE = 'application/vnd.holoviews_exec.v0+json';\nvar CLASS_NAME = 'output';\n\n/**\n * Render data to the DOM node\n */\nfunction render(props, node) {\n var div = document.createElement(\"div\");\n var script = document.createElement(\"script\");\n node.appendChild(div);\n node.appendChild(script);\n}\n\n/**\n * Handle when a new output is added\n */\nfunction handle_add_output(event, handle) {\n var output_area = handle.output_area;\n var output = handle.output;\n if ((output.data == undefined) || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n return\n }\n var id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n if (id !== undefined) {\n var nchildren = toinsert.length;\n var html_node = toinsert[nchildren-1].children[0];\n html_node.innerHTML = output.data[HTML_MIME_TYPE];\n var scripts = [];\n var nodelist = html_node.querySelectorAll(\"script\");\n for (var i in nodelist) {\n if (nodelist.hasOwnProperty(i)) {\n scripts.push(nodelist[i])\n }\n }\n\n scripts.forEach( function (oldScript) {\n var newScript = document.createElement(\"script\");\n var attrs = [];\n var nodemap = oldScript.attributes;\n for (var j in nodemap) {\n if (nodemap.hasOwnProperty(j)) {\n attrs.push(nodemap[j])\n }\n }\n attrs.forEach(function(attr) { newScript.setAttribute(attr.name, attr.value) });\n newScript.appendChild(document.createTextNode(oldScript.innerHTML));\n oldScript.parentNode.replaceChild(newScript, oldScript);\n });\n if (JS_MIME_TYPE in output.data) {\n toinsert[nchildren-1].children[1].textContent = output.data[JS_MIME_TYPE];\n }\n output_area._hv_plot_id = id;\n if ((window.Bokeh !== undefined) && (id in Bokeh.index)) {\n window.PyViz.plot_index[id] = Bokeh.index[id];\n } else {\n window.PyViz.plot_index[id] = null;\n }\n } else if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n var bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n var script_attrs = bk_div.children[0].attributes;\n for (var i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].childNodes[1].setAttribute(script_attrs[i].name, script_attrs[i].value);\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n}\n\n/**\n * Handle when an output is cleared or removed\n */\nfunction handle_clear_output(event, handle) {\n var id = handle.cell.output_area._hv_plot_id;\n var server_id = handle.cell.output_area._bokeh_server_id;\n if (((id === undefined) || !(id in PyViz.plot_index)) && (server_id !== undefined)) { return; }\n var comm = window.PyViz.comm_manager.get_client_comm(\"hv-extension-comm\", \"hv-extension-comm\", function () {});\n if (server_id !== null) {\n comm.send({event_type: 'server_delete', 'id': server_id});\n return;\n } else if (comm !== null) {\n comm.send({event_type: 'delete', 'id': id});\n }\n delete PyViz.plot_index[id];\n if ((window.Bokeh !== undefined) & (id in window.Bokeh.index)) {\n var doc = window.Bokeh.index[id].model.document\n doc.clear();\n const i = window.Bokeh.documents.indexOf(doc);\n if (i > -1) {\n window.Bokeh.documents.splice(i, 1);\n }\n }\n}\n\n/**\n * Handle kernel restart event\n */\nfunction handle_kernel_cleanup(event, handle) {\n delete PyViz.comms[\"hv-extension-comm\"];\n window.PyViz.plot_index = {}\n}\n\n/**\n * Handle update_display_data messages\n */\nfunction handle_update_output(event, handle) {\n handle_clear_output(event, {cell: {output_area: handle.output_area}})\n handle_add_output(event, handle)\n}\n\nfunction register_renderer(events, OutputArea) {\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n var toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[0]);\n element.append(toinsert);\n return toinsert\n }\n\n events.on('output_added.OutputArea', handle_add_output);\n events.on('output_updated.OutputArea', handle_update_output);\n events.on('clear_output.CodeCell', handle_clear_output);\n events.on('delete.Cell', handle_clear_output);\n events.on('kernel_ready.Kernel', handle_kernel_cleanup);\n\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n safe: true,\n index: 0\n });\n}\n\nif (window.Jupyter !== undefined) {\n try {\n var events = require('base/js/events');\n var OutputArea = require('notebook/js/outputarea').OutputArea;\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n } catch(err) {\n }\n}\n",
+ "application/vnd.holoviews_load.v0+json": ""
},
"metadata": {},
"output_type": "display_data"
@@ -491,7 +81,7 @@
}
],
"source": [
- "from larvaworld.lib import reg, process"
+ "from larvaworld.lib import reg"
]
},
{
diff --git a/docs/tutorials/replay.ipynb b/docs/tutorials/replay.ipynb
index 7a5bf217..66d05f13 100644
--- a/docs/tutorials/replay.ipynb
+++ b/docs/tutorials/replay.ipynb
@@ -21,9 +21,7 @@
"metadata": {},
"outputs": [],
"source": [
- "import numpy as np\n",
- "\n",
- "from larvaworld.lib import util, reg, process\n",
+ "from larvaworld.lib import reg, util\n",
"from larvaworld.lib.sim.dataset_replay import ReplayRun\n",
"\n",
"reg.VERBOSE = 1"
diff --git a/docs/tutorials/sensorscapes.ipynb b/docs/tutorials/sensorscapes.ipynb
index df7cb071..965340b2 100644
--- a/docs/tutorials/sensorscapes.ipynb
+++ b/docs/tutorials/sensorscapes.ipynb
@@ -27,8 +27,7 @@
"source": [
"import numpy as np\n",
"\n",
- "from larvaworld.lib import util, reg, process, sim\n",
- "from larvaworld.lib.sim.single_run import ExpRun\n",
+ "from larvaworld.lib import reg, sim, util\n",
"# reg.VERBOSE=1"
]
},
diff --git a/src/larvaworld/cli/__init__.py b/src/larvaworld/cli/__init__.py
index edb04bd9..dc973d53 100644
--- a/src/larvaworld/cli/__init__.py
+++ b/src/larvaworld/cli/__init__.py
@@ -4,5 +4,4 @@
from .argparser import SimModeParser
-
__displayname__ = "CLI"
diff --git a/src/larvaworld/cli/argparser.py b/src/larvaworld/cli/argparser.py
index 2c93ba10..f47fd41f 100644
--- a/src/larvaworld/cli/argparser.py
+++ b/src/larvaworld/cli/argparser.py
@@ -1,8 +1,10 @@
-from typing import List
from argparse import ArgumentParser
+from typing import List
+
import param
-from ..lib import reg, util, sim, screen
-from ..lib.param import SimOps, RuntimeOps
+
+from ..lib import reg, screen, sim, util
+from ..lib.param import RuntimeOps, SimOps
# from ..lib.param.custom import ClassAttr, ClassDict
@@ -39,6 +41,7 @@ class SingleParserArgument:
A list containing the short and long argument names.
kwargs : dict
Additional keyword arguments.
+
"""
def __init__(self, short, key, **kwargs):
@@ -59,6 +62,7 @@ def add(self, p):
-------
argparse.ArgumentParser
The modified parser.
+
"""
p.add_argument(*self.args, **self.kwargs)
return p
@@ -76,6 +80,7 @@ def get(self, input):
-------
Any
The value of the argument.
+
"""
return getattr(input, self.key)
@@ -95,6 +100,7 @@ def from_dict(cls, name, **kwargs):
-------
SingleParserArgument
A SingleParserArgument instance.
+
"""
return cls(**parser_entry_from_dict(name, **kwargs))
@@ -114,6 +120,7 @@ def from_param(cls, k, p):
-------
SingleParserArgument
A SingleParserArgument instance.
+
"""
return cls(**parser_entry_from_param(k, p))
@@ -133,6 +140,7 @@ def parser_entry_from_param(k, p):
-------
dict
A dictionary entry for the parser argument.
+
"""
c = p.__class__
v = p.default
@@ -191,6 +199,7 @@ def parser_entry_from_dict(name, k=None, h="", dtype=float, v=None, vs=None, **k
-------
dict
A dictionary entry for the parser argument.
+
"""
if k is None:
k = name
@@ -238,6 +247,7 @@ def __init__(self, parsargs):
----------
parsargs : dict
A dictionary of parser arguments.
+
"""
self.parsargs = parsargs
@@ -255,6 +265,7 @@ def from_param(cls, d0):
-------
ParserArgumentDict
A ParserArgumentDict instance.
+
"""
return cls(parser_dict_from_param(d0))
@@ -272,6 +283,7 @@ def from_dict(cls, d0):
-------
ParserArgumentDict
A ParserArgumentDict instance.
+
"""
return cls(parser_dict_from_dict(d0))
@@ -288,6 +300,7 @@ def add(self, parser=None):
-------
argparse.ArgumentParser
The modified ArgumentParser.
+
"""
if parser is None:
parser = ArgumentParser()
@@ -308,6 +321,7 @@ def get(self, input):
-------
dict
A dictionary of argument values.
+
"""
dic = util.AttrDict({k: v.get(input) for k, v in self.parsargs.items()})
return dic.unflatten()
@@ -326,8 +340,8 @@ def parser_dict_from_param(d0):
-------
dict
A dictionary of parser arguments.
- """
+ """
# dv0 = aux.AttrDict(d0.param.values())
d = util.AttrDict()
@@ -360,6 +374,7 @@ def parser_dict_from_dict(d0):
-------
dict
A dictionary of parser arguments.
+
"""
p = util.AttrDict()
for n, v in d0.items():
@@ -585,13 +600,13 @@ def show_args(self, nested=True, flat_nested=False, input=False, run_args=True):
"""
print(f"Simulation mode : {self.mode}")
if nested:
- print(f"Simulation args as nested dictionary: ")
+ print("Simulation args as nested dictionary: ")
self.run_kws.print(flat=False)
if flat_nested:
- print(f"Simulation args as flattened nested dictionary: ")
+ print("Simulation args as flattened nested dictionary: ")
self.run_kws.print(flat=True)
if input:
- print(f"Input args : ")
+ print("Input args : ")
self.args.print(flat=True)
if run_args:
if hasattr(self.run, "configuration_text"):
diff --git a/src/larvaworld/cli/main.py b/src/larvaworld/cli/main.py
index 2077009e..b3184b87 100644
--- a/src/larvaworld/cli/main.py
+++ b/src/larvaworld/cli/main.py
@@ -1,4 +1,3 @@
-from ..lib import reg, util
from .argparser import SimModeParser
diff --git a/src/larvaworld/gui/__init__.py b/src/larvaworld/gui/__init__.py
index a45a791f..9cac4075 100644
--- a/src/larvaworld/gui/__init__.py
+++ b/src/larvaworld/gui/__init__.py
@@ -2,7 +2,7 @@
The larvaworld Graphical User Interface (GUI)
"""
-from . import gui_aux, tabs, panel
+from . import gui_aux, panel, tabs
# print('jj')
__displayname__ = "GUI"
diff --git a/src/larvaworld/gui/gui_aux/buttons.py b/src/larvaworld/gui/gui_aux/buttons.py
index 71473b8a..cc3a6bbe 100644
--- a/src/larvaworld/gui/gui_aux/buttons.py
+++ b/src/larvaworld/gui/gui_aux/buttons.py
@@ -3,8 +3,8 @@
import PySimpleGUI as sg
-from ...lib import reg
from ...gui import gui_aux
+from ...lib import reg
__all__ = [
"b_kws",
diff --git a/src/larvaworld/gui/gui_aux/dtypes.py b/src/larvaworld/gui/gui_aux/dtypes.py
index e7dc59c9..712cc8ee 100644
--- a/src/larvaworld/gui/gui_aux/dtypes.py
+++ b/src/larvaworld/gui/gui_aux/dtypes.py
@@ -1,6 +1,7 @@
-import numpy as np
import typing
+import numpy as np
+
from ...lib import reg
__all__ = [
diff --git a/src/larvaworld/gui/gui_aux/elements.py b/src/larvaworld/gui/gui_aux/elements.py
index 79588dda..d023f815 100644
--- a/src/larvaworld/gui/gui_aux/elements.py
+++ b/src/larvaworld/gui/gui_aux/elements.py
@@ -1,20 +1,19 @@
import copy
import inspect
import os
-from typing import Tuple, List
import sys
-
+from typing import List, Tuple
if sys.version_info >= (3, 8):
from typing import TypedDict # pylint: disable=no-name-in-module
else:
from typing_extensions import TypedDict
+import matplotlib.pyplot as plt
import numpy as np
import PySimpleGUI as sg
-import matplotlib.pyplot as plt
-from ...lib import reg, util
from ...gui import gui_aux
+from ...lib import reg, util
__all__ = [
"SYMBOL_UP",
@@ -1494,7 +1493,7 @@ def build(self, name, **kwargs):
k0,
dict_name=args["entry"],
disp_name=args["disp"],
- index=f"ID",
+ index="ID",
**subkws,
)
ii = self.subdicts[k0].get_layout()[0]
@@ -2042,18 +2041,18 @@ def evaluate(self):
w.close()
return False
elif e == "Choose":
- w[f"-COL2-"].update(visible=False)
- w[f"-COL1-"].update(visible=True)
+ w["-COL2-"].update(visible=False)
+ w["-COL1-"].update(visible=True)
self.cur_layout = 1
elif e == "Ok":
- w[f"-COL1-"].update(visible=False)
- w[f"-COL2-"].update(visible=True)
+ w["-COL1-"].update(visible=False)
+ w["-COL2-"].update(visible=True)
self.pars = [p for p in self.available_pars if v[f"k_{p}"]]
self.update_pars()
self.cur_layout = 2
elif e == "Cancel":
- w[f"-COL1-"].update(visible=False)
- w[f"-COL2-"].update(visible=True)
+ w["-COL1-"].update(visible=False)
+ w["-COL2-"].update(visible=True)
self.cur_layout = 2
if self.cur_layout == 2 and self.Npars > 0:
secs = v["-SLIDER-TIME-"]
diff --git a/src/larvaworld/gui/gui_aux/functions.py b/src/larvaworld/gui/gui_aux/functions.py
index eb5a87ce..3e297d18 100644
--- a/src/larvaworld/gui/gui_aux/functions.py
+++ b/src/larvaworld/gui/gui_aux/functions.py
@@ -56,7 +56,7 @@ def get_disp_name(name) -> str:
def retrieve_value(v, t):
- from typing import List, Tuple, Union, Type
+ from typing import List, Tuple, Type, Union
if v in ["", "None", None, ("", ""), ("", "")]:
vv = None
diff --git a/src/larvaworld/gui/gui_aux/par_tree.py b/src/larvaworld/gui/gui_aux/par_tree.py
index 96628e7f..83f6bbab 100644
--- a/src/larvaworld/gui/gui_aux/par_tree.py
+++ b/src/larvaworld/gui/gui_aux/par_tree.py
@@ -3,7 +3,6 @@
from ...lib import reg
-
__all__ = [
"tree_dict",
"pars_to_tree",
@@ -18,7 +17,7 @@ def tree_dict(d, parent_key="", sep="."):
def add(item):
entry = dict(zip(cols, item))
- if not entry["key"] in keys:
+ if entry["key"] not in keys:
entries.append(entry)
keys.append(entry["key"])
diff --git a/src/larvaworld/gui/gui_aux/png_to_b64.py b/src/larvaworld/gui/gui_aux/png_to_b64.py
index 02772d85..811cb898 100644
--- a/src/larvaworld/gui/gui_aux/png_to_b64.py
+++ b/src/larvaworld/gui/gui_aux/png_to_b64.py
@@ -1,16 +1,15 @@
-import PySimpleGUI as sg
-import os
import base64
-from PIL import Image
+import os
from io import BytesIO
+import PySimpleGUI as sg
+from PIL import Image
__all__ = ["png_to_b64", "bs64_to_png"]
def png_to_b64():
# Base64 Encoder - encodes a folder of PNG files and creates a .py file with definitions
-
"""
Make base64 images
input: folder with .png .ico .gif 'sigma
diff --git a/src/larvaworld/gui/gui_aux/windows.py b/src/larvaworld/gui/gui_aux/windows.py
index e18c6f42..0dbefe7c 100644
--- a/src/larvaworld/gui/gui_aux/windows.py
+++ b/src/larvaworld/gui/gui_aux/windows.py
@@ -1,6 +1,6 @@
import os
-import PySimpleGUI as sg
+import PySimpleGUI as sg
from ...gui import gui_aux
from ...lib import reg, util
@@ -222,7 +222,7 @@ def delete_conf_window(id, conftype, disp=None):
)
]
]
- e, v = sg.Window(f"Delete configuration", l, size=(500, 250)).read(close=True)
+ e, v = sg.Window("Delete configuration", l, size=(500, 250)).read(close=True)
if e == "Ok":
# reg.stored.delete(id=id, conftype=conftype)
reg.conf[conftype].delete(id)
@@ -437,7 +437,7 @@ def import_window(labID, raw_dic):
del proc_dir[target_id]
else:
- print(f"------ Building a single merged dataset ------")
+ print("------ Building a single merged dataset ------")
target_id0 = v[f"new_{raw_ids[0]}"]
if labID in ["Berni", "Arguello"]:
@@ -464,7 +464,7 @@ def import_window(labID, raw_dic):
**kws,
}
elif labID in ["Jovanic"]:
- raise NotImplemented
+ raise NotImplementedError
dd = g.import_dataset(**kws0)
proc_dir[dd.id] = dd
break
diff --git a/src/larvaworld/gui/panel/__init__.py b/src/larvaworld/gui/panel/__init__.py
index 15cb1ac4..1d6c6e4b 100644
--- a/src/larvaworld/gui/panel/__init__.py
+++ b/src/larvaworld/gui/panel/__init__.py
@@ -3,6 +3,7 @@
"""
from . import track_viewer
+
# from .track_viewer import TrackViewer
__displayname__ = "Dashboards"
diff --git a/src/larvaworld/gui/panel/experiment_viewer.py b/src/larvaworld/gui/panel/experiment_viewer.py
index 4c8139a1..b49bb451 100644
--- a/src/larvaworld/gui/panel/experiment_viewer.py
+++ b/src/larvaworld/gui/panel/experiment_viewer.py
@@ -1,12 +1,11 @@
-import pandas as pd
-import panel as pn
-import numpy as np
import holoviews as hv
-from panel.template import DarkTheme
+import numpy as np
+import panel as pn
pn.extension()
-from larvaworld.lib import reg, util, model, sim, screen
+from larvaworld.lib import screen, sim, util
+
# from larvaworld.lib.param import SimOps
__all__ = [
@@ -21,7 +20,7 @@ def __init__(self, img_width=600, experiment="dish", duration=1, **kwargs):
self.env = self.launcher.p.env_params
x, y = self.env.arena.dims
self.image_kws = {
- "title": f"Arena viewer",
+ "title": "Arena viewer",
"xlim": (-x / 2, x / 2),
"ylim": (-y / 2, y / 2),
"width": self.size,
diff --git a/src/larvaworld/gui/panel/model_inspector.py b/src/larvaworld/gui/panel/model_inspector.py
index 65fb802f..f91d7fa9 100644
--- a/src/larvaworld/gui/panel/model_inspector.py
+++ b/src/larvaworld/gui/panel/model_inspector.py
@@ -2,16 +2,17 @@
Interactive dashboard to inspect any model configuration available
"""
-import panel as pn
-import pandas as pd
import holoviews as hv
+import pandas as pd
+import panel as pn
from holoviews.streams import Buffer
from panel.template import DarkTheme
import larvaworld.lib.reg as reg
-from larvaworld.lib.param import class_objs
-from larvaworld.lib.model import DefaultBrain, Effector, moduleDB as MD
from larvaworld.lib import util
+from larvaworld.lib.model import DefaultBrain, Effector
+from larvaworld.lib.model import moduleDB as MD
+from larvaworld.lib.param import class_objs
w, h = 800, 500
MODULES = MD.LocoModsBasic
diff --git a/src/larvaworld/gui/panel/module_tester.py b/src/larvaworld/gui/panel/module_tester.py
index dbff403a..d221a9ae 100644
--- a/src/larvaworld/gui/panel/module_tester.py
+++ b/src/larvaworld/gui/panel/module_tester.py
@@ -1,12 +1,11 @@
import hvplot.pandas
-import larvaworld.lib.param
import numpy as np
import pandas as pd
import panel as pn
-import param
from panel.template import DarkTheme
import larvaworld.lib.model as model
+import larvaworld.lib.param
def module_tester(M, temp):
diff --git a/src/larvaworld/gui/panel/track_viewer.py b/src/larvaworld/gui/panel/track_viewer.py
index f2990198..9487f0a6 100644
--- a/src/larvaworld/gui/panel/track_viewer.py
+++ b/src/larvaworld/gui/panel/track_viewer.py
@@ -1,7 +1,6 @@
import pandas as pd
-
-from ...lib import reg, util
+from ...lib import util
from ...lib.process.dataset import LarvaDatasetCollection
__all__ = [
@@ -19,7 +18,7 @@ def __init__(self, size=600, **kwargs):
x, y = self.arena_dims
self.image_kws = {
- "title": f"Trajectory viewer",
+ "title": "Trajectory viewer",
"xlim": (-x / 2, x / 2),
"ylim": (-y / 2, y / 2),
"width": self.size,
@@ -46,9 +45,8 @@ def build_data(self):
return data
def get_app(self):
- import panel as pn
- import numpy as np
import holoviews as hv
+ import panel as pn
pn.extension()
diff --git a/src/larvaworld/gui/tabs/__init__.py b/src/larvaworld/gui/tabs/__init__.py
index 52bb961a..00fea18e 100644
--- a/src/larvaworld/gui/tabs/__init__.py
+++ b/src/larvaworld/gui/tabs/__init__.py
@@ -6,8 +6,8 @@
analysis,
batch_run,
body_draw,
- env_draw,
env,
+ env_draw,
essay,
importing,
intro,
@@ -18,6 +18,7 @@
tutorial,
videos,
)
+
# from .analysis import AnalysisTab
# from .batch_run import BatchTab
# from .body_draw import DrawBodyTab
diff --git a/src/larvaworld/gui/tabs/analysis.py b/src/larvaworld/gui/tabs/analysis.py
index 2f910d80..e069d52f 100644
--- a/src/larvaworld/gui/tabs/analysis.py
+++ b/src/larvaworld/gui/tabs/analysis.py
@@ -1,5 +1,5 @@
-from ...lib import reg
from ...gui import gui_aux
+from ...lib import reg
__all__ = [
"AnalysisTab",
diff --git a/src/larvaworld/gui/tabs/batch_run.py b/src/larvaworld/gui/tabs/batch_run.py
index 844035d2..7be60ac4 100644
--- a/src/larvaworld/gui/tabs/batch_run.py
+++ b/src/larvaworld/gui/tabs/batch_run.py
@@ -1,11 +1,12 @@
#!/usr/bin/python
import copy
-import PySimpleGUI as sg
+
import pandas as pd
+import PySimpleGUI as sg
-from ...lib import reg, util, sim
from ...gui import gui_aux
+from ...lib import reg, sim, util
from ...lib.plot.table import mpl_table
__all__ = [
diff --git a/src/larvaworld/gui/tabs/env_draw.py b/src/larvaworld/gui/tabs/env_draw.py
index c177c02d..9d8ed437 100644
--- a/src/larvaworld/gui/tabs/env_draw.py
+++ b/src/larvaworld/gui/tabs/env_draw.py
@@ -4,10 +4,10 @@
import numpy as np
import PySimpleGUI as sg
-from ...lib import reg, util
from ...gui import gui_aux
+from ...lib import reg, util
from ...lib.model import Border
-from ...lib.param import generate_xy_distro, class_defaults
+from ...lib.param import class_defaults, generate_xy_distro
__all__ = [
"DrawEnvTab",
@@ -347,7 +347,7 @@ def eval(self, e, v, w, c, d, g):
dic["sample_fig"], dic["sample_pars"] = None, {}
else:
info.update(
- value=f"Draw a sample item for the distribution"
+ value="Draw a sample item for the distribution"
)
elif v[G]:
self.update_window_distro(v, w, o)
@@ -698,7 +698,7 @@ def check_abort(self, n, w, v, units, groups):
if n == S0:
if not odor_on and not food_on:
- info.update(value=f"Assign food and/or odor to the drawn source")
+ info.update(value="Assign food and/or odor to the drawn source")
return True
elif food_on and float(v[fM]) == 0.0:
w[fM].update(value=10**-3)
diff --git a/src/larvaworld/gui/tabs/essay.py b/src/larvaworld/gui/tabs/essay.py
index 5de631cb..54488f31 100644
--- a/src/larvaworld/gui/tabs/essay.py
+++ b/src/larvaworld/gui/tabs/essay.py
@@ -1,8 +1,7 @@
import os
-
-from ...lib import reg, util
from ...gui import gui_aux
+from ...lib import reg, util
__all__ = [
"EssayTab",
@@ -100,9 +99,9 @@ def eval(self, e, v, w, c, d, g):
def run_essay_exp(self, v, w, c, d, g, essay_exp):
from ...lib.reg.stored_confs.essay_conf import (
- RvsS_Essay,
- DoublePatch_Essay,
Chemotaxis_Essay,
+ DoublePatch_Essay,
+ RvsS_Essay,
)
type = self.current_ID(v)
diff --git a/src/larvaworld/gui/tabs/importing.py b/src/larvaworld/gui/tabs/importing.py
index 1ec1c56a..639c8d79 100644
--- a/src/larvaworld/gui/tabs/importing.py
+++ b/src/larvaworld/gui/tabs/importing.py
@@ -1,7 +1,7 @@
import PySimpleGUI as sg
-from ...lib import reg, sim
from ...gui import gui_aux
+from ...lib import reg, sim
__all__ = [
"ImportTab",
diff --git a/src/larvaworld/gui/tabs/intro.py b/src/larvaworld/gui/tabs/intro.py
index c84f73b3..7a6a5a35 100644
--- a/src/larvaworld/gui/tabs/intro.py
+++ b/src/larvaworld/gui/tabs/intro.py
@@ -1,8 +1,9 @@
import os
+
import PySimpleGUI as sg
-from ...lib import reg
from ...gui import gui_aux
+from ...lib import reg
__all__ = [
"IntroTab",
diff --git a/src/larvaworld/gui/tabs/larvaworld_gui.py b/src/larvaworld/gui/tabs/larvaworld_gui.py
index 908bfa08..e78fcfdd 100644
--- a/src/larvaworld/gui/tabs/larvaworld_gui.py
+++ b/src/larvaworld/gui/tabs/larvaworld_gui.py
@@ -1,12 +1,12 @@
-from typing import Any
-import numpy as np
-import PySimpleGUI as sg
import time
+from typing import Any
+import numpy as np
import pandas as pd
+import PySimpleGUI as sg
-from ...lib import reg, screen
from ...gui import gui_aux, tabs
+from ...lib import reg, screen
__all__ = [
"LarvaworldGui",
diff --git a/src/larvaworld/gui/tabs/life_history.py b/src/larvaworld/gui/tabs/life_history.py
index dfbb145e..0bd116a7 100644
--- a/src/larvaworld/gui/tabs/life_history.py
+++ b/src/larvaworld/gui/tabs/life_history.py
@@ -1,6 +1,5 @@
import PySimpleGUI as sg
-from ...lib import reg
from ...gui import gui_aux
from ...lib.param import Substrate
@@ -14,13 +13,13 @@ def __init__(self, **kwargs):
super().__init__(**kwargs)
self.Sq, self.Sa = "SLIDER_quality", "SLIDER_age"
self.s0, self.s1 = "start", "stop"
- self.S0, self.S1 = [f"SLIDER_epoch_{s}" for s in [self.s0, self.s1]]
+ self.S0, self.S1 = (f"SLIDER_epoch_{s}" for s in [self.s0, self.s1])
self.ep = "rearing epoch"
self.K = "EPOCHS"
def build(self):
- from ...lib.plot.deb import plot_debs
from ...lib.param import substrate_dict
+ from ...lib.plot.deb import plot_debs
sl1_kws = {"size": (30, 20), "enable_events": True, "orientation": "h"}
deb_modes = [
diff --git a/src/larvaworld/gui/tabs/model.py b/src/larvaworld/gui/tabs/model.py
index 32dabe45..a3778039 100644
--- a/src/larvaworld/gui/tabs/model.py
+++ b/src/larvaworld/gui/tabs/model.py
@@ -1,21 +1,22 @@
-import PySimpleGUI as sg
import copy
import os
-from ...lib import util, reg, model
+import PySimpleGUI as sg
+
from ...gui.gui_aux import (
- gui_col,
+ CollapsibleTable,
GraphList,
- col_kws,
- SelectionList,
- named_bool_button,
GuiTab,
- tab_kws,
- CollapsibleTable,
PadDict,
+ SelectionList,
+ col_kws,
+ gui_col,
+ named_bool_button,
t_kws,
+ tab_kws,
)
from ...gui.tabs.body_draw import DrawBodyTab
+from ...lib import model, reg, util
__all__ = [
"ModelTab",
diff --git a/src/larvaworld/gui/tabs/settings.py b/src/larvaworld/gui/tabs/settings.py
index f773b913..9aa2fe23 100644
--- a/src/larvaworld/gui/tabs/settings.py
+++ b/src/larvaworld/gui/tabs/settings.py
@@ -1,10 +1,9 @@
import time
-import PySimpleGUI as sg
+import PySimpleGUI as sg
-from ...lib import reg, util
from ...gui import gui_aux
-
+from ...lib import reg, util
__all__ = [
"SettingsTab",
diff --git a/src/larvaworld/gui/tabs/simulation.py b/src/larvaworld/gui/tabs/simulation.py
index 201ec058..7e09f8fa 100644
--- a/src/larvaworld/gui/tabs/simulation.py
+++ b/src/larvaworld/gui/tabs/simulation.py
@@ -1,10 +1,9 @@
import copy
-import PySimpleGUI as sg
-
-from ...lib import reg, util, sim
+import PySimpleGUI as sg
from ...gui import gui_aux, tabs
+from ...lib import reg, sim
__all__ = [
"SimTab",
diff --git a/src/larvaworld/gui/tabs/tutorial.py b/src/larvaworld/gui/tabs/tutorial.py
index 9412b036..9fe59d67 100644
--- a/src/larvaworld/gui/tabs/tutorial.py
+++ b/src/larvaworld/gui/tabs/tutorial.py
@@ -1,9 +1,10 @@
import os
import webbrowser
+
import PySimpleGUI as sg
-from ...lib import reg
from ...gui import gui_aux
+from ...lib import reg
__all__ = [
"TutorialTab",
diff --git a/src/larvaworld/gui/tabs/videos.py b/src/larvaworld/gui/tabs/videos.py
index 340354d2..b4dd1b12 100644
--- a/src/larvaworld/gui/tabs/videos.py
+++ b/src/larvaworld/gui/tabs/videos.py
@@ -1,8 +1,9 @@
import os
+
import PySimpleGUI as sg
-from ...lib import reg
from ...gui import gui_aux
+from ...lib import reg
__all__ = [
"VideoTab",
diff --git a/src/larvaworld/lib/ipc/__init__.py b/src/larvaworld/lib/ipc/__init__.py
index bc498365..a816f9ea 100644
--- a/src/larvaworld/lib/ipc/__init__.py
+++ b/src/larvaworld/lib/ipc/__init__.py
@@ -2,7 +2,7 @@
Interface between a larvaworld simulation and a remote model
"""
-from .ipc import Server, Client
+from .ipc import Client, Server
__displayname__ = "Client-Server"
@@ -23,5 +23,5 @@ def with_params(self, **params):
def param(self, key):
try:
return self.params[key]
- except Exception as e:
+ except Exception:
return None
diff --git a/src/larvaworld/lib/ipc/ipc.py b/src/larvaworld/lib/ipc/ipc.py
index 6543c737..bc81b409 100644
--- a/src/larvaworld/lib/ipc/ipc.py
+++ b/src/larvaworld/lib/ipc/ipc.py
@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import socketserver
+import json
import socket
+import socketserver
import struct
-import json
try:
from socketserver import ThreadingUnixStreamServer as StreamServer
@@ -23,7 +23,6 @@
from socketserver import ThreadingTCPServer as StreamServer
from socketserver import ThreadingTCPServer
-
__all__ = [
"Message",
"Client",
@@ -74,7 +73,7 @@ def _recursive_subclasses(cls):
return classmap
-class Message(object):
+class Message:
@classmethod
def deserialize(cls, objects):
classmap = _recursive_subclasses(cls)
@@ -103,12 +102,12 @@ def _get_args(self):
def __repr__(self):
r = self.serialize()
args = ", ".join([repr(arg) for arg in r["args"]])
- kwargs = "".join([", {}={}".format(k, repr(v)) for k, v in r["kwargs"].items()])
+ kwargs = "".join([f", {k}={v!r}" for k, v in r["kwargs"].items()])
name = r["class"]
- return "{}({}{})".format(name, args, kwargs)
+ return f"{name}({args}{kwargs})"
-class Client(object):
+class Client:
def __init__(self, server_address):
self.addr = server_address
# print(self.addr)
@@ -147,7 +146,7 @@ def handle(self):
while True:
try:
results = _read_objects(self.request)
- except ConnectionClosed as e:
+ except ConnectionClosed:
return
_write_objects(self.request, callback(results))
diff --git a/src/larvaworld/lib/model/agents/_agent.py b/src/larvaworld/lib/model/agents/_agent.py
index ecb198cf..8267309f 100644
--- a/src/larvaworld/lib/model/agents/_agent.py
+++ b/src/larvaworld/lib/model/agents/_agent.py
@@ -1,16 +1,14 @@
-import numpy as np
-
from ...param import (
- OrientedPoint,
- RadiallyExtended,
ClassAttr,
MobilePoint,
MobileVector,
+ OrientedPoint,
+ RadiallyExtended,
Viewable,
)
from ...param.composition import Odor
-from ..object import GroupedObject
from ...screen.rendering import IDBox
+from ..object import GroupedObject
__all__ = [
"NonSpatialAgent",
@@ -24,7 +22,8 @@
class NonSpatialAgent(GroupedObject):
- """An agent lacking spatial positioning in space.
+ """
+ An agent lacking spatial positioning in space.
Args:
odor (dict) : An optional dictionary containing odor information of the agent.
@@ -47,7 +46,8 @@ def step(self):
class PointAgent(RadiallyExtended, NonSpatialAgent, Viewable):
- """Agent with a point spatial representation.
+ """
+ Agent with a point spatial representation.
This agent class extends the NonSpatialAgent class and represents agents as points.
"""
@@ -81,7 +81,8 @@ def draw_selected(self, v, **kwargs):
class OrientedAgent(OrientedPoint, PointAgent):
- """An agent represented as an oriented point in space.
+ """
+ An agent represented as an oriented point in space.
This agent class extends the PointAgent class and adds orientation to the agent.
"""
@@ -92,7 +93,8 @@ def __init__(self, **kwargs):
class MobilePointAgent(MobilePoint, PointAgent):
- """A mobile point agent.
+ """
+ A mobile point agent.
This agent class extends the PointAgent class and adds mobility with point representation.
"""
@@ -103,7 +105,8 @@ def __init__(self, **kwargs):
class MobileAgent(MobileVector, PointAgent):
- """An agent represented in space as a mobile oriented vector.
+ """
+ An agent represented in space as a mobile oriented vector.
This agent class extends the PointAgent class and uses vector representation for mobility.
"""
@@ -115,17 +118,14 @@ def __init__(self, **kwargs):
@property
def last_orientation_vel(self):
"""The last angular velocity of the agent."""
-
return self.last_delta_orientation / self.dt
@property
def last_pos_vel(self):
"""The last translational velocity of the agent."""
-
return self.last_delta_pos / self.dt
@property
def last_scaled_pos_vel(self):
"""The last translational velocity of the agent, scaled to its vector length."""
-
return self.last_delta_pos / self.length / self.dt
diff --git a/src/larvaworld/lib/model/agents/_larva.py b/src/larvaworld/lib/model/agents/_larva.py
index 09e3910f..8a646665 100644
--- a/src/larvaworld/lib/model/agents/_larva.py
+++ b/src/larvaworld/lib/model/agents/_larva.py
@@ -1,10 +1,11 @@
import math
from copy import deepcopy
+
import numpy as np
-from ... import reg, util
-from . import Source, MobileAgent
-from ...param import SegmentedBodySensored, Contour
+from ... import util
+from ...param import Contour, SegmentedBodySensored
+from . import MobileAgent, Source
__all__ = [
"Larva",
@@ -17,7 +18,8 @@
class Larva(MobileAgent):
- """A Larva as a mobile agent.
+ """
+ A Larva as a mobile agent.
Args:
model (larvaworld.lib.model.Model) : The model containing this agent.
@@ -161,7 +163,8 @@ def draw_selected(self, v, **kwargs):
class LarvaMotile(LarvaSegmented):
- """A larva with a segmented body, sensors, a brain, energetics, and life history.
+ """
+ A larva with a segmented body, sensors, a brain, energetics, and life history.
Args:
brain (larvaworld.lib.model.modules.brain.BrainConfiguration) :
@@ -170,6 +173,7 @@ class LarvaMotile(LarvaSegmented):
The energetics parameters for the larva. Defaults to None.
life_history (dict) : The life history of the larva. Defaults to None.
**kwargs (dict) : Additional keyword arguments.
+
"""
__displayname__ = "Behaving & growing larva"
@@ -184,7 +188,6 @@ def __init__(self, brain, energetics, life_history, body, **kwargs):
def build_brain(self, conf):
"""Build the brain for the larva agent."""
-
if conf.nengo:
from larvaworld.lib.model.modules.nengobrain import NengoBrain
diff --git a/src/larvaworld/lib/model/agents/_larva_replay.py b/src/larvaworld/lib/model/agents/_larva_replay.py
index 32fef062..1e700ce9 100644
--- a/src/larvaworld/lib/model/agents/_larva_replay.py
+++ b/src/larvaworld/lib/model/agents/_larva_replay.py
@@ -1,7 +1,6 @@
import numpy as np
-from ... import util, reg
-from ...util import nam
+from ... import util
from . import Larva, LarvaContoured, LarvaSegmented
__all__ = [
@@ -51,7 +50,6 @@ def step(self):
It also updates the trajectory and orientation_trajectory attributes.
"""
-
self.pos = self.data.pos[self.model.t]
self.trajectory.append(self.pos)
self.orientation_trajectory.append(self.front_orientation)
@@ -69,7 +67,6 @@ def midline_xy(self):
A list of tuples representing the xy coordinates of the midline points.
"""
-
return util.np2Dtotuples(self.data.midline[self.model.t])
@property
@@ -83,7 +80,6 @@ def front_orientation(self):
The front orientation in radians.
"""
-
return self.data.front_orientation[self.model.t]
@property
@@ -97,7 +93,6 @@ def rear_orientation(self):
The rear orientation in radians.
"""
-
return self.data.rear_orientation[self.model.t]
@@ -121,7 +116,6 @@ def step(self):
contour data to the replay larva.
"""
-
super().step()
self.vertices = self.contour_xy
@@ -136,7 +130,6 @@ def contour_xy(self):
A list of tuples representing the xy coordinates of the contour points.
"""
-
a = self.data.contour[self.model.t]
a = a[~np.isnan(a)].reshape(-1, 2)
return util.np2Dtotuples(a)
@@ -163,7 +156,6 @@ def step(self):
and positions multiple body segments based on recorded data.
"""
-
super().step()
mid = self.midline_xy
ors = self.data.seg_orientations[self.model.t]
diff --git a/src/larvaworld/lib/model/agents/_larva_sim.py b/src/larvaworld/lib/model/agents/_larva_sim.py
index 2ce49a71..8da7c851 100644
--- a/src/larvaworld/lib/model/agents/_larva_sim.py
+++ b/src/larvaworld/lib/model/agents/_larva_sim.py
@@ -5,8 +5,8 @@
from shapely import geometry
from ... import util
-from . import LarvaMotile
from ...param import PositiveNumber
+from . import LarvaMotile
__all__ = [
"BaseController",
@@ -20,7 +20,7 @@ class BaseController(param.Parameterized):
"""
Base controller for larva motion simulation.
- Parameters:
+ Parameters
----------
lin_vel_coef : float, positive
Coefficient for translational velocity.
@@ -43,10 +43,11 @@ class BaseController(param.Parameterized):
ang_mode : str
Mode of angular motion generation ('torque', 'velocity').
- Methods:
- --------
+ Methods
+ -------
compute_delta_rear_angle(bend, dst, length)
Compute the change in rear angle based on bend, distance, and length.
+
"""
lin_vel_coef = PositiveNumber(1.0, doc="Coefficient for translational velocity")
@@ -71,7 +72,7 @@ def compute_delta_rear_angle(self, bend, dst, length):
"""
Compute the change in rear angle based on bend, distance, and length.
- Parameters:
+ Parameters
----------
bend : float
Bend angle.
@@ -80,10 +81,11 @@ def compute_delta_rear_angle(self, bend, dst, length):
length : float
Length of the larva.
- Returns:
+ Returns
-------
float
Change in rear angle.
+
"""
k0 = 2 * dst * self.bend_correction_coef / length
if 0 <= k0 < 1:
@@ -98,7 +100,7 @@ class LarvaSim(LarvaMotile, BaseController):
"""
Simulated larva agent.
- Parameters:
+ Parameters
----------
physics : dict
Dictionary containing physical parameters for the larva simulation.
@@ -107,8 +109,8 @@ class LarvaSim(LarvaMotile, BaseController):
**kwargs
Additional keyword arguments.
- Methods:
- --------
+ Methods
+ -------
compute_ang_vel(amp)
Compute angular velocity based on torque amplitude.
prepare_motion(lin, ang)
@@ -121,6 +123,7 @@ class LarvaSim(LarvaMotile, BaseController):
Position the larva's head in the simulated tank.
position_body(lin_vel, ang_vel)
Position the larva's body based on translational and angular motion.
+
"""
__displayname__ = "Simulated larva"
@@ -135,17 +138,17 @@ def compute_ang_vel(self, amp):
"""
Compute angular velocity based on torque amplitude.
- Parameters:
+ Parameters
----------
amp : float
Torque amplitude.
- Returns:
+ Returns
-------
float
Angular velocity.
- """
+ """
torque = amp * self.torque_coef
ang_vel = self.get_angularvelocity()
return (
@@ -162,14 +165,14 @@ def prepare_motion(self, lin, ang):
"""
Prepare translational and angular motion.
- Parameters:
+ Parameters
----------
lin : float
Linear motion parameter.
ang : float
Angular motion parameter.
- """
+ """
lin_vel = lin * self.lin_vel_coef
if self.ang_mode == "torque":
ang_vel = self.compute_ang_vel(ang)
@@ -187,10 +190,11 @@ def border_collision(self):
"""
Check for collisions with borders.
- Returns:
+ Returns
-------
bool
True if there is a border collision, False otherwise.
+
"""
if len(self.model.borders) == 0:
return False
@@ -217,10 +221,11 @@ def larva_collision(self):
"""
Check for collisions with other larvae.
- Returns:
+ Returns
-------
bool
True if there is a collision, False otherwise.
+
"""
if not self.model.larva_collisions:
ids = self.model.detect_collisions(self.unique_id)
@@ -232,7 +237,7 @@ def position_head_in_tank(self, hr0, ho0, l0, fov0, fov1, ang_vel, lin_vel):
"""
Position the larva's head in the simulated tank.
- Parameters:
+ Parameters
----------
hr0 : tuple
Initial position of the rear end of the larva.
@@ -249,12 +254,12 @@ def position_head_in_tank(self, hr0, ho0, l0, fov0, fov1, ang_vel, lin_vel):
lin_vel : float
Linear velocity.
- Returns:
+ Returns
-------
tuple
New angular velocity and linear velocity.
- """
+ """
dt = self.model.dt
sf = self.model.scaling_factor
@@ -309,14 +314,14 @@ def position_body(self, lin_vel, ang_vel):
"""
Position the larva's body based on translational and angular motion.
- Parameters:
+ Parameters
----------
lin_vel : float
Linear velocity.
ang_vel : float
Angular velocity.
- """
+ """
dt = self.model.dt
hp0, ho0 = self.head.get_pose()
hr0 = self.head.rear_end
@@ -354,7 +359,7 @@ def update_larva_pose(self, position, orientation, lin_vel=0, ang_vel=0):
"""
Update the larva's pose and trajectories' log.
- Parameters:
+ Parameters
----------
position : float
2D position.
@@ -364,8 +369,8 @@ def update_larva_pose(self, position, orientation, lin_vel=0, ang_vel=0):
Linear velocity.
ang_vel : float
Angular velocity.
- """
+ """
self.update_all(position, orientation, lin_vel=lin_vel, ang_vel=ang_vel)
self.trajectory.append(position)
self.orientation_trajectory.append(orientation)
@@ -376,12 +381,12 @@ def reset_larva_pose(self, reset_trajectories=False):
"""
Reset the larva's pose to the initial position and orientation.
- Parameters:
+ Parameters
----------
reset_trajectories : bool
Reset the trajectories's log
- """
+ """
if reset_trajectories:
self.trajectory = []
self.orientation_trajectory = []
diff --git a/src/larvaworld/lib/model/agents/_source.py b/src/larvaworld/lib/model/agents/_source.py
index 015be225..f87054f1 100644
--- a/src/larvaworld/lib/model/agents/_source.py
+++ b/src/larvaworld/lib/model/agents/_source.py
@@ -1,8 +1,8 @@
import numpy as np
import param
+from ...param import ClassAttr, PositiveNumber, Substrate, xy_uniform_circle
from . import PointAgent
-from ...param import xy_uniform_circle, Substrate, PositiveNumber, ClassAttr
__all__ = [
"Source",
@@ -16,7 +16,7 @@ class Source(PointAgent):
"""
Base class for representing a source of something in the environment.
- Parameters:
+ Parameters
----------
can_be_carried : bool, default False
Whether the source can be carried around.
@@ -27,19 +27,20 @@ class Source(PointAgent):
regeneration_pos : tuple or None, default None
Where the agent appears if regenerated.
- Attributes:
+ Attributes
----------
is_carried_by : object or None
Reference to the agent that is currently carrying this source.
- Methods:
- --------
+ Methods
+ -------
step()
Perform a step in the simulation, possibly updating the source's position.
- Notes:
- ------
+ Notes
+ -----
This class is a base class for representing various types of sources in the environment.
+
"""
can_be_carried = param.Boolean(
@@ -82,30 +83,31 @@ class Food(Source):
"""
Class for representing a source of food in the environment.
- Parameters:
+ Parameters
----------
amount : float, default 10.0
The initial amount of food in the source.
substrate : Substrate, default None
The substrate where the agent feeds.
- Attributes:
+ Attributes
----------
color : str
Color of the food source.
initial_amount : float
Initial amount of food in the source.
- Methods:
- --------
+ Methods
+ -------
subtract_amount(amount)
Subtract a given amount of food from the source.
draw(v, filled=None)
Draw the food source on the visualization canvas.
- Notes:
- ------
+ Notes
+ -----
This class extends the `Source` class to represent food sources specifically.
+
"""
color = param.Color(default="green")
@@ -122,19 +124,20 @@ def subtract_amount(self, amount):
"""
Subtract a given amount of food from the source.
- Parameters:
+ Parameters
----------
amount : float
Amount of food to subtract.
- Returns:
+ Returns
-------
float
The actual amount subtracted, which may be less than the requested amount.
- Notes:
- ------
+ Notes
+ -----
If the source runs out of food, it is deleted from the simulation.
+
"""
prev_amount = self.amount
if amount >= self.amount:
diff --git a/src/larvaworld/lib/model/agents/braitenberg_robot.py b/src/larvaworld/lib/model/agents/braitenberg_robot.py
index 7b023d90..458a4e2b 100644
--- a/src/larvaworld/lib/model/agents/braitenberg_robot.py
+++ b/src/larvaworld/lib/model/agents/braitenberg_robot.py
@@ -1,9 +1,9 @@
import random
+
import numpy as np
-from ...model.modules.rot_surface import RotTriangle
from ... import util
-
+from ...model.modules.rot_surface import RotTriangle
__all__ = [
"DifferentialDriveRobot",
@@ -35,7 +35,7 @@ def __init__(self, unique_id, model, x, y, length, wheel_radius):
self.deltay = None
def step(self):
- """updates x, y and direction"""
+ """Updates x, y and direction"""
self.delta_x()
self.delta_y()
self.delta_direction()
@@ -46,7 +46,7 @@ def move_duration(self, seconds):
self.step()
def print_xyd(self):
- """prints the x,y position and direction"""
+ """Prints the x,y position and direction"""
print("x = " + str(self.x) + " " + "y = " + str(self.y))
print("direction = " + str(self.direction))
diff --git a/src/larvaworld/lib/model/agents/larva_offline.py b/src/larvaworld/lib/model/agents/larva_offline.py
index 2047a937..f0305943 100644
--- a/src/larvaworld/lib/model/agents/larva_offline.py
+++ b/src/larvaworld/lib/model/agents/larva_offline.py
@@ -1,4 +1,5 @@
import random
+
import numpy as np
import pandas as pd
diff --git a/src/larvaworld/lib/model/agents/larva_robot.py b/src/larvaworld/lib/model/agents/larva_robot.py
index 37709da6..e01a5ba6 100644
--- a/src/larvaworld/lib/model/agents/larva_robot.py
+++ b/src/larvaworld/lib/model/agents/larva_robot.py
@@ -1,9 +1,8 @@
from ... import util
-from . import LarvaSim
-from ...model.modules.motor_controller import MotorController, Actuator
+from ...model.modules.motor_controller import Actuator, MotorController
from ...model.modules.sensor2 import ProximitySensor
from ...param import PositiveNumber
-
+from . import LarvaSim
__all__ = [
"LarvaRobot",
diff --git a/src/larvaworld/lib/model/box2d.py b/src/larvaworld/lib/model/box2d.py
index fcf8e3ff..7f738e9f 100644
--- a/src/larvaworld/lib/model/box2d.py
+++ b/src/larvaworld/lib/model/box2d.py
@@ -4,14 +4,14 @@
"""
# import Box2D
-from Box2D.b2 import world, polygonShape, circleShape, staticBody, dynamicBody, vec2
import numpy as np
import param
+from Box2D.b2 import dynamicBody, polygonShape, staticBody, vec2, world
from shapely import geometry
-from .. import util, reg
-from .agents import LarvaSim
+from .. import util
from ..param import ShapeMobile
+from .agents import LarvaSim
from .envs import Arena
__all__ = ["SegmentBox2D", "LarvaBox2D", "ArenaBox2D"]
@@ -30,7 +30,6 @@ class SegmentBox2D(ShapeMobile):
Methods:
-
get_position():
Get the world position of the segment.
@@ -66,6 +65,7 @@ class SegmentBox2D(ShapeMobile):
get_world_facing_axis():
Get the world-facing axis of the segment.
+
"""
__displayname__ = "Box2D body segment"
@@ -100,6 +100,7 @@ def get_position(self):
-------
numpy.ndarray
The world position of the segment.
+
"""
pos = self._body.worldCenter
return np.asarray(pos)
@@ -112,6 +113,7 @@ def set_position(self, position):
----------
position : tuple
The new world position.
+
"""
self._body.position = position
@@ -123,6 +125,7 @@ def get_orientation(self):
-------
float
The orientation of the segment.
+
"""
return self._body.angle
@@ -134,6 +137,7 @@ def set_orientation(self, orientation):
----------
orientation : float
The new orientation of the segment.
+
"""
self._body.angle = orientation % (np.pi * 2)
@@ -145,6 +149,7 @@ def get_pose(self):
-------
tuple
The pose of the segment, including position and orientation.
+
"""
pos = np.asarray(self._body.position)
return tuple((*pos, self._body.angle))
@@ -159,6 +164,7 @@ def set_linearvelocity(self, lin_vel, local=False):
The new linear velocity.
local : bool, optional
Whether the linear velocity is in local coordinates. Defaults to False.
+
"""
if local:
lin_vel = self._body.GetWorldVector(np.asarray(lin_vel))
@@ -172,6 +178,7 @@ def get_angularvelocity(self):
-------
float
The angular velocity of the segment.
+
"""
return self._body.angularVelocity
@@ -183,6 +190,7 @@ def set_angularvelocity(self, ang_vel):
----------
ang_vel : float
The new angular velocity of the segment.
+
"""
self._body.angularVelocity = ang_vel
@@ -194,6 +202,7 @@ def set_mass(self, mass):
----------
mass : float
The new mass of the segment.
+
"""
self._body.mass = mass
@@ -205,6 +214,7 @@ def get_mass(self):
-------
float
The mass of the segment.
+
"""
return self._body.mass
@@ -221,6 +231,7 @@ def get_world_point(self, point):
-------
numpy.ndarray
The world coordinates of the point.
+
"""
return self._body.GetWorldPoint(np.asarray(point))
@@ -232,6 +243,7 @@ def get_world_facing_axis(self):
-------
numpy.ndarray
The world-facing axis of the segment.
+
"""
return np.asarray(self._body.GetWorldVector(vec2(1.0, 0.0)))
@@ -293,8 +305,8 @@ def prepare_motion(self, lin, ang):
Linear velocity.
ang : float
Angular velocity.
- """
+ """
if self.ang_mode == "velocity":
ang_vel = ang * self.ang_vel_coef
self.segs[0].set_angularvelocity(ang_vel)
@@ -343,7 +355,6 @@ def updated_by_Box2D(self):
"""
Update the larva simulation based on Box2D physics.
"""
-
self.set_position(tuple(self.global_midspine_of_body))
self.trajectory.append(self.get_position())
@@ -395,7 +406,6 @@ def create_joints(self, Nsegs, segs, joint_types=None):
larva together in a physically realistic way.
"""
-
if joint_types is None:
joint_types = util.AttrDict(
{
diff --git a/src/larvaworld/lib/model/deb/deb.py b/src/larvaworld/lib/model/deb/deb.py
index a8019757..549d6641 100644
--- a/src/larvaworld/lib/model/deb/deb.py
+++ b/src/larvaworld/lib/model/deb/deb.py
@@ -4,21 +4,21 @@
import json
import os
+
import numpy as np
import param
-
from ... import reg, util
-from ...util import nam, simplex, beta0
-from . import Gut
from ...param import (
- Substrate,
- NestedConf,
- PositiveNumber,
ClassAttr,
- OptionalPositiveNumber,
Life,
+ NestedConf,
+ OptionalPositiveNumber,
+ PositiveNumber,
+ Substrate,
)
+from ...util import beta0, nam, simplex
+from . import Gut
__all__ = [
"DEB_model",
@@ -183,7 +183,8 @@ def get_E0(self):
"""
This function calculates the maximum reserve density (E0) that an organism can achieve given its energy budget parameters.
- Parameters:
+ Parameters
+ ----------
kap (float): Fraction of assimilated energy that is used for somatic maintenance.
v (float): Energy conductance.
p_M (float): Specific somatic maintenance costs.
@@ -192,10 +193,11 @@ def get_E0(self):
eb (float, optional): Allocation fraction to reserve production. Defaults to 1.0.
lb (float, optional): Length at birth. If not provided, it is calculated from the other parameters. Defaults to None.
- Returns:
+ Returns
+ -------
float: Maximum reserve density that an organism can achieve.
- """
+ """
# Calculate uE0 using the equation in the Dynamic Energy Budget textbook
uE0 = np.real(
(
@@ -381,7 +383,7 @@ def print_life_history(self, Es, Wws, Lws, Durs):
@property
def M_V(self):
- "number of C-atoms per unit of structural body volume V : dV /wV"
+ """Number of C-atoms per unit of structural body volume V : dV /wV"""
return self.d_V / self.w_V
@property
diff --git a/src/larvaworld/lib/model/deb/gut.py b/src/larvaworld/lib/model/deb/gut.py
index bc4a8d63..b8671136 100644
--- a/src/larvaworld/lib/model/deb/gut.py
+++ b/src/larvaworld/lib/model/deb/gut.py
@@ -2,7 +2,7 @@
import param
from ... import util
-from ...param import PositiveNumber, NestedConf
+from ...param import NestedConf, PositiveNumber
__all__ = [
"Gut",
diff --git a/src/larvaworld/lib/model/envs/__init__.py b/src/larvaworld/lib/model/envs/__init__.py
index d8618933..8ac2a143 100644
--- a/src/larvaworld/lib/model/envs/__init__.py
+++ b/src/larvaworld/lib/model/envs/__init__.py
@@ -4,8 +4,8 @@
as well as any existing sensory landscapes.
"""
-from .obstacle import *
from .arena import Arena
+from .obstacle import *
from .valuegrid import *
__displayname__ = "Environment"
diff --git a/src/larvaworld/lib/model/envs/arena.py b/src/larvaworld/lib/model/envs/arena.py
index a166367b..ef68fb92 100644
--- a/src/larvaworld/lib/model/envs/arena.py
+++ b/src/larvaworld/lib/model/envs/arena.py
@@ -3,9 +3,9 @@
import param
from shapely.geometry import Point
-from .valuegrid import SpatialEntity
from ... import util
from ...param import BoundedArea
+from .valuegrid import SpatialEntity
__all__ = [
"Arena",
diff --git a/src/larvaworld/lib/model/envs/maze.py b/src/larvaworld/lib/model/envs/maze.py
index 4478c35c..47fe74e1 100644
--- a/src/larvaworld/lib/model/envs/maze.py
+++ b/src/larvaworld/lib/model/envs/maze.py
@@ -9,7 +9,8 @@
class Cell:
- """A cell in the maze.
+ """
+ A cell in the maze.
A maze "Cell" is a point in the grid which may be surrounded by walls to
the north, east, south or west.
@@ -21,18 +22,15 @@ class Cell:
def __init__(self, x, y):
"""Initialize the cell at (x,y). At first it is surrounded by walls."""
-
self.x, self.y = x, y
self.walls = {"N": True, "S": True, "E": True, "W": True}
def has_all_walls(self):
"""Does this cell still have all its walls?"""
-
return all(self.walls.values())
def knock_down_wall(self, other, wall):
"""Knock down the wall between cells self and other."""
-
self.walls[wall] = False
other.walls[Cell.wall_pairs[wall]] = False
@@ -41,7 +39,8 @@ class Maze:
"""A Maze, represented as a grid of cells."""
def __init__(self, nx, ny, ix=0, iy=0, height=1.0):
- """Initialize the maze grid.
+ """
+ Initialize the maze grid.
The maze consists of nx x ny cells and will be constructed starting
at the cell indexed at (ix, iy).
@@ -53,12 +52,10 @@ def __init__(self, nx, ny, ix=0, iy=0, height=1.0):
def cell_at(self, x, y):
"""Return the Cell object_class at (x,y)."""
-
return self.maze_map[x][y]
def __str__(self):
"""Return a (crude) string representation of the maze."""
-
maze_rows = ["-" * self.nx * 2]
for y in range(self.ny):
maze_row = ["|"]
@@ -79,7 +76,6 @@ def __str__(self):
def write_svg(self, filename):
"""Write an SVG image of the maze to filename."""
-
aspect_ratio = self.nx / self.ny
# Pad the maze all around by this amount.
padding = 10
@@ -91,11 +87,8 @@ def write_svg(self, filename):
def write_wall(ww_f, ww_x1, ww_y1, ww_x2, ww_y2):
"""Write a single wall to the SVG image file handle f."""
-
print(
- ''.format(
- ww_x1, ww_y1, ww_x2, ww_y2
- ),
+ f'',
file=ww_f,
)
@@ -106,14 +99,7 @@ def write_wall(ww_f, ww_x1, ww_y1, ww_x2, ww_y2):
print('