英文:
Couldn't understand the behaviour of initial parameter in np.min() function:
问题
print('min using where parameter column-wise with initial parameter as 10:', np.min([[9, 13], [12, 11]], where=[False, True], initial=10))
output:
使用 where 参数按列计算最小值,初始参数为 10:10
根据我的理解,初始参数是在数组的最小值大于“initial”参数值时,输出数组中的输出值(换句话说,最大值作为输出)。
但在这里,即使数组的最小值是9,输出仍然是10。
英文:
print('min using where parameter column wise with initial parameter as 10: ',
np.min([[9,13],[12,11]], where=[False, True], initial=10))
output:
min using where parameter column-wise with initial parameter as 10: 10
According to my understanding, the initial parameter is something that will be the output value in the output array when the minimum value in the array is greater than the 'initial' parameter value. (In other words, maximum value to printed as output)
But here, it is showing 10 as output even when we have 9 as the minimum value of the array.
答案1
得分: 2
抱歉,我的错。
问题在于我完全忘记了where
参数,因为我已经向where
参数提供了输入[False, True]
。所以带有where
参数的实际输出是11。所以它打印出10作为输出。
英文:
Sorry, my bad guys.
The thing is I completely forgot about the where parameter, as I have
provided input to the where parameter = [False, True]. so the actual output with the where parameter is 11. So it is printing 10 as output.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论