Matlab和Mathematica都具有允许用户使用滑块操纵绘图内容的功能.例如,如果您有一组3D数据,则可以轻松制作一个小程序,使您可以查看一组3D数据的2D切片,用户可以滑动滑块以显示切片.python中是否有任何东西可以提供这种功能而无需付出太多努力?例如,是否可以在matplotlib或类似的东西中做这样的事情?一世
谢谢.
在Numpy(和Python一般来说,我想),如何存储切片索引,例如(...,0,:),以便传递它并将其应用于各种数组?比方说,能够将切片索引传递给函数和从函数传递是很好的.
为了加快速度,有什么我忘了做的吗?我正在尝试实现一本名为Tuning Timbre Spectrum Scale的书中描述的算法.另外---如果所有其他方法都失败了,有没有办法让我在C中编写这部分代码,然后能够从python中调用它?
import numpy as np
cimport numpy as np
# DTYPE = np.float
ctypedef np.float_t DTYPE_t
np.seterr(divide='raise', over='raise', under='ignore', invalid='raise')
"""
I define a timbre as the following 2d numpy array:
[[f0, a0], [f1, a1], [f2, a2]...] where f describes the frequency
of the given partial and a is its amplitude from 0 to 1. Phase is ignored.
"""
#Test Timbre
# cdef np.ndarray[DTYPE_t,ndim=2] t1 = np.array( [[440,1],[880,.5],[(440*3),.333]])
# Calculates the inherent dissonance of one timbres of …Run Code Online (Sandbox Code Playgroud) 我有一个名为dataList的类.它基本上是一个包含一些元数据的列表---myDataList.data包含(numpy)列表本身,myDataList.tag包含描述等.我希望能够使myDataList [42]返回myDataList的相应元素.数据,我想让Numpy等将它识别为一个列表(IE,numpy.asarray(myDataList)返回一个包含myDataList中数据的numpy数组).在Java中,这就像将dataList声明为实现List接口一样简单,然后只定义必要的函数.你会怎么用Python做到这一点?
谢谢.
我试图从函数返回一个函数列表,每个函数使用来自外部作用域的变量.这不起作用.这是一个展示正在发生的事情的例子:
a = []
for i in range(10):
a.append(lambda x: x+i)
a[1](1) # returns 10, where it seems it should return 2
Run Code Online (Sandbox Code Playgroud)
为什么会这样,我怎样才能在python 2.7中解决这个问题?
python ×5
numpy ×3
closures ×1
cython ×1
indexing ×1
inheritance ×1
interactive ×1
list ×1
matplotlib ×1
plot ×1
scope ×1
slice ×1