CoCalc Shared Filesanaconda.html
Views : 19
Description: Jupyter html version of anaconda.ipynb
anaconda
In [1]:
!hostname

compute1-us


$\int_0^\infty x\; \mathrm{d}x$

In [2]:
import numpy as np; np; np.__version__

Out[2]:
'1.10.2'
In [3]:
import pandas as pd

In [4]:
import numba
print(numba)
numba.__version__

<module 'numba' from '/projects/anaconda3/lib/python3.5/site-packages/numba/__init__.py'>

Out[4]:
'0.23.1'
In [5]:
def faster(x, y):
a = 0.0
for i in range(x):
for j in range(i, x):
b = a
a += y * .2
a -= y * .1
a = (a + b) / 2.
return a

In [6]:
%timeit faster(2222, 1.111)

1 loop, best of 3: 375 ms per loop

In [7]:
import numba
faster2 = numba.autojit(faster)

In [8]:
%timeit faster2(2222, 1.111)

The slowest run took 7.94 times longer than the fastest. This could mean that an intermediate result is being cached.
100 loops, best of 3: 10.4 ms per loop

In [ ]:


In [ ]:


In [ ]:
def f2(x, y):
k = 0
for i in range(x):
for j in range(y):
k += i / x + j / y
return k

In [ ]:
%timeit f2(200, 300)

In [ ]:
@numba.jit(nopython=True, nogil=True)
def f(x, y):
k = 0
for i in range(x):
for j in range(y):
k += i / x + j / y
return k

In [ ]:
%timeit f(200, 300)

In [ ]:
%matplotlib inline
import matplotlib.pyplot as plt

In [ ]:
plt.plot([f(x, 2.2) for x in range(1000)])

In [ ]:
np.test()

In [ ]:
np.__version__

In [ ]: