Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem: Jupyter (Sage) with Numba and pypy

How to use and import numba, pypy in sage.

I get:

ModuleNotFoundError: No module named 'numba'

when I run the following code:

from numba import jit import numpy as np import time

x = np.arange(100).reshape(10, 10)

@jit(nopython=True) def go_fast(a): # Function is compiled and runs in machine code
    trace = 0
    for i in range(a.shape[0]):
        trace += np.tanh(a[i, i])
    return a + trace

start = time.time() go_fast(x) end = time.time() print("Elapsed (with compilation) = %s" % (end - start))


start = time.time() go_fast(x) end = time.time() print("Elapsed (after compilation) = %s" % (end - start))

Problem: Jupyter (Sage) with Numba and pypy

I install it by:

pip3 install numba

How to use and import numba, pypy in sage.

I get:

ModuleNotFoundError: No module named 'numba'

'numba'

when I run the following code:

from numba import jit import numpy as np import time

x = np.arange(100).reshape(10, 10)

@jit(nopython=True) def go_fast(a): # Function is compiled and runs in machine code
    trace = 0
    for i in range(a.shape[0]):
        trace += np.tanh(a[i, i])
    return a + trace

start = time.time() go_fast(x) end = time.time() print("Elapsed (with compilation) = %s" % (end - start))


start = time.time() go_fast(x) end = time.time() print("Elapsed (after compilation) = %s" % (end - start))

Problem: Jupyter (Sage) with Numba and pypy

I install it by:

pip3 install numba

How to use and import numba, pypy in sage.

I get:

ModuleNotFoundError: No module named 'numba'

when I run the following code:code (https://numba.pydata.org/numba-doc/latest/user/5minguide.html):

from numba import jit import numpy as np import time

x = np.arange(100).reshape(10, 10)

@jit(nopython=True) def go_fast(a): # Function is compiled and runs in machine code
    trace = 0
    for i in range(a.shape[0]):
        trace += np.tanh(a[i, i])
    return a + trace

start = time.time() go_fast(x) end = time.time() print("Elapsed (with compilation) = %s" % (end - start))


start = time.time() go_fast(x) end = time.time() print("Elapsed (after compilation) = %s" % (end - start))

Problem: Jupyter (Sage) with Numba and pypy

I install it by:

pip3 install numba

How to use and import numba, pypy in sage.

I get:

ModuleNotFoundError: No module named 'numba'

when I run the following code (https://numba.pydata.org/numba-doc/latest/user/5minguide.html):(from https://numba.pydata.org/numba-doc/latest/user/5minguide.html )

from numba import jit import numpy as np import time

x = np.arange(100).reshape(10, 10)

@jit(nopython=True) def go_fast(a): # Function is compiled and runs in machine code
    trace = 0
    for i in range(a.shape[0]):
        trace += np.tanh(a[i, i])
    return a + trace

start = time.time() go_fast(x) end = time.time() print("Elapsed (with compilation) = %s" % (end - start))


start = time.time() go_fast(x) end = time.time() print("Elapsed (after compilation) = %s" % (end - start))

Problem: Jupyter (Sage) with Numba and pypy

I install it by:

pip3 install numba

How to use and import numba, pypy in sage.

I get:

ModuleNotFoundError: No module named 'numba'

when I run the following code (from https://numba.pydata.org/numba-doc/latest/user/5minguide.html )

from numba import jit import numpy as np import time

x = np.arange(100).reshape(10, 10)

@jit(nopython=True) def go_fast(a): # Function is compiled and runs in machine code
    trace = 0
    for i in range(a.shape[0]):
        trace += np.tanh(a[i, i])
    return a + trace

start = time.time() go_fast(x) end = time.time() print("Elapsed (with compilation) = %s" % (end - start))


start = time.time() go_fast(x) end = time.time() print("Elapsed (after compilation) = %s" % (end - start))

Problem: Jupyter (Sage) with Numba and pypy

I install it by:

pip3 install numba

How to use and import numba, pypy in sage.

I get:

ModuleNotFoundError: No module named 'numba'

when I run the following code (from (from https://numba.pydata.org/numba-doc/latest/user/5minguide.html )

from numba import jit import numpy as np import time

x = np.arange(100).reshape(10, 10)

@jit(nopython=True) def go_fast(a): # Function is compiled and runs in machine code
    trace = 0
    for i in range(a.shape[0]):
        trace += np.tanh(a[i, i])
    return a + trace

start = time.time() go_fast(x) end = time.time() print("Elapsed (with compilation) = %s" % (end - start))


start = time.time() go_fast(x) end = time.time() print("Elapsed (after compilation) = %s" % (end - start))

Problem: Jupyter (Sage) with Numba and pypy

I install it by:

pip3 install numba

How to use and import numba, pypy in sage.

I get:

ModuleNotFoundError: No module named 'numba'

when I run the following code (from https://numba.pydata.org/numba-doc/latest/user/5minguide.html )

from numba import jit  import numpy as np  import time

x = np.arange(100).reshape(10, 10)

@jit(nopython=True)  def go_fast(a): # Function is compiled and runs in machine code
    trace = 0
    for i in range(a.shape[0]):
        trace += np.tanh(a[i, i])
    return a + trace

start = time.time()  go_fast(x)  end = time.time()  print("Elapsed (with compilation) = %s" % (end - start))

 start = time.time() go_fast(x) time.time()
go_fast(x)
end = time.time() time.time()
print("Elapsed (after compilation) = %s" % (end - start))