考虑以下事项:
import numpy as np
cimport numpy as np
DTYPE = np.float
ctypedef np.float_t DTYPE_t
def do(np.ndarray[DTYPE_t, ndim=2] hlc, int days=2):
cdef float dvu = 0.0
cdef Py_ssize_t N = np.shape(hlc)[1]-1, i, j, k
cdef np.ndarray[DTYPE_t] h = hlc[0]
cdef np.ndarray[DTYPE_t] l = hlc[1]
cdef np.ndarray[DTYPE_t] output = np.empty(N+1, dtype=np.float)
for i from 0 <= i <= days-1:
output[i] = np.NaN
for j from N >= j >= days-1:
for k from j >= k >= j-days+1:
dvu += ((h[k] + l[k]) / 2.0) - 1.0
print dvu # prints a float
output[j] = dvu / days
dvu = 0.0
return output
当我发出dvu语句时,我得到一个未接地的浮点数。当我将值设置为output [j]并返回输出时,所有值都被舍入。我需要返回带有完整浮点数的输出 - 舍入。对我做错了什么的想法?
答案 0 :(得分:0)
我很蠢。我在不同的模块中使用圆形功能打印出来的东西。我生命中有3个小时我永远不会回来......