<div dir="ltr"><div>Yeah, I am not seeing any way around it at the moment. I guess I will have to use the bitarray package for now. I was hoping for some fast per-element processing, but at the moment, I guess I will have to sacrifice that just to have something that worked correctly.<br><br></div>Ben Root<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 28, 2015 at 10:19 AM, Jaime Fernández del Río <span dir="ltr"><<a href="mailto:jaime.frio@gmail.com" target="_blank">jaime.frio@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Tue, Apr 28, 2015 at 7:00 AM, Benjamin Root <span dir="ltr"><<a href="mailto:ben.root@ou.edu" target="_blank">ben.root@ou.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div>I have a need to have a numpy array of 17 byte (more specifically, at least 147 bits) values that I would be doing some bit twiddling on. I have found that doing a dtype of "i17" yields a dtype of int32, which is completely not what I intended. Doing 'u17' gets an "data type not understood". I have tried 'a17', but then bitwise_or() and left_shift() do not work (returns "NotImplemented"). </div></div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div><br></div>How should I be going about this?<br></div></div></div></blockquote><div><br></div></span><div>The correct type to use would be a void dtype:<div><br></div><div><div><font face="monospace, monospace">>>> dt = np.dtype('V17')</font></div><div><font face="monospace, monospace">>>> dt.itemsize</font></div><div><font face="monospace, monospace">17</font></div></div><div><br></div><div>Unfortunately, it does not support bitwise operations either, which seems like an oddity to me:</div><div><br></div><div><div><font face="monospace, monospace">>>> a = np.empty(2, dt)</font></div><div><font face="monospace, monospace">>>> a[0] = 'abcdef'</font></div><div><font face="monospace, monospace">>>> a[1] = bytearray([64, 56, 78])</font></div><div><font face="monospace, monospace">>>> a[0] | a[1]</font></div><div><font face="monospace, monospace">Traceback (most recent call last):</font></div><div><font face="monospace, monospace">  File "<stdin>", line 1, in <module></font></div><div><font face="monospace, monospace">TypeError: unsupported operand type(s) for |: 'numpy.void' and 'numpy.void'</font></div></div><div><br></div><div>Any fundamental reason for this?</div></div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Jaime</div><div><br></div></font></span></div><span class="HOEnZb"><font color="#888888">-- <br><div>(\__/)<br>( O.o)<br>( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de dominación mundial.</div>
</font></span></div></div>
<br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br></div>