请参见此处的代码:https://github.com/rootpy/root_numpy/blob/master/root_numpy/src/tree.pyx#L228
cdef cppclass VectorConverter[T](VectorConverterBase):
int elesize
int nptypecode
Vector2Array[T] v2a
__init__():
cdef TypeName[T] ast = TypeName[T]()
info = TYPES[ast.name]
this.elesize = info[1].itemsize
this.nptypecode = info[2]
int write(Column* col, void* buffer):
cdef vector[T]* tmp = <vector[T]*> col.GetValuePointer()
cdef unsigned long numele = tmp.size()
# check cython auto generate code
# if it really does &((*tmp)[0])
cdef T* fa = this.v2a.convert(tmp)
return create_numpyarray(buffer, fa, this.nptypecode, numele, this.elesize)
基本上-这段代码的意思是将vector <object>
(通常是float或int)转换成数组[尤其是NumPy数组]。我很难理解,但我离题了。在
我需要潜在地扩展它,以便有一些东西可以实现vector<vector <object>>
。我认为它应该是,几乎,我在上述链接中强调的代码的副本。在
我从哪里开始?在
我已经解决了这个问题,既然我不是DenverCoder9,下面是我如何做到的,如果它在将来对某人有帮助,即使是过时的
相关问题 更多 >
编程相关推荐