In [1]:
%matplotlib inline
from matplotlib import pyplot as plt
import seaborn as sns
import antipackage
from github.ellisonbg.misc import vizarray as va
import numpy as np
In [5]:
c = np.arange(0.0, 10.0, 1.0)
c
Out[5]:
In [6]:
e = np.linspace(0.0, 5.0, 11)
e
len(e)
Out[6]:
In [7]:
a = np.array([0,1,2,3])
a, a.dtype
Out[7]:
In [8]:
a = np.empty((3,3))
a.fill(0.1)
a
Out[8]:
In [9]:
b = np.ones((3,3))
b
Out[9]:
In [10]:
a+b
Out[10]:
In [11]:
a = np.random.rand(10,10)
a
Out[11]:
In [12]:
np.round(a,2)
Out[12]:
In [13]:
a[0,0]
Out[13]:
In [14]:
a[9,9]
Out[14]:
In [15]:
a[1,:]
Out[15]:
In [16]:
a[-8,]
Out[16]:
In [17]:
b = np.array([1,2,3,4])
b
Out[17]:
In [18]:
b[-1]
Out[18]:
In [19]:
b[-3]
Out[19]:
In [20]:
ages = np.array([23,56,67,89,23,56,27,12,8,72])
genders = np.array(['m','m','f','f','m','f','m','m','m','f'])
In [21]:
ages > 30
Out[21]:
In [22]:
mask = (genders == 'f')
ages[mask]
Out[22]:
In [23]:
a = np.random.rand(3,4)
a
Out[23]:
In [24]:
a.T
Out[24]:
In [25]:
a.shape
Out[25]:
In [26]:
a.size
Out[26]:
In [27]:
a.dim
In [ ]:
a.dtype
In [ ]:
a.reshape(2,6)
In [ ]:
a.reshape(6,2)
In [ ]:
a.reshape(12,1)
In [ ]:
a.ravel()
In [ ]:
a
In [28]:
va.disable()
In [2]:
va.set_block_size(5)
va.enable()
t = np.linspace(0.0, 4*np.pi, 100)
t
Out[2]:
In [31]:
np.sin(t)
Out[31]:
In [33]:
np.exp(np.sqrt(t))
Out[33]:
In [34]:
va.disable()
va.set_block_size(30)
In [3]:
plt.plot(t, np.exp(-0.1*t)*np.sin(t))
Out[3]:
In [ ]: