I'm implementing some numba code following this example. The example uses floats but my value should be a boolean.
I thought bool_to_bool should return a bool but my code is throwing me the following error
TypeError: Failed in nopython mode pipeline (step: native lowering)
Invalid store of i8* to i1 in <data.preprocess.numba.MyObj.MyObjModel object at 0x7fbb3f22e7f0> (trying to write member #0)
which looks to me that it's converting to i8*. Here's that method
from numba.extending import unbox, NativeValue
@unbox(MyObj)
def unbox_my_obj(typ, obj, c):
flip_sign_obj = c.pyapi.object_getattr_string(obj,"flip_sign")
my_obj = cgutils.create_struct_proxy(typ)(c.context,c.builder)
tmp = c.pyapi.bool_from_bool(flip_sign_obj)
my_obj.flip_sign = c.pyapi.bool_from_bool(flip_sign_obj)
c.pyapi.decref(flip_sign_obj)
is_error = cgutils.is_not_null(c.builder, c.pyapi.err_occurred())
return NativeValue(my_obj._getvalue(), is_error=is_error)
I think the only other code that'll be useful is when I declare what type flip_sign is:
from numba.extending import type_callable
@type_callable(MyObj)
def type_my_obj(context):
def typer(flip_sign):
if isinstance(flip_sign, types.b1):
return my_obj_type
return typer