I have been playing around with Django Channels for a a little bit and I am stuck on how to get it to work outside of a local development server setting. Before someone just pastes a documentation page to me, I have exhausted my search of the Django Channels documentation and everywhere else I could find. I can get the local setup to work fine, but not externally. My philosophy over years has been to never develop with the Django …
我面临的情况是我有一个非常大的numpy.ndarray(实际上,它是一个 hdf5 数据集),我需要快速找到一个子集,因为它们整个数组无法保存在内存中。但是,我也不想遍历这样的数组(即使声明内置的 numpy 迭代器抛出 a MemoryError),因为我的脚本实际上需要几天才能运行。
因此,我面临迭代数组的某些维度的情况,以便我可以对完整数组的缩减子集执行数组操作。为此,我需要能够动态切出数组的一个子集。动态切片意味着构造一个元组并传递它。
例如,代替
my_array[0,0,0]
Run Code Online (Sandbox Code Playgroud)
我可能会用
my_array[(0,0,0,)]
Run Code Online (Sandbox Code Playgroud)
问题是:如果我想手动沿数组的特定维度/轴切出所有值,我可以执行类似的操作
my_array[0,:,0]
> array([1, 4, 7])
Run Code Online (Sandbox Code Playgroud)
但是,如果我使用元组,这将不起作用:
my_array[(0,:,0,)]
Run Code Online (Sandbox Code Playgroud)
我会在哪里得到一个SyntaxError.
当我必须动态构造切片以将某些内容放入数组的括号中时,我该怎么做?