{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numba" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import interpolation" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "grid = (\n", " (0.0, 1.0, 10),\n", " (0.0, 1.0, 10)\n", ")" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "import numpy as np" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "C = np.random.random((10,10))" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "N = 1000000" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "S = np.random.random((N,2))" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "from interpolation import mlinterp" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0.39887696, 0.46464487, 0.2931475 , ..., 0.05132932, 0.59298413,\n", " 0.68548968])" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mlinterp(grid, C, S)" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "d = mlinterp.inspect_llvm()\n", "d[[*d.keys()]]" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/opt/pablo/anaconda3/lib/python3.6/site-packages/numba/pretty_annotate.py:26: FutureWarning: The pretty_annotate functionality is experimental and might change API\n", " FutureWarning)\n" ] }, { "data": { "text/html": [ "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "
\n", " Function name: mlininterp
\n", " \n", " in file: /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py
\n", " \n", " with signature: (tuple((float64, float64, int64) x 2), array(float64, 2d, C), array(float64, 2d, C)) -> array(float64, 1d, C)\n", "
\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "
\n", " \n", " \n", " 46:\n", " def mlininterp(grid: Tuple, c: Array, u: Array)->float:\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "  \n", " label 0\n", " \n", "
\n", "
\n", "
\n", "
\n", " \n", " \n", " 47:\n", "      N = u.shape[0]\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "      \n", "   grid = arg(0, name=grid) :: tuple((float64, float64, int64) x 2)\n", " \n", "
\n", "      \n", "   c = arg(1, name=c) :: array(float64, 2d, C)\n", " \n", "
\n", "      \n", "   u = arg(2, name=u) :: array(float64, 2d, C)\n", " \n", "
\n", "      \n", "   $0.2 = getattr(value=u, attr=shape) :: tuple(int64 x 2)\n", " \n", "
\n", "      \n", "   $const0.3 = const(int, 0) :: int64\n", " \n", "
\n", "      \n", "   $0.4 = static_getitem(value=$0.2, index=0, index_var=$const0.3) :: int64\n", " \n", "
\n", "      \n", "   del $const0.3\n", " \n", "
\n", "      \n", "   del $0.2\n", " \n", "
\n", "      \n", "   N = $0.4 :: int64\n", " \n", "
\n", "      \n", "   del $0.4\n", " \n", "
\n", "
\n", "
\n", "
\n", " \n", " \n", " 48:\n", "      res = np.zeros(N)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "      \n", "   $0.5 = global(np: <module 'numpy' from '/opt/pablo/anaconda3/lib/python3.6/site-packages/numpy/__init__.py'>) :: Module(<module 'numpy' from '/opt/pablo/anaconda3/lib/python3.6/site-packages/numpy/__init__.py'>)\n", " \n", "
\n", "      \n", "   $0.6 = getattr(value=$0.5, attr=zeros) :: Function(<built-in function zeros>)\n", " \n", "
\n", "      \n", "   del $0.5\n", " \n", "
\n", "      \n", "   $0.8 = call $0.6(N, func=$0.6, args=[Var(N, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47))], kws=(), vararg=None) :: (int64,) -> array(float64, 1d, C)\n", " \n", "
\n", "      \n", "   del $0.6\n", " \n", "
\n", "      \n", "   res = $0.8 :: array(float64, 1d, C)\n", " \n", "
\n", "      \n", "   del $0.8\n", " \n", "
\n", "      \n", "   jump 20\n", " \n", "
\n", "      \n", " label 20\n", " \n", "
\n", "
\n", "
\n", "
\n", " \n", " \n", " 49:\n", "      for n in range(N):\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "      \n", "   jump 22\n", " \n", "
\n", "      \n", " label 22\n", " \n", "
\n", "      \n", "   $22.1 = global(range: <class 'range'>) :: Function(<class 'range'>)\n", " \n", "
\n", "      \n", "   $22.3 = call $22.1(N, func=$22.1, args=[Var(N, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47))], kws=(), vararg=None) :: (int64,) -> range_state_int64\n", " \n", "
\n", "      \n", "   del N\n", " \n", "
\n", "      \n", "   del $22.1\n", " \n", "
\n", "      \n", "   $22.4 = getiter(value=$22.3) :: range_iter_int64\n", " \n", "
\n", "      \n", "   del $22.3\n", " \n", "
\n", "      \n", "   $phi30.1 = $22.4 :: range_iter_int64\n", " \n", "
\n", "      \n", "   del $22.4\n", " \n", "
\n", "      \n", "   jump 30\n", " \n", "
\n", "      \n", " label 30\n", " \n", "
\n", "      \n", "   $30.2 = iternext(value=$phi30.1) :: pair<int64, bool>\n", " \n", "
\n", "      \n", "   $30.3 = pair_first(value=$30.2) :: int64\n", " \n", "
\n", "      \n", "   $30.4 = pair_second(value=$30.2) :: bool\n", " \n", "
\n", "      \n", "   del $30.2\n", " \n", "
\n", "      \n", "   $phi32.1 = $30.3 :: int64\n", " \n", "
\n", "      \n", "   $phi96.1 = $30.3 :: int64\n", " \n", "
\n", "      \n", "   del $phi96.1\n", " \n", "
\n", "      \n", "   del $30.3\n", " \n", "
\n", "      \n", "   $phi96.2 = $phi30.1 :: range_iter_int64\n", " \n", "
\n", "      \n", "   del $phi96.2\n", " \n", "
\n", "      \n", "   branch $30.4, 32, 96\n", " \n", "
\n", "      \n", " label 32\n", " \n", "
\n", "      \n", "   del $30.4\n", " \n", "
\n", "      \n", "   n = $phi32.1 :: int64\n", " \n", "
\n", "      \n", "   del $phi32.1\n", " \n", "
\n", "
\n", "
\n", "
\n", " \n", " \n", " 50:\n", "          uu = extract_row(u, n, grid)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "          \n", "   $32.2 = global(extract_row: CPUDispatcher(<function extract_row at 0x7ff2779c18c8>)) :: type(CPUDispatcher(<function extract_row at 0x7ff2779c18c8>))\n", " \n", "
\n", "          \n", "   $32.6 = call $32.2(u, n, grid, func=$32.2, args=[Var(u, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47)), Var(n, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (49)), Var(grid, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47))], kws=(), vararg=None) :: (array(float64, 2d, C), int64, tuple((float64, float64, int64) x 2)) -> tuple(float64 x 2)\n", " \n", "
\n", "          \n", "   del $32.2\n", " \n", "
\n", "          \n", "   uu = $32.6 :: tuple(float64 x 2)\n", " \n", "
\n", "          \n", "   del $32.6\n", " \n", "
\n", "
\n", "
\n", " \n", " 51:\n", "          # get indices and barycentric coordinates\n", " \n", "
\n", "
\n", " \n", " \n", " 52:\n", "          tmp = fmap(get_index, grid, uu)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "          \n", "   $32.7 = global(fmap: <function fmap at 0x7ff277be11e0>) :: Function(<function fmap at 0x7ff277be11e0>)\n", " \n", "
\n", "          \n", "   $32.8 = global(get_index: CPUDispatcher(<function get_index at 0x7ff277be17b8>)) :: type(CPUDispatcher(<function get_index at 0x7ff277be17b8>))\n", " \n", "
\n", "          \n", "   $32.11 = call $32.7($32.8, grid, uu, func=$32.7, args=[Var($32.8, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (52)), Var(grid, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47)), Var(uu, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (50))], kws=(), vararg=None) :: (type(CPUDispatcher(<function get_index at 0x7ff277be17b8>)), tuple((float64, float64, int64) x 2), tuple(float64 x 2)) -> tuple((int64, float64) x 2)\n", " \n", "
\n", "          \n", "   del uu\n", " \n", "
\n", "          \n", "   del $32.8\n", " \n", "
\n", "          \n", "   del $32.7\n", " \n", "
\n", "          \n", "   tmp = $32.11 :: tuple((int64, float64) x 2)\n", " \n", "
\n", "          \n", "   del $32.11\n", " \n", "
\n", "
\n", "
\n", "
\n", " \n", " \n", " 53:\n", "          indices, barycenters = funzip(tmp)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "          \n", "   $32.12 = global(funzip: CPUDispatcher(<function funzip at 0x7ff2779c1268>)) :: type(CPUDispatcher(<function funzip at 0x7ff2779c1268>))\n", " \n", "
\n", "          \n", "   $32.14 = call $32.12(tmp, func=$32.12, args=[Var(tmp, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (52))], kws=(), vararg=None) :: (tuple((int64, float64) x 2),) -> (tuple(int64 x 2), tuple(float64 x 2))\n", " \n", "
\n", "          \n", "   del tmp\n", " \n", "
\n", "          \n", "   del $32.12\n", " \n", "
\n", "          \n", "   $32.17 = exhaust_iter(value=$32.14, count=2) :: (tuple(int64 x 2), tuple(float64 x 2))\n", " \n", "
\n", "          \n", "   del $32.14\n", " \n", "
\n", "          \n", "   $32.15 = static_getitem(value=$32.17, index=0, index_var=None) :: tuple(int64 x 2)\n", " \n", "
\n", "          \n", "   $32.16 = static_getitem(value=$32.17, index=1, index_var=None) :: tuple(float64 x 2)\n", " \n", "
\n", "          \n", "   del $32.17\n", " \n", "
\n", "          \n", "   indices = $32.15 :: tuple(int64 x 2)\n", " \n", "
\n", "          \n", "   del $32.15\n", " \n", "
\n", "          \n", "   barycenters = $32.16 :: tuple(float64 x 2)\n", " \n", "
\n", "          \n", "   del $32.16\n", " \n", "
\n", "
\n", "
\n", "
\n", " \n", " \n", " 54:\n", "          coeffs = get_coeffs(c, indices)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "          \n", "   $32.18 = global(get_coeffs: CPUDispatcher(<function get_coeffs at 0x7ff2779c12f0>)) :: type(CPUDispatcher(<function get_coeffs at 0x7ff2779c12f0>))\n", " \n", "
\n", "          \n", "   $32.21 = call $32.18(c, indices, func=$32.18, args=[Var(c, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47)), Var(indices, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (53))], kws=(), vararg=None) :: (array(float64, 2d, C), tuple(int64 x 2)) -> tuple(tuple(float64 x 2) x 2)\n", " \n", "
\n", "          \n", "   del indices\n", " \n", "
\n", "          \n", "   del $32.18\n", " \n", "
\n", "          \n", "   coeffs = $32.21 :: tuple(tuple(float64 x 2) x 2)\n", " \n", "
\n", "          \n", "   del $32.21\n", " \n", "
\n", "
\n", "
\n", "
\n", " \n", " \n", " 55:\n", "          res[n] = tensor_reduction(coeffs, barycenters)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "          \n", "   $32.22 = global(tensor_reduction: CPUDispatcher(<function tensor_reduction at 0x7ff2779c1840>)) :: type(CPUDispatcher(<function tensor_reduction at 0x7ff2779c1840>))\n", " \n", "
\n", "          \n", "   $32.25 = call $32.22(coeffs, barycenters, func=$32.22, args=[Var(coeffs, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (54)), Var(barycenters, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (53))], kws=(), vararg=None) :: (tuple(tuple(float64 x 2) x 2), tuple(float64 x 2)) -> float64\n", " \n", "
\n", "          \n", "   del coeffs\n", " \n", "
\n", "          \n", "   del barycenters\n", " \n", "
\n", "          \n", "   del $32.22\n", " \n", "
\n", "          \n", "   res[n] = $32.25 :: (array(float64, 1d, C), int64, float64) -> none\n", " \n", "
\n", "          \n", "   del n\n", " \n", "
\n", "          \n", "   del $32.25\n", " \n", "
\n", "          \n", "   jump 30\n", " \n", "
\n", "          \n", " label 96\n", " \n", "
\n", "          \n", "   del u\n", " \n", "
\n", "          \n", "   del grid\n", " \n", "
\n", "          \n", "   del c\n", " \n", "
\n", "          \n", "   del $phi32.1\n", " \n", "
\n", "          \n", "   del $phi30.1\n", " \n", "
\n", "          \n", "   del $30.4\n", " \n", "
\n", "          \n", "   jump 98\n", " \n", "
\n", "          \n", " label 98\n", " \n", "
\n", "
\n", "
\n", "
\n", " \n", " \n", " 56:\n", "      return res\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "      \n", "   $98.2 = cast(value=res) :: array(float64, 1d, C)\n", " \n", "
\n", "      \n", "   del res\n", " \n", "
\n", "      \n", "   return $98.2\n", " \n", "
\n", "
\n", "
\n", "
\n", " \n", "\n", "" ], "text/plain": [ "Function name: \u001b[34mmlininterp\u001b[39;49;00m\n", "In file: \u001b[34m/home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py\u001b[39;49;00m\n", "With signature: \u001b[34m(tuple((float64, float64, int64) x 2), array(float64, 2d, C), array(float64, 2d, C)) -> array(float64, 1d, C)\u001b[39;49;00m\n", "\n", "46: \u001b[34mdef\u001b[39;49;00m \u001b[32mmlininterp\u001b[39;49;00m(grid: Tuple, c: Array, u: Array)->\u001b[36mfloat\u001b[39;49;00m:\n", "-- label 0\u001b[41m\u001b[39;49;00m\n", "47: N = u.shape[\u001b[34m0\u001b[39;49;00m]\n", "-- grid = arg(0, name=grid) :: tuple((float64, float64, int64) x 2)\u001b[41m\u001b[39;49;00m\n", "-- c = arg(1, name=c) :: array(float64, 2d, C)\u001b[41m\u001b[39;49;00m\n", "-- u = arg(2, name=u) :: array(float64, 2d, C)\u001b[41m\u001b[39;49;00m\n", "-- $0.2 = getattr(value=u, attr=shape) :: tuple(int64 x 2)\u001b[41m\u001b[39;49;00m\n", "-- $const0.3 = const(int, 0) :: int64\u001b[41m\u001b[39;49;00m\n", "-- $0.4 = static_getitem(value=$0.2, index=0, index_var=$const0.3) :: int64\u001b[41m\u001b[39;49;00m\n", "-- del $const0.3\u001b[41m\u001b[39;49;00m\n", "-- del $0.2\u001b[41m\u001b[39;49;00m\n", "-- N = $0.4 :: int64\u001b[41m\u001b[39;49;00m\n", "-- del $0.4\u001b[41m\u001b[39;49;00m\n", "48: res = np.zeros(N)\n", "-- $0.5 = global(np: ) :: Module()\u001b[41m\u001b[39;49;00m\n", "-- $0.6 = getattr(value=$0.5, attr=zeros) :: Function()\u001b[41m\u001b[39;49;00m\n", "-- del $0.5\u001b[41m\u001b[39;49;00m\n", "-- $0.8 = call $0.6(N, func=$0.6, args=[Var(N, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47))], kws=(), vararg=None) :: (int64,) -> array(float64, 1d, C)\u001b[41m\u001b[39;49;00m\n", "-- del $0.6\u001b[41m\u001b[39;49;00m\n", "-- res = $0.8 :: array(float64, 1d, C)\u001b[41m\u001b[39;49;00m\n", "-- del $0.8\u001b[41m\u001b[39;49;00m\n", "-- jump 20\u001b[41m\u001b[39;49;00m\n", "-- label 20\u001b[41m\u001b[39;49;00m\n", "49: \u001b[34mfor\u001b[39;49;00m n \u001b[35min\u001b[39;49;00m \u001b[36mrange\u001b[39;49;00m(N):\n", "-- jump 22\u001b[41m\u001b[39;49;00m\n", "-- label 22\u001b[41m\u001b[39;49;00m\n", "-- $22.1 = global(range: ) :: Function()\u001b[41m\u001b[39;49;00m\n", "-- $22.3 = call $22.1(N, func=$22.1, args=[Var(N, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47))], kws=(), vararg=None) :: (int64,) -> range_state_int64\u001b[41m\u001b[39;49;00m\n", "-- del N\u001b[41m\u001b[39;49;00m\n", "-- del $22.1\u001b[41m\u001b[39;49;00m\n", "-- $22.4 = getiter(value=$22.3) :: range_iter_int64\u001b[41m\u001b[39;49;00m\n", "-- del $22.3\u001b[41m\u001b[39;49;00m\n", "-- $phi30.1 = $22.4 :: range_iter_int64\u001b[41m\u001b[39;49;00m\n", "-- del $22.4\u001b[41m\u001b[39;49;00m\n", "-- jump 30\u001b[41m\u001b[39;49;00m\n", "-- label 30\u001b[41m\u001b[39;49;00m\n", "-- $30.2 = iternext(value=$phi30.1) :: pair\u001b[41m\u001b[39;49;00m\n", "-- $30.3 = pair_first(value=$30.2) :: int64\u001b[41m\u001b[39;49;00m\n", "-- $30.4 = pair_second(value=$30.2) :: bool\u001b[41m\u001b[39;49;00m\n", "-- del $30.2\u001b[41m\u001b[39;49;00m\n", "-- $phi32.1 = $30.3 :: int64\u001b[41m\u001b[39;49;00m\n", "-- $phi96.1 = $30.3 :: int64\u001b[41m\u001b[39;49;00m\n", "-- del $phi96.1\u001b[41m\u001b[39;49;00m\n", "-- del $30.3\u001b[41m\u001b[39;49;00m\n", "-- $phi96.2 = $phi30.1 :: range_iter_int64\u001b[41m\u001b[39;49;00m\n", "-- del $phi96.2\u001b[41m\u001b[39;49;00m\n", "-- branch $30.4, 32, 96\u001b[41m\u001b[39;49;00m\n", "-- label 32\u001b[41m\u001b[39;49;00m\n", "-- del $30.4\u001b[41m\u001b[39;49;00m\n", "-- n = $phi32.1 :: int64\u001b[41m\u001b[39;49;00m\n", "-- del $phi32.1\u001b[41m\u001b[39;49;00m\n", "50: uu = extract_row(u, n, grid)\n", "-- $32.2 = global(extract_row: CPUDispatcher()) :: type(CPUDispatcher())\u001b[41m\u001b[39;49;00m\n", "-- $32.6 = call $32.2(u, n, grid, func=$32.2, args=[Var(u, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47)), Var(n, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (49)), Var(grid, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47))], kws=(), vararg=None) :: (array(float64, 2d, C), int64, tuple((float64, float64, int64) x 2)) -> tuple(float64 x 2)\u001b[41m\u001b[39;49;00m\n", "-- del $32.2\u001b[41m\u001b[39;49;00m\n", "-- uu = $32.6 :: tuple(float64 x 2)\u001b[41m\u001b[39;49;00m\n", "-- del $32.6\u001b[41m\u001b[39;49;00m\n", "51: \u001b[37m# get indices and barycentric coordinates\u001b[39;49;00m\n", "52: tmp = fmap(get_index, grid, uu)\n", "-- $32.7 = global(fmap: ) :: Function()\u001b[41m\u001b[39;49;00m\n", "-- $32.8 = global(get_index: CPUDispatcher()) :: type(CPUDispatcher())\u001b[41m\u001b[39;49;00m\n", "-- $32.11 = call $32.7($32.8, grid, uu, func=$32.7, args=[Var($32.8, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (52)), Var(grid, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47)), Var(uu, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (50))], kws=(), vararg=None) :: (type(CPUDispatcher()), tuple((float64, float64, int64) x 2), tuple(float64 x 2)) -> tuple((int64, float64) x 2)\u001b[41m\u001b[39;49;00m\n", "-- del uu\u001b[41m\u001b[39;49;00m\n", "-- del $32.8\u001b[41m\u001b[39;49;00m\n", "-- del $32.7\u001b[41m\u001b[39;49;00m\n", "-- tmp = $32.11 :: tuple((int64, float64) x 2)\u001b[41m\u001b[39;49;00m\n", "-- del $32.11\u001b[41m\u001b[39;49;00m\n", "53: indices, barycenters = funzip(tmp)\n", "-- $32.12 = global(funzip: CPUDispatcher()) :: type(CPUDispatcher())\u001b[41m\u001b[39;49;00m\n", "-- $32.14 = call $32.12(tmp, func=$32.12, args=[Var(tmp, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (52))], kws=(), vararg=None) :: (tuple((int64, float64) x 2),) -> (tuple(int64 x 2), tuple(float64 x 2))\u001b[41m\u001b[39;49;00m\n", "-- del tmp\u001b[41m\u001b[39;49;00m\n", "-- del $32.12\u001b[41m\u001b[39;49;00m\n", "-- $32.17 = exhaust_iter(value=$32.14, count=2) :: (tuple(int64 x 2), tuple(float64 x 2))\u001b[41m\u001b[39;49;00m\n", "-- del $32.14\u001b[41m\u001b[39;49;00m\n", "-- $32.15 = static_getitem(value=$32.17, index=0, index_var=None) :: tuple(int64 x 2)\u001b[41m\u001b[39;49;00m\n", "-- $32.16 = static_getitem(value=$32.17, index=1, index_var=None) :: tuple(float64 x 2)\u001b[41m\u001b[39;49;00m\n", "-- del $32.17\u001b[41m\u001b[39;49;00m\n", "-- indices = $32.15 :: tuple(int64 x 2)\u001b[41m\u001b[39;49;00m\n", "-- del $32.15\u001b[41m\u001b[39;49;00m\n", "-- barycenters = $32.16 :: tuple(float64 x 2)\u001b[41m\u001b[39;49;00m\n", "-- del $32.16\u001b[41m\u001b[39;49;00m\n", "54: coeffs = get_coeffs(c, indices)\n", "-- $32.18 = global(get_coeffs: CPUDispatcher()) :: type(CPUDispatcher())\u001b[41m\u001b[39;49;00m\n", "-- $32.21 = call $32.18(c, indices, func=$32.18, args=[Var(c, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47)), Var(indices, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (53))], kws=(), vararg=None) :: (array(float64, 2d, C), tuple(int64 x 2)) -> tuple(tuple(float64 x 2) x 2)\u001b[41m\u001b[39;49;00m\n", "-- del indices\u001b[41m\u001b[39;49;00m\n", "-- del $32.18\u001b[41m\u001b[39;49;00m\n", "-- coeffs = $32.21 :: tuple(tuple(float64 x 2) x 2)\u001b[41m\u001b[39;49;00m\n", "-- del $32.21\u001b[41m\u001b[39;49;00m\n", "55: res[n] = tensor_reduction(coeffs, barycenters)\n", "-- $32.22 = global(tensor_reduction: CPUDispatcher()) :: type(CPUDispatcher())\u001b[41m\u001b[39;49;00m\n", "-- $32.25 = call $32.22(coeffs, barycenters, func=$32.22, args=[Var(coeffs, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (54)), Var(barycenters, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (53))], kws=(), vararg=None) :: (tuple(tuple(float64 x 2) x 2), tuple(float64 x 2)) -> float64\u001b[41m\u001b[39;49;00m\n", "-- del coeffs\u001b[41m\u001b[39;49;00m\n", "-- del barycenters\u001b[41m\u001b[39;49;00m\n", "-- del $32.22\u001b[41m\u001b[39;49;00m\n", "-- res[n] = $32.25 :: (array(float64, 1d, C), int64, float64) -> none\u001b[41m\u001b[39;49;00m\n", "-- del n\u001b[41m\u001b[39;49;00m\n", "-- del $32.25\u001b[41m\u001b[39;49;00m\n", "-- jump 30\u001b[41m\u001b[39;49;00m\n", "-- label 96\u001b[41m\u001b[39;49;00m\n", "-- del u\u001b[41m\u001b[39;49;00m\n", "-- del grid\u001b[41m\u001b[39;49;00m\n", "-- del c\u001b[41m\u001b[39;49;00m\n", "-- del $phi32.1\u001b[41m\u001b[39;49;00m\n", "-- del $phi30.1\u001b[41m\u001b[39;49;00m\n", "-- del $30.4\u001b[41m\u001b[39;49;00m\n", "-- jump 98\u001b[41m\u001b[39;49;00m\n", "-- label 98\u001b[41m\u001b[39;49;00m\n", "56: \u001b[34mreturn\u001b[39;49;00m res\n", "-- $98.2 = cast(value=res) :: array(float64, 1d, C)\u001b[41m\u001b[39;49;00m\n", "-- del res\u001b[41m\u001b[39;49;00m\n", "-- return $98.2\u001b[41m\u001b[39;49;00m" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mlinterp.inspect_types(pretty=True)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.8" } }, "nbformat": 4, "nbformat_minor": 2 }