<i id='WLd8v'><tr id='WLd8v'><dt id='WLd8v'><q id='WLd8v'><span id='WLd8v'><b id='WLd8v'><form id='WLd8v'><ins id='WLd8v'></ins><ul id='WLd8v'></ul><sub id='WLd8v'></sub></form><legend id='WLd8v'></legend><bdo id='WLd8v'><pre id='WLd8v'><center id='WLd8v'></center></pre></bdo></b><th id='WLd8v'></th></span></q></dt></tr></i><div id='WLd8v'><tfoot id='WLd8v'></tfoot><dl id='WLd8v'><fieldset id='WLd8v'></fieldset></dl></div>

    <small id='WLd8v'></small><noframes id='WLd8v'>

      1. <tfoot id='WLd8v'></tfoot>

        <legend id='WLd8v'><style id='WLd8v'><dir id='WLd8v'><q id='WLd8v'></q></dir></style></legend>
          <bdo id='WLd8v'></bdo><ul id='WLd8v'></ul>

      2. np.isnan() == False,但 np.isnan() 不是 False

        np.isnan() == False, but np.isnan() is not False(np.isnan() == False,但 np.isnan() 不是 False)
        <legend id='gMMcz'><style id='gMMcz'><dir id='gMMcz'><q id='gMMcz'></q></dir></style></legend>
      3. <i id='gMMcz'><tr id='gMMcz'><dt id='gMMcz'><q id='gMMcz'><span id='gMMcz'><b id='gMMcz'><form id='gMMcz'><ins id='gMMcz'></ins><ul id='gMMcz'></ul><sub id='gMMcz'></sub></form><legend id='gMMcz'></legend><bdo id='gMMcz'><pre id='gMMcz'><center id='gMMcz'></center></pre></bdo></b><th id='gMMcz'></th></span></q></dt></tr></i><div id='gMMcz'><tfoot id='gMMcz'></tfoot><dl id='gMMcz'><fieldset id='gMMcz'></fieldset></dl></div>
      4. <small id='gMMcz'></small><noframes id='gMMcz'>

            <bdo id='gMMcz'></bdo><ul id='gMMcz'></ul>
            <tfoot id='gMMcz'></tfoot>
                  <tbody id='gMMcz'></tbody>
                1. 本文介绍了np.isnan() == False,但 np.isnan() 不是 False的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  据我了解,== 检查值是否相等,is 检查值后面的结构的身份(例如 === 其他语言).

                  As far as I understand it, == checks for equality of value, and is checks for identity of structure behind value (as, say === in some other languages).

                  鉴于此,我不明白以下内容:

                  Given that, I don't understand the following:

                  np.isnan(30) == False
                  Out[19]: 
                  True
                  np.isnan(30) is False
                  Out[20]: 
                  False
                  

                  其他身份检查似乎并非如此:

                  It appears not to be the case with other identity checks:

                  (5 == 4) == False
                  Out[22]: 
                  True
                  (5 == 4) is False
                  Out[23]: 
                  True
                  

                  看起来好像 np.isnan() 返回 False 作为值,而不是作为标识.为什么会这样?

                  It appears as if np.isnan() returns False as a value, but not as identity. Why is that the case?

                  推荐答案

                  numpy.isnan() 返回一个compatible 类型的对象:

                  numpy.isnan() returns a compatible type object:

                  >>> import numpy
                  >>> type(numpy.isnan(0))
                  <class 'numpy.bool_'>
                  

                  这是一个自定义布尔值,可以有效地存储在 numpy 数组中,请参阅 Numpy 的 数据类型 文档.numpy.isnan() 函数也可以对数组进行操作,生成另一个数组并得到结果:

                  This is a custom boolean that can be stored efficiently in numpy arrays, see Numpy's Data Types documentation. The numpy.isnan() function can also operate on arrays, producing another array with results:

                  >>> numpy.isnan(numpy.array([1, 2]))
                  array([False, False], dtype=bool)
                  

                  dtype 又是 Numpy 布尔对象.

                  where again the dtype is the Numpy boolean object.

                  Python 不保证布尔运算必须始终返回单例布尔值.你永远不应该测试 is Trueis False anyway.在布尔运算中直接使用 numpy.isnan() 输出,使用 not 来测试假值:

                  Python makes no guarantees that boolean operations must always return a singleton boolean value. You should never test for is True or is False anyway. Use numpy.isnan() output directly in boolean operations, use not to test for false values:

                  if numpy.isnan(foo):
                  

                  if not numpy.isnan(bar):
                  

                  这篇关于np.isnan() == False,但 np.isnan() 不是 False的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Initialize Multiple Numpy Arrays (Multiple Assignment) - Like MATLAB deal()(初始化多个 Numpy 数组(多重赋值) - 像 MATLAB deal())
                  How to extend Python class init(如何扩展 Python 类初始化)
                  What#39;s the difference between dict() and {}?(dict() 和 {} 有什么区别?)
                  What is a wrapper_descriptor, and why is Foo.__init__() one in this case?(什么是 wrapper_descriptor,为什么 Foo.__init__() 在这种情况下是其中之一?)
                  Initialize list with same bool value(使用相同的布尔值初始化列表)
                  setattr with kwargs, pythonic or not?(setattr 与 kwargs,pythonic 与否?)

                    <tbody id='EJX4O'></tbody>

                  <small id='EJX4O'></small><noframes id='EJX4O'>

                      • <i id='EJX4O'><tr id='EJX4O'><dt id='EJX4O'><q id='EJX4O'><span id='EJX4O'><b id='EJX4O'><form id='EJX4O'><ins id='EJX4O'></ins><ul id='EJX4O'></ul><sub id='EJX4O'></sub></form><legend id='EJX4O'></legend><bdo id='EJX4O'><pre id='EJX4O'><center id='EJX4O'></center></pre></bdo></b><th id='EJX4O'></th></span></q></dt></tr></i><div id='EJX4O'><tfoot id='EJX4O'></tfoot><dl id='EJX4O'><fieldset id='EJX4O'></fieldset></dl></div>
                        <tfoot id='EJX4O'></tfoot>

                          <bdo id='EJX4O'></bdo><ul id='EJX4O'></ul>
                          1. <legend id='EJX4O'><style id='EJX4O'><dir id='EJX4O'><q id='EJX4O'></q></dir></style></legend>