<div dir="auto">Oh. I answered thinking about choice and not choose. Please ignore both parts. </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Apr 18, 2021, 17:56 Robert Kern <<a href="mailto:robert.kern@gmail.com">robert.kern@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">On Sat, Apr 17, 2021 at 4:28 PM Kevin Sheppard <<a href="mailto:kevin.k.sheppard@gmail.com" target="_blank" rel="noreferrer">kevin.k.sheppard@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">1. I suppose it only uses the (Native int or int64) dtype since each one would need a code path to run quickly.<div dir="auto"><br></div><div dir="auto">2. I would describe this a a bug. I think sequences are converted to arrays and in this case the conversion is not returning a 2 element object array but expanding and then concatenation.</div></div></blockquote><div><br></div><div>No, it's broadcasting the two to a common shape, as documented.</div><div><a href="https://numpy.org/doc/stable/reference/generated/numpy.choose.html" target="_blank" rel="noreferrer">https://numpy.org/doc/stable/reference/generated/numpy.choose.html</a><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
E.g.,<br>
a = a = (0,1,1,0,0,0,1,1)  #binary array<br>
np.choose(a, (0,range(8))     #array([0, 1, 2, 0, 0, 0, 6, 7])<br></blockquote></div></blockquote><div> </div><div>This is equivalent to `np.choose(a, (np.zeros(8, dtype=int), range(8)))`</div><div><br></div></div>-- <br><div dir="ltr">Robert Kern</div></div>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank" rel="noreferrer">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div>