Title: Theory / Important / CS / Programming / Python / SciPy / NumPy / ndarray
Tags: computer_to_instruction FromInstruction hasNotNewEffectReturnsMeaning some_instruction automatedNewLineAfterCommaSpace syntactical_sugar
On every note of this deck, unless a note says otherwise:
Language: Python

Instruction: [a_1, ..., a_n]
Page: https://docs.scipy.org/doc/numpy-1.13.0/user/quickstart.html
Effect: An ndarray whose elements are a_1, ..., a_n
Variables: a_i being elements of the same type, or ndarrays of the same shape.
Name: ndarray

Instruction: n.ndim
Page: https://docs.scipy.org/doc/numpy-1.13.0/user/quickstart.html
Effect: the number of dimension
Variables: n an ndarray

Instruction: n.shape
Page: https://docs.scipy.org/doc/numpy-1.13.0/user/quickstart.html
Effect: The tuple whose ith element is the ith dimension of the ndarray
Variables: n an ndarray

Instruction: n.size
Page: https://docs.scipy.org/doc/numpy-1.13.0/user/quickstart.html
Effect: the total number of elements of the array. This is equal to the product of the elements of shape.
Variables: n an ndarray

Instruction: n.dtype
Page: https://docs.scipy.org/doc/numpy-1.13.0/user/quickstart.html
Effect: an object describing the type of the elements in the array. One can
create or specify it using standard Python types. Additionally
NumPy provides some of its own.
Variables: n an ndarray
Example: numpy.int32, numpy.int16, and numpy.float64

Instruction: n.itemsize
Page: https://docs.scipy.org/doc/numpy-1.13.0/user/quickstart.html
Effect: the size in bytes of each element of the array. For example, an array of elements of type float64, it is 8 (=64/8), while for one of type complex32 it is 4 (=32/8).
Variables: n an ndarray

Instruction: n.data
Page: https://docs.scipy.org/doc/numpy-1.13.0/user/quickstart.html
Effect: the buffer containing the actual elements of the array. Normally, we won’t need to use this attribute because we will access the elements in an array using indexing facilities.
Context: ndarray
Variables: n an ndarray

Instruction: np.array(foo)
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: An ndarray with same content as the array of array of ... foo

Instruction: np.array(
  foo,
  dtype=bar
)
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: An ndarray with same content as the array of array of ... foo, elements of type bar

Instruction: np.zeros((foo_1,...,foo_n))
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: An ndarray of dimension n whose i-th dimension's size foo_i, initialized with only zeroes

Instruction: np.ones((foo_1,...,foo_n))
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: An ndarray of dimension n whose i-th dimension's size foo_i, initialized with only 1s

Instruction: np.empty((foo_1,...,foo_n))
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: An ndarray of dimension n whose i-th dimension's size foo_i, not initialized (i.e. random values)

Instruction: np.arange
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: Similar to range, but returning ndarray

Instruction: np.linspace(foo,bar,plop)
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: A 1-dimension ndarray with plop elements regularly spaced from foo to bar

Instruction: n.set_printoptions(...)
Page: https://www.numpy.org/devdocs/user/quickstart.html
Effect: change the way n is printed
Variables: n a ndarray

Question: Result of arithmetical operations on ndarrays
Answer: Applied pointwise
Page: https://www.numpy.org/devdocs/user/quickstart.html
Variables: n a ndarray
Construction: change the way n is printed

Instruction: .dot()
Page: https://www.numpy.org/devdocs/user/quickstart.html
Context: ndarray
Returns: Matrix product
Abbreviation: @

Instruction: n.min()
Page: https://www.numpy.org/devdocs/user/quickstart.html
Context: ndarray
Returns: Minimal element of n
Variables: n a ndarray

Instruction: n.sum(axis=i)
Page: https://www.numpy.org/devdocs/user/quickstart.html
Context: ndarray
Returns: Remove dimension i and replace it by its sum along this direction
Variables: n a ndarray

Instruction: fromfunction(f,(foo_1,...,foo_n))
Page: https://www.numpy.org/devdocs/user/quickstart.html
Context: ndarray
Returns: A n-dimensional array whose entry (i_1,...,i_n) is f(i_1,...,i_n)
Variables: foo_i an int
f a n-ary function

