consider the following:
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
When I pring out the dvu statement, I get an unrounded floating point number. When I set the value to output[j] and return output, all the values are rounded. I need to return output with the full float numbers – rounding. Any thoughts on what I’m doing wrong?
I’m dumb. I was printing the thing out using the round function in a different module. There’s 3 hours of my life I’ll never get back …