December 2016
Intermediate to advanced
332 pages
6h 2m
English
You cannot use and, or, and not on Boolean arrays. Indeed, those operators force the casting from array to Boolean, which is not permitted. Instead, we can use the operators given in the following table (Table 5.1) for componentwise logical operations on Boolean arrays:
|
Logic operator
|
Replacement for Boolean arrays
|
|
|
|
|
|
|
|
|
|
Table 5.1 Logical operators and, or and not do not work with arrays.
A = array([True, True, False, False]) B = array([True, False, True, False]) A and B # error! A & B # array([True, False, False, False]) A | B # array([True, True, True, False]) ~A # array([False, False, True, True])
Here is an example usage of logical operators with ...
Read now
Unlock full access