Instruction: n[foo_1]...[foo_i]
Page: https://www.numpy.org/devdocs/user/quickstart.html
Context: ndarray
Variables: n an ndarray
Abbreviation: n[foo_1,...,foo_i]

Instruction: ,:,
Page: https://www.numpy.org/devdocs/user/quickstart.html
Context: In an argument of n[foo_1,...,foo_i]
Returns: Takes the full slice
Variables: n an ndarray

Instruction: ...
Page: https://www.numpy.org/devdocs/user/quickstart.html
Effect: replaced by as many ":" as required to be full dimensional
Context: In an argument of n[foo_1,...,foo_i]
Variables: n an ndarray

Instruction: For x in n:
Page: https://www.numpy.org/devdocs/user/quickstart.html
Effect: Loops over the first axis of n
Variables: n an ndarray

Instruction: n.flat
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: Iterator returning each values of n
Variables: n an ndarray
Extra: ravel is a ndarray, while flat is iteraton

Instruction: n.ravel()
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: The ndarray n flattened
Variables: n an ndarray

Instruction: n.reshape(foo)
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: An array with same elements as n and shape foo
Variables: n an ndarray

Instruction: n.T
Page: https://www.numpy.org/devdocs/user/quickstart.html
Context: NDArray
Returns: n transposed
Variables: n an ndarray

Instruction: n.resize(foo)
Page: https://www.numpy.org/devdocs/user/quickstart.html
Effect: Modifies array n, keeping its element but giving shape foo
Variables: n an ndarray

Instruction: n.resize((foo_1,...,foo_i-1,S/(foo_*,...*foo_i-1)))
n.reshape((foo_1,...,foo_i-1,S/(foo_*,...*foo_i-1)))
Page: https://www.numpy.org/devdocs/user/quickstart.html
Variables: n an ndarray
Abbreviation: n.resize((foo_1,...,foo_i-1,-1)) or n.reshape((foo_1,...,foo_i-1,-1))

Instruction: vstack((foo,bar))
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: A ndarray where foo and bar are stacked vertically
Variables: n an ndarray

Instruction: hstack((foo,bar))
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: A ndarray where foo and bar are stacked horizontally
Variables: n an ndarray

Instruction: column_stack((foo,bar))
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: foo as colums stacked over the array bar
Variables: n an ndarray

Instruction: row_stack((foo,bar))
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: foo as vector stacked on the left of bar
Variables: n an ndarray

Instruction: hsplit(n,bar)
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: A list of bar ndarrays of same dimension, such that stacked horizontally, they are equal to n
Variables: n an ndarray

Instruction: vsplit(n,bar)
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: A list of bar ndarrays of same dimension, such that stacked vertically, they are equal to n
Variables: n an ndarray

Instruction: hsplit(n,(foo_1,...,foo_n))
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: A list of bar ndarrays of horizontal length foo_", ..., foo_n, such that stacked horizontally, they are equal to n
Variables: n an ndarray

Instruction: vsplit(n,(foo_1,...,foo_n))
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: A list of bar ndarrays of vertical length foo_1, ..., foo_n, such that stacked vertically, they are equal to n
Variables: n an ndarray

Instruction: n.view()
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: A view of n. I.e. an object which have the same data, but may have different shape,
Variables: n an ndarray

Name: A view of n
Definition: An object which share some data with n but is not n
Page: https://www.numpy.org/devdocs/user/quickstart.html
Variables: n an ndarray
Context: ndarray

Instruction: n.copy()
Page: https://www.numpy.org/devdocs/user/quickstart.html
Context: ndarray
Returns: A deep copy of n, not sharing their values
Variables: n an ndarray

Instruction: n[m_1,...,m_k]
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: An array with same shape as i such that the element at index (j_1,...,j_l) is n[m_1(j_1,...,j_l),...,m_k(j_1,...,j_l)]
Variables: n,i ndarrays
Assuming: each m_i as the same shape

Instruction: n.argmax(axis = i)
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: An array of index of maximal element over the axis i
Variables: n ndarrays

Instruction: n.argmax(m)
Page: https://www.numpy.org/devdocs/user/quickstart.html
Returns: The ndarray of elements of n such that the element of m in the same position is True
Variables: n ndarrays
m an ndarray of boolean
Assuming: n and m have the same shape