我在Jupyter笔记本中有一个单选按钮小部件,我想保存选定状态,最好保存在笔记本json中。当我保存笔记本时,这似乎没有发生。重新打开笔记本计算机时,状态会丢失并重置。有没有办法保存状态并重新加载?
我想要一个脚本来查询我的Mendeley桌面以获取文章列表.这是可能的(使用任何脚本语言,包括shell)?我知道有一个我可以在http上使用的API,但是当我没有连接到互联网时,我需要一个本地查询.
我不确定scipy.integrate.solve_ivp中的事件处理是否正常工作.在下面的例子中,我整合了一个导数,它应该产生一个三次多项式,在x = -6,x = -2和x = 2时有三个根.我设置了一个返回y的事件函数,该函数在这些x值处为零.我希望在解决方案的t_events属性中看到三个条目,但我只看到一个,即使很明显解决方案穿过x轴三次.
我在这里做错了吗?
def fprime(x, y):
return 3 * x**2 + 12 * x - 4
def event(x, y):
return y
import numpy as np
from scipy.integrate import solve_ivp
sol = solve_ivp(fprime, (-8, 4), np.array([-120]), t_eval=np.linspace(-8, 4, 10), events=[event])
Run Code Online (Sandbox Code Playgroud)
上面的代码导致:
message: 'The solver successfully reached the interval end.'
nfev: 26
njev: 0
nlu: 0
sol: None
status: 0
success: True
t: array([-8. , -6.66666667, -5.33333333, -4. , -2.66666667,
-1.33333333, 0. , 1.33333333, 2.66666667, 4. …Run Code Online (Sandbox Code Playgroud) 我定义了这个宏:
(defmacro with-current-directory (directory &rest body)
"Set the working directory temporarily set to DIRECTORY and run BODY.
DIRECTORY is expanded"
`(let ((default-directory
,(file-name-as-directory
(expand-file-name (eval directory)))))
,@body))
Run Code Online (Sandbox Code Playgroud)
我在emacs打开时加载的一些lisp函数中使用它.我总是得到这些警告:
Eager macro-expansion failure: (void-variable repo-dir)
Eager macro-expansion failure: (wrong-type-argument stringp nil)
Run Code Online (Sandbox Code Playgroud)
据我所知,因为这些变量没有在加载时定义,而emacs正试图评估它们.我的问题是,我如何避免收到这些警告.有没有办法定义宏,以便不会发生?我无法弄清楚如何使用变量的值,而不是变量本身的符号.
是否可以获取 emacs-lisp 文件中定义的函数列表?我找到了这种相关的答案:How do I get a list of Emacs lisp non-interactive functions? ,但它涉及所有定义的原子的映射,而不仅仅是文件中的原子。