Where I mainly cut and paste to build muscle memory.
see: https://docs.scipy.org/doc/numpy-dev/user/quickstart.html
From the docs: NumPy’s main object is the homogeneous multidimensional array. It is a table of elements (usually numbers), all of the same type, indexed by a tuple of positive integers. In NumPy dimensions are called axes. The number of axes is rank.
In [1]:
# Seems like everyone aliases numpy
import numpy as np
In [2]:
# Hello world for numpy
a = np.arange(15).reshape(3, 5)
In [3]:
a
Out[3]:
In [4]:
a.shape
Out[4]:
In [5]:
a.ndim
Out[5]:
In [6]:
a.dtype.name
Out[6]:
In [7]:
a.itemsize
Out[7]:
In [8]:
a.size
Out[8]:
In [9]:
type(a)
Out[9]:
In [10]:
b = np.array([6, 7, 8])
In [11]:
b
Out[11]:
In [12]:
type(b)
Out[12]:
In [13]:
coord1 = np.array((1, 1), dtype=int)
In [14]:
coord2 = np.array((1, 2), dtype=int)
In [15]:
# Element addition
coord1 + coord2
Out[15]:
In [16]:
# Element multiplication
coord1 * coord2
Out[16]:
In [17]:
# Dot product via function
coord1.dot(coord2)
Out[17]:
In [18]:
# apply operation from module
np.cross(coord1, coord2)
Out[18]:
In [ ]: