Python NumPy3 Selections Flashcards
How do you create a matrix?
Create a list of lists, then convert using the numpy array function
How do you do matrix multiplication?
With the dot function
How do you invert a matrix
With the np.linalg.inv function
How can you compute eigenvalues and eigenvectors?
Using the np.linalg.eig method
How would you select a single value from a NumPy array?
Use indexing, for example V[0] or V[5]
How can you extract a range of values?
By slicing, for example, V[2:5] and you can do stuff like this: V[:2] and V[2:]
How can you set a selection of values in an array equal to a constant?
By “broadcasting” for example,
V[4:6] = 33 remember these intervals are half open, like this: [,)
Value assignment propagates
Like this
How can you prevent propagation?
By using copy.
How to select a value from a matrix
There are two syntaxes that would work. Both use brackets.
How to select a submatrix?
Do slicing with the colon.
Vector operation. How to perform a simple test on every element of an array?
Just apply it to the object name
How can you use that boolean as a selector?
Pop it into brackets. Or even do this: V[V>24]