File indexing completed on 2026-04-09 07:48:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 """
0022
0023
0024
0025 ::
0026
0027
0028 In [19]: M = np.random.random((10, 4, 4))
0029
0030 In [20]: M
0031 Out[20]:
0032 array([[[0.26 , 0.8375, 0.65 , 0.9379],
0033 [0.425 , 0.5007, 0.0893, 0.9828],
0034 [0.7195, 0.5231, 0.0094, 0.8324],
0035 [0.7935, 0.9463, 0.4482, 0.071 ]],
0036
0037 ...
0038
0039 [[0.4159, 0.5709, 0.0778, 0.8898],
0040 [0.7658, 0.8104, 0.5436, 0.6296],
0041 [0.7726, 0.5003, 0.7588, 0.5328],
0042 [0.3231, 0.4282, 0.5839, 0.8149]]])
0043
0044 In [21]: M.max(axis=(1,2))
0045 Out[21]: array([0.9828, 0.9816, 0.9906, 0.9307, 0.7959, 0.9424, 0.9273, 0.9979, 0.9815, 0.8898])
0046
0047 In [22]: M.max(axis=(1,2)).shape
0048 Out[22]: (10,)
0049
0050
0051
0052 In [24]: np.amax?
0053
0054 Signature: np.amax(a, axis=None, out=None, keepdims=<class 'numpy._globals._NoValue'>)
0055 Docstring:
0056 Return the maximum of an array or maximum along an axis.
0057
0058 Parameters
0059 ----------
0060 a : array_like
0061 Input data.
0062 axis : None or int or tuple of ints, optional
0063 Axis or axes along which to operate. By default, flattened input is
0064 used.
0065
0066 .. versionadded:: 1.7.0
0067
0068 If this is a tuple of ints, the maximum is selected over multiple axes,
0069 instead of a single axis or all the axes as before.
0070
0071
0072
0073
0074 * https://jakevdp.github.io/PythonDataScienceHandbook/02.04-computation-on-arrays-aggregates.html
0075
0076 The way the axis is specified here can be confusing to users coming from other
0077 languages. The axis keyword specifies the dimension of the array that will be
0078 collapsed, rather than the dimension that will be returned. So specifying
0079 axis=0 means that the first axis will be collapsed: for two-dimensional arrays,
0080 this means that values within each column will be aggregated.
0081
0082
0083
0084 """
0085 import numpy as np
0086
0087
0088 M = np.random.random((3, 4))
0089
0090
0091
0092
0093