Skip to content

Commit

Permalink
WIP: Apply @njit to interp and mlinterp
Browse files Browse the repository at this point in the history
  • Loading branch information
oyamad committed Mar 20, 2024
1 parent 3e2f3c1 commit fab2666
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions interpolation/multilinear/mlinterp.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
# logic of multilinear interpolation


def mlinterp(grid, c, u):
def _mlinterp(grid, c, u):
pass


@overload(mlinterp)
@overload(_mlinterp)
def ol_mlinterp(grid, c, u):
if isinstance(u, UniTuple):

Expand Down Expand Up @@ -76,6 +76,11 @@ def mlininterp(grid: Tuple, c: Array, u: Array) -> float:
return mlininterp


@njit
def mlinterp(grid, c, u):
return _mlinterp(grid, c, u)


### The rest of this file constrcts function `interp`

from collections import namedtuple
Expand Down Expand Up @@ -217,11 +222,11 @@ def {funname}(*args):
return source


def interp(*args):
def _interp(*args):
pass


@overload(interp)
@overload(_interp)
def ol_interp(*args):
aa = args[0].types

Expand All @@ -235,3 +240,8 @@ def ol_interp(*args):
code = compile(tree, "<string>", "exec")
eval(code, globals())
return __mlinterp


@njit
def interp(*args):
return _interp(args)

0 comments on commit fab2666

Please sign in to comment.