numpy 的 histogram() 函数中的 'new' 参数做了什么?
What did the 'new' parameter in numpy's histogram() function do?
我偶然发现了一些 old code(>10 年),其中一行是:
c, be = np.histogram(s, bins=values, new=True)
这个new
参数是no longer there。我试图让这段代码工作,但我不知道 new
参数做了什么。我还没有在网上找到任何相关信息。我可以删除它,但我不知道它的用途以及它是否可能是重要的东西。
任何人都可以告诉我这个参数做了什么以及现在如何重现它?
该参数允许旧版本提供与新版本 (>= 1.3) 相同的 bin 创建功能。我在 link
的代码中发现了以下注释
Either an integer number of bins or a sequence giving the
bins. If bins is an integer, bins + 1 bin edges
will be returned, consistent with :func:numpy.histogram
for numpy version >= 1.3, and with the new = True argument
in earlier versions.
这来自评论中链接的文档:
new : {None, True, False}, optional
Whether to use the new semantics for histogram:
- None : the new behaviour is used, no warning is printed.
- True : the new behaviour is used and a warning is raised about the future removal of the new keyword.
- False : the old behaviour is used and a DeprecationWarning is raised.
As of NumPy 1.3, this keyword should not be used explicitly since it will disappear in NumPy 1.4.
我偶然发现了一些 old code(>10 年),其中一行是:
c, be = np.histogram(s, bins=values, new=True)
这个new
参数是no longer there。我试图让这段代码工作,但我不知道 new
参数做了什么。我还没有在网上找到任何相关信息。我可以删除它,但我不知道它的用途以及它是否可能是重要的东西。
任何人都可以告诉我这个参数做了什么以及现在如何重现它?
该参数允许旧版本提供与新版本 (>= 1.3) 相同的 bin 创建功能。我在 link
的代码中发现了以下注释Either an integer number of bins or a sequence giving the bins. If bins is an integer, bins + 1 bin edges will be returned, consistent with :func:
numpy.histogram
for numpy version >= 1.3, and with the new = True argument in earlier versions.
这来自评论中链接的文档:
new : {None, True, False}, optional
Whether to use the new semantics for histogram:
- None : the new behaviour is used, no warning is printed.
- True : the new behaviour is used and a warning is raised about the future removal of the new keyword.
- False : the old behaviour is used and a DeprecationWarning is raised.
As of NumPy 1.3, this keyword should not be used explicitly since it will disappear in NumPy 1.4.