Skip to content

Commit 326b869

Browse files
committed
2 parents 43dc8b0 + ddc14db commit 326b869

File tree

6 files changed

+75
-0
lines changed

6 files changed

+75
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## Simple calculation
2+
3+
Calculate the square of all numbers 1...10 using a separate `Process` to
4+
calculate the square of each number and print out the result.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## Work distribution
2+
3+
Read the atom coordinates of the Zika virus [5ire.pdb](5ire.pdb) using the
4+
simple parser provided in [pdb.py](pdb.py) (see comments in the file for
5+
examples on how to use it). In [center-of-coords.py](center-of-coords.py) is a
6+
skeleton code you may also use as a starting point.
7+
8+
Calculate the center of coordinates in parallel by dividing the coordinates
9+
in smaller chunks (e.g. 100 coordinates) to separate tasks. After completing
10+
the tasks in worker processes, combine the results in the master process.
11+
12+
If needed, figure out also how to deal with any coordinates left out of the
13+
neat uniform-sized chunks.
14+
15+
a) Use a **Pool of Workers** to distribute the tasks to worker processes.
16+
*Hint: if you return also the weight of each chunk, you can process also
17+
non-uniform sized chunks.*
18+
19+
OR
20+
21+
b) Use a **Queue** to distribute the tasks to worker processes. Store the
22+
results for each chunk in a separate queue.

numpy/array-creation/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Array creation
2+
3+
Start from a Python list containing both integers and floating point values,
4+
and construct then a NumPy array from the list.
5+
6+
Generate a 1D NumPy array containing all numbers from -2.0 to 2.0 with a
7+
spacing of 0.2. Use optional start and step arguments of the `np.arange()`
8+
function.
9+
10+
Generate another 1D NumPy array containing 11 equally spaced values between
11+
0.5 and 1.5. Extract every second element of the array.

numpy/array-slicing/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Array slicing
2+
3+
First, create a 4x4 array with arbitrary values, then
4+
5+
1. Extract every element from the second row.
6+
2. Extract every element from the third column.
7+
3. Assign a value of 0.21 to upper left 2x2 subarray.
8+
9+
Next, create a 8x8 array with checkerboard pattern, i.e. alternating zeros
10+
and ones:
11+
12+
```
13+
1 0 1 ...
14+
0 1 0 ...
15+
1 0 1 ...
16+
...
17+
```

numpy/split-combine/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Split and combine arrays
2+
3+
Continue with the previous 4x4 array
4+
5+
1. Use `np.split()` function for splitting the array into two new 2x4 arrays.
6+
Reconstruct the original 4x4 array by using `np.concatenate()`.
7+
2. Repeat the above exercise but create now 4x2 subarrays and then combine
8+
them.

numpy/subdiagonal-matrix/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Subdiagonal matrix
2+
3+
Create a 6x6 matrix with 1’s above and below the diagonal and zeros
4+
otherwise:
5+
```
6+
0 1 0 0 0 0
7+
1 0 1 0 0 0
8+
0 1 0 1 0 0
9+
0 0 1 0 1 0
10+
0 0 0 1 0 1
11+
0 0 0 0 1 0
12+
```
13+
Use the `numpy.eye()` function.

0 commit comments

Comments
 (0)