I'm sure I'm doing something daft here, but perhaps someone could enlighten me as to why this doesn't work:
import numpy as np
from numba import jit
from numba import types
from numba.extending import lower_cast
@lower_cast(types.NPDatetime('ns'), types.int64)
def dt_val(context, builder, fromty, toty, value):
return value
@jit(nopython=True, locals={'x': types.int64})
def test(x):
return x // 1000000000
res = test(np.datetime64(60*1000000000,'ns'))
fails with,
numba.errors.TypingError: Failed at nopython (nopython frontend)
No conversion from datetime64(ns) to int64 for 'x', defined at None
or perhaps any alternative approach for taking the floor of a datetime64, that doesn't involve taking a view of the item outside of numba would be appreciated.
thanks