Lar*_*son 6 python markup slider jupyter-notebook google-colaboratory
Google Colab 具有一些独特的嵌入式Markdown功能,这些功能在Jupyter markdown中不存在。
例如,这会产生一个滑块:
#@title SEIR Model with Social Distancing { run: "auto" }
#@markdown
#@markdown Reproduction number
R0 = 2.4 #@param {type:"slider", min:0.9, max:5, step:0.1}
Run Code Online (Sandbox Code Playgroud)
尝试在本地运行 Colab似乎是否定的:CoLab 笔记本必须通过 Google CoLab 网站才能运行。
在不通过外部网站的情况下,以开源方式在本地运行的笔记本中在 Jupyter 上运行,从 CoLab 生成等效的 @param 标记的最佳方法是什么?
小智 4
我一直在努力解决同样的问题,我通过使用ipywidgets Jupyter Widgets 文档解决了它,它不是那么优雅,但有效。
@interact_manual(R0 = (0.9,5.1,0.1))
def my_function(R0 = 2.4):
print("SEIR Model with Social Distancing")
print("Reproduction number")
print(R0) # do something - enter your code here
Run Code Online (Sandbox Code Playgroud)
发生的情况是,您将获得一个带有最小/最大值和步长的滑块。我正在使用 _manual - 您可以设置多个参数,按照您想要的方式设置它们后,您可以单击“ Run Interact ”按钮,该按钮将调用您的函数(例如my_function)。
适用于 VS-Code,但不适用于 PyCharm