In this exercise we practice creating arrays of random numbers. Source code for this exercise is located in numpy/random-numbers/ Generate a one dimensional 1000 element array of uniformly distributed randomnumbers …
In this exercise we study how to read and write arrays to disk. Source code for this exercise is located in numpy/input-output/ File numpy/input-output/xy-coordinates.dat contains a list of (x,y) valuepairs. …
NumPy provides functions for reading and writing numeric data to simple files in a regular column layout. These I/O functions offer a very convenient way to load and store data …
In this exercise we study NumPy broadcasting, which is powerful tool for dealing with different, but compatible shape arrays. Source code for this exercise is located in numpy/broadcast-translation/ File numpy/broadcast-translation/points_circle.dat …
In this exercise you can learn how to split and combine NumPy arrays. Source code for this exercise is located in numpy/split-combine/ Create a new 8×8 array with some values …
When working with NumPy arrays it is sometimes necessary to manipulate the shape and/or size of them. One can for example modify the shape of an array as well as …
We continue studying vectorized operations with numerical integration. Source code for this exercise is located in numpy/integration/ A simple method for evaluating integrals numerically is by the middle Riemannsum [S …
In this exercise we study vectorization, which is crucial for obtaining good performance with NumPy. Source code for this exercise is located in numpy/finite-difference/ Derivatives can be calculated numerically with …
Element-wise operations Simple calculations are very straightforward with NumPy arrays. Basic arithmetic operations (+ - * / **) can all be used with arrays. The mainthing to keep in mind …
In this exercise we explore the slicing syntax of NumPy arrays. Source code for this exercise is located in numpy/array-slicing/ First, create a 4×4 array with arbitrary values, then Extract …
For loops in Python are slow. If one needs to apply a mathematical operation on multiple (consecutive) elements of an array, it is always better to use a vectorised operation …
In this exercise we explore various ways of creating NumPy arrays Source code for this exercise is located in numpy/array-creation/ Start from a Python list containing both integers and floating …
NumPy arrays have a fixed number of elements and all the elements have the same datatype, both specified when creating the array. Even though the number of elements is fixed, …
Python lists are very flexible, but not always optimal for numerical computations. In this video we discuss the main differences between Python list and NumPy array which is the most …
We hope that you have enjoyed the first week of Python in High Performance Computing! This week, we have discussed various performance challenges in Python programs and have set up …