无法理解np.min()函数中初始参数的行为:

huangapple go评论47阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年2月19日 00:03:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/75494583.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定