[Numpy-discussion] Re: np.bool_ vs Python bool behavior

2022-03-21 Thread Benjamin Root
Just as a quick note, I find it *very* common and handy to do something like: someCount = (x > 5).sum() which requires implicit upcasting of np.bool_ to integer. Just making sure that usecase isn't forgotten, as it had to be mentioned the last time this subject came up. On Mon, Mar 21, 2022 at

[Numpy-discussion] Re: np.bool_ vs Python bool behavior

2022-03-21 Thread Sebastian Berg
On Wed, 2022-03-16 at 18:14 +, Jacob Reinhold wrote: > Hi Sebastian and Chuck, > > Thanks for the response! (Sorry about the formatting in my original > post, I wasn't familiar with how to display code in this setting). > > I think keeping + as "logical or" and * as "logical and" on np.bool_

[Numpy-discussion] Re: np.bool_ vs Python bool behavior

2022-03-16 Thread Jacob Reinhold
Hi Sebastian and Chuck, Thanks for the response! (Sorry about the formatting in my original post, I wasn't familiar with how to display code in this setting). I think keeping + as "logical or" and * as "logical and" on np.bool_ types is fine, although redundant given that | and & provide this f

[Numpy-discussion] Re: np.bool_ vs Python bool behavior

2022-03-13 Thread Sebastian Berg
Hi Jacob, adding to what Chuck mentioned, a few inline comments if you are interested in some gory details. On Sat, 2022-03-12 at 21:40 +, Jacob Reinhold wrote: > A pain point I ran into a while ago was assuming that an np.ndarray > with dtype=np.bool_ would act similarly to the Python built

[Numpy-discussion] Re: np.bool_ vs Python bool behavior

2022-03-13 Thread Charles R Harris
On Sun, Mar 13, 2022 at 10:31 AM Charles R Harris wrote: > > > On Sat, Mar 12, 2022 at 4:53 PM Jacob Reinhold > wrote: > >> A pain point I ran into a while ago was assuming that an np.ndarray with >> dtype=np.bool_ would act similarly to the Python built-in boolean under >> addition. This is not

[Numpy-discussion] Re: np.bool_ vs Python bool behavior

2022-03-13 Thread Charles R Harris
On Sat, Mar 12, 2022 at 4:53 PM Jacob Reinhold wrote: > A pain point I ran into a while ago was assuming that an np.ndarray with > dtype=np.bool_ would act similarly to the Python built-in boolean under > addition. This is not the case, as shown in the following code snippet: > > >>> np.bool_(Tru