我有两个numpy数组,持有2d向量:
import numpy as np
a = np.array([[ 0.999875, 0.015836],
[ 0.997443, 0.071463],
[ 0.686554, 0.727078],
[ 0.93322 , 0.359305]])
b = np.array([[ 0.7219 , 0.691997],
[ 0.313656, 0.949537],
[ 0.507926, 0.861401],
[ 0.818131, 0.575031],
[ 0.117956, 0.993019]])
Run Code Online (Sandbox Code Playgroud)
如您所见,a.shape是(4,2)并且b.shape是(5,2).
现在,我可以得到我想要的结果:
In [441]: np.array([np.cross(av, bv) for bv in b for av in a]).reshape(5, 4)
Out[441]:
array([[ 0.680478, 0.638638, -0.049784, 0.386403],
[ 0.944451, 0.924694, 0.423856, 0.773429],
[ 0.85325 , 0.8229 , 0.222097, 0.621377],
[ 0.562003, 0.515094, -0.200055, 0.242672], …Run Code Online (Sandbox Code Playgroud) 如果我在 VSCode 中的调试器下运行 Python 程序,并且该程序具有行import matplotlib.pyplot as plt,我会在 Python 调试控制台(在选项TERMINAL卡下)中看到以下消息:
Backend TkAgg is interactive backend. Turning interactive mode on.
Run Code Online (Sandbox Code Playgroud)
这是所希望的,因为现在当我在选项卡下的 REPL 中探索数据时,
我不必plt.show()每次都
键入。plt.plot()DEBUG CONSOLE
问题是,并非每个程序都有该import行,因此我被迫在调试 REPL 中手动执行此操作,并在每个程序后面plt.plot()
加上plt.show().
我的问题:有没有办法强制这种“交互模式”,也许通过launch.json文件?我查看了文档launch.json
,但没有看到任何适用的内容。
我在 Windows 10 版本 20H2 上使用 VSCode 1.63.2。