numpy
的ceil
函数用于对数组中的元素进行向上取整。
import numpy as np
a = np.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])
print("np.ceil(a) =", np.ceil(a))
执行结果:
np.ceil(a) = [-1. -1. -0. 1. 2. 2. 2.]
numpy
的ceil
函数用于对数组中的元素进行向上取整。
import numpy as np
a = np.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])
print("np.ceil(a) =", np.ceil(a))
执行结果:
np.ceil(a) = [-1. -1. -0. 1. 2. 2. 2.]