So i am running into this weird error that when i run this code it works perfectly fine … below are my classes … i am using numba 0.58.1 and on windows 10
spec = {
"helper_class_self_num": types.float_,
"helper_class_self_var": types.float_,
}
@jitclass(spec)
class HelperClass(object):
def __init__(
self,
helper_class_self_num,
helper_class_self_var,
):
self.helper_class_self_num = helper_class_self_num
self.helper_class_self_var = helper_class_self_var
def calc_num_one(self, helper_num):
pass
@jitclass
class SubClassOne(object):
helper_class_inst: HelperClass
def __init__(
self,
helper_class_self_num,
helper_class_self_var,
):
self.helper_class_inst = HelperClass(
helper_class_self_num,
helper_class_self_var,
)
def calc_num_one(self, helper_num):
return helper_num / self.helper_class_inst.helper_class_self_num
so when i run it in a numba function, like below, I get no problems everything is fine
@njit(cache=True)
def tester_func():
calculator = SubClassOne(10, 20)
return calculator.calc_num_one(40)
tester_func()
>>> 6.0
but if i run it with param names in a numba function like below … i get this weird error
@njit(cache=True)
def tester_func():
calculator = SubClassOne(
helper_class_self_num=10,
helper_class_self_var=20,
)
return calculator.calc_num_one(40)
tester_func()
LoweringError: Failed in nopython mode pipeline (step: native lowering)
unsupported keyword arguments when calling jitclass.SubClassOne#19f60e22830<helper_class_inst:instance.jitclass.HelperClass#19f60e21ed0<helper_class_self_num:float32,helper_class_self_var:float32>>
File "C:\Users\User\AppData\Local\Temp\ipykernel_35612\2742518833.py", line 46:
def tester_func():
calculator = SubClassOne(helper_class_self_num=10, helper_class_self_var=20)
^
During: lowering "calculator = call $2load_global.0(func=$2load_global.0, args=[], kws=[('helper_class_self_num', Var($const4.1, 2742518833.py:46)), ('helper_class_self_var', Var($const6.2, 2742518833.py:46))], vararg=None, varkwarg=None, target=None)" at C:\Users\User\AppData\Local\Temp\ipykernel_35612\2742518833.py (46)
but if i run this outside of a numba function it works fine
SubClassOne(
helper_class_self_num=10,
helper_class_self_var=20,
).calc_num_one(40)
>>> 4.0
I am going to be passing a lot of params so i want to be able to label what i am doing … because without it … it could turn into a real mess real fast
so does anyone know what is going on here?
i have seen a couple people talking about nesting jitclasses and you guys helped me figure out how to do it … so thank you … you guys all saved my life … absolutely saved my life … so if you guys can help me figure this out too … then I will owe all of you more than you can think of!
@epifanio @alanlujan91 - How do I create a jitclass that takes a list of jitclass objects?
@justinblaber @Hannes - Jitclass with input of list of jitclass
@hgrecco @luk-f-a Typed list of jitted functions in jitclass