Skip to content

Commit 557782c

Browse files
committed
make use of amax and amin more consistent
1 parent ddcf70f commit 557782c

4 files changed

Lines changed: 400 additions & 6 deletions

File tree

episodes/02-numpy.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,14 +420,14 @@ next diagram on the left) or the average for each day (as in the
420420
diagram on the right)? As the diagram below shows, we want to perform the
421421
operation across an axis:
422422

423-
![](fig/python-operations-across-axes.png){alt="Per-patient maximum inflammation is computed row-wise across all columns usingnumpy.amax(data, axis=1). Per-day average inflammation is computed column-wise across all rows usingnumpy.mean(data, axis=0)."}
423+
![](fig/python-operations-across-axes.svg){alt="Per-patient maximum inflammation is computed row-wise across all columns usingnumpy.amax(data, axis=1). Per-day average inflammation is computed column-wise across all rows usingnumpy.mean(data, axis=0)."}
424424

425-
To find the **maximum inflammation reported for each patient**, you would apply the `max` function moving across the columns (axis 1). To find the **daily average inflammation reported across patients**, you would apply the `mean` function moving down the rows (axis 0).
425+
To find the **maximum inflammation reported for each patient**, you would apply the `amax` function moving across the columns (axis 1). To find the **daily average inflammation reported across patients**, you would apply the `mean` function moving down the rows (axis 0).
426426

427-
To support this functionality, most array functions allow us to specify the axis we want to work on. If we ask for the max across axis 1 (columns in our 2D example), we get:
427+
To support this functionality, most array functions allow us to specify the axis we want to work on. If we ask for the maximum across axis 1 (columns in our 2D example), we get:
428428

429429
```python
430-
print(numpy.max(data, axis=1))
430+
print(numpy.amax(data, axis=1))
431431
```
432432

433433
```output
@@ -437,10 +437,10 @@ print(numpy.max(data, axis=1))
437437
17. 16. 17. 19. 18. 18.]
438438
```
439439

440-
As a quick check, we can ask this array what its shape is. We expect 60 patient maximums:
440+
As a quick check, we can ask this array what its shape is. We expect 60 patient maxima:
441441

442442
```python
443-
print(numpy.max(data, axis=1).shape)
443+
print(numpy.amax(data, axis=1).shape)
444444
```
445445

446446
```output
-15.8 KB
Binary file not shown.
-47.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)