# Are jitclass methods jitted functions? : - argument 0: cannot determine Numba type of \<class 'method'\>

**URL:** <https://numba.discourse.group/t/are-jitclass-methods-jitted-functions-argument-0-cannot-determine-numba-type-of-class-method/398>\
**Category:** Support: How do I do ...?\
**Created:** [December 15, 2020, 2:19am UTC](https://numba.discourse.group/t/are-jitclass-methods-jitted-functions-argument-0-cannot-determine-numba-type-of-class-method/398 "2020-12-15T02:19:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alanlujan91](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/alanlujan91/32/83_2.png) [@alanlujan91](https://numba.discourse.group/u/alanlujan91)\
**Post date:** [December 15, 2020, 2:19am UTC](https://numba.discourse.group/t/are-jitclass-methods-jitted-functions-argument-0-cannot-determine-numba-type-of-class-method/398/1 "2020-12-15T02:19:43Z")

</div>

I ran into a problem where I wanted to use a rootfinding jitted function that itself takes jitted functions, in particular this [https://quanteconpy.readthedocs.io/en/latest/optimize/root\_finding.html](https://quanteconpy.readthedocs.io/en/latest/optimize/root_finding.html)

However, my “jitted” function for which I have to find a root is a method of a jitclass. I thought methods of jitclasses were jitted, but when I tried, I got the following error:

```
This error may have been caused by the following argument(s):
- argument 0: cannot determine Numba type of <class 'method'>

```

Here’s an example to reproduce the error. The jitclass Foo has method `bar`, which I understand to be jitted, after all that’s the point of a jitclass, no?

```
from numba import njit, float64
from numba.experimental import jitclass

specs = {"param": float64}

@jitclass(specs)
class Foo:

    def __init__ (self, param):
        self.param = param

    def bar(self, x):
        return (x - 2) * (x + 1) ** 2 + self.param

@njit
def func(bar, x):
    return bar(x)

@njit
def testfunc(x):
    return x**2

foo_inst = Foo(10.0)

print(func(testfunc, 2)) # prints 4

print(func(foo_inst.bar, 2)) # results in error

```

Is there something I should be doing differently?

Below is the full error:

```
 4
Traceback (most recent call last):
  File "C:\Users\\anaconda3\envs\mini-hark\lib\site-packages\IPython\core\interactiveshell.py", line 3418, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-331fa44ed081>", line 1, in <module>
    runfile('C:/Users///teststuff.py', wdir='C:/Users//')
  File "C:\Users\\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\203.5981.165\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
  File "C:\Users\\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\203.5981.165\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Users///teststuff.py", line 29, in <module>
    print(func(foo_inst.bar, 2))
  File "C:\Users\\anaconda3\envs\mini-hark\lib\site-packages\numba\core\dispatcher.py", line 415, in _compile_for_args
    error_rewrite(e, 'typing')
  File "C:\Users\\anaconda3\envs\mini-hark\lib\site-packages\numba\core\dispatcher.py", line 358, in error_rewrite
    reraise(type(e), e, None)
  File "C:\Users\\anaconda3\envs\mini-hark\lib\site-packages\numba\core\utils.py", line 80, in reraise
    raise value.with_traceback(tb)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
non-precise type pyobject
During: typing of argument at C:/Users///teststuff.py (19)
File "teststuff.py", line 19:
def func(bar, x):
    return bar(x)
    ^
This error may have been caused by the following argument(s):
- argument 0: cannot determine Numba type of <class 'method'>
```

---

<div class="post-metadata">

**Author:** ![stuartarchibald](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/stuartarchibald/32/10_2.png) [@stuartarchibald](https://numba.discourse.group/u/stuartarchibald)\
**Post date:** [December 17, 2020, 5:42pm UTC](https://numba.discourse.group/t/are-jitclass-methods-jitted-functions-argument-0-cannot-determine-numba-type-of-class-method/398/2 "2020-12-17T17:42:38Z")

</div>

Hi @alanlujan91

The methods on a `jitclass`, when used from the interpreter, are true methods, i.e. I’d expect this to succeed:

```python
import types; assert isinstance(foo_inst.bar, types.MethodType)

```

I can’t immediately think of a way around this (use of the actual `jit` methods will result in problems with binding to `self`), but perhaps someone else might know. CC @sklam thoughts?

---

<div class="post-metadata">

**Author:** ![sklam](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/sklam/32/9_2.png) [@sklam](https://numba.discourse.group/u/sklam)\
**Post date:** [December 18, 2020, 9:40pm UTC](https://numba.discourse.group/t/are-jitclass-methods-jitted-functions-argument-0-cannot-determine-numba-type-of-class-method/398/3 "2020-12-18T21:40:55Z")

</div>

@stuartarchibald is right. The methods are true python methods. And, Numba does not handle passing the bound method as argument currently.
