In [1]:
import numpy as np
In [2]:
a = np.array([0, 1, 2])
b = np.array([3, 0, 6])
c = np.array([1, 2, 3])
In [3]:
print(np.maximum.reduce([a, b, c]))
In [4]:
print(np.maximum(np.maximum(a, b), c))
In [5]:
print(np.fmax.reduce([a, b, c]))
In [6]:
print(np.minimum.reduce([a, b, c]))
In [7]:
print(np.fmin.reduce([a, b, c]))
In [8]:
print(np.maximum.reduce((a, b, c)))
In [9]:
# print(np.maximum.reduce(a, b, c))
# TypeError: data type not understood
In [10]:
a_2d = np.arange(6).reshape(2, 3)
print(a_2d)
In [11]:
# print(np.maximum.reduce([a_2d, b, c]))
# ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
In [12]:
print(np.maximum(np.maximum(a_2d, b), c))
In [13]:
# print(np.maximum.reduce([4, b, c]))
# ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
In [14]:
print(np.maximum(np.maximum(4, b), c))
In [15]:
print(a)
In [16]:
print(np.maximum.reduce(a))
In [17]:
print(a.max())
In [18]:
print(max(a))
In [19]:
a_2d = np.array([[0, 1, 2], [3, 0, 6], [1, 2, 3]])
print(a_2d)
In [20]:
print(np.maximum.reduce(a_2d))
In [21]:
print(np.maximum(np.maximum(a_2d[0], a_2d[1]), a_2d[2]))
In [22]:
print(a_2d.max(axis=0))