This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients nschloe, steven.daprano
Date 2021-04-09.09:57:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1617962258.69.0.0955993464129.issue43786@roundup.psfhosted.org>
In-reply-to
Content
The behaviour of `is` is correct.

The `is` operator tests for object identity, not equality. The reason that `slice(None) is slice(None)` returns False is that the two calls to the slice function return two different objects.

You say that using the equals operator `==` "doesn't return a single Boolean if a is a NumPy array", that is a design flaw in numpy, and there is nothing we can do about it.

You could try something like this:

def equal(a, b):
    flag = (a == b)
    if isinstance(flag, bool):
        return flag
    else:
        return all(flag)
History
Date User Action Args
2021-04-09 09:57:38steven.dapranosetrecipients: + steven.daprano, nschloe
2021-04-09 09:57:38steven.dapranosetmessageid: <1617962258.69.0.0955993464129.issue43786@roundup.psfhosted.org>
2021-04-09 09:57:38steven.dapranolinkissue43786 messages
2021-04-09 09:57:38steven.dapranocreate