<div dir="ltr"><div dir="ltr">On Thu, Apr 18, 2019 at 10:52 AM Stuart Reynolds <<a href="mailto:stuart@stuartreynolds.net">stuart@stuartreynolds.net</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><div dir="auto">Is float8 a thing?</div></div></blockquote><div><br></div><div>no, but np.float16 is -- so at least only twice as much memory as youo need :-)</div><br><font face="monospace, monospace">array([ nan,  inf, -inf], dtype=float16)</font><br><br>I think masked arrays are going to be just as much, as they need to carry the mask.<br><br>-CHB</div><div class="gmail_quote"><br><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><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 18, 2019 at 9:46 AM Stefan van der Walt <<a href="mailto:stefanv@berkeley.edu" target="_blank">stefanv@berkeley.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Stuart,<br>
<br>
On Thu, 18 Apr 2019 09:12:31 -0700, Stuart Reynolds wrote:<br>
> Is there an efficient way to represent bool arrays with null entries?<br>
<br>
You can use the bool dtype:<br>
<br>
In [5]: x = np.array([True, False, True])                                                                                                                                            <br>
<br>
In [6]: x                                                                                                                                                                            <br>
Out[6]: array([ True, False,  True])<br>
<br>
In [7]: x.dtype                                                                                                                                                                      <br>
Out[7]: dtype('bool')<br>
<br>
You should note that this stores one True/False value per byte, so it is<br>
not optimal in terms of memory use.  There is no easy way to do<br>
bit-arrays with NumPy, because we use strides to determine how to move<br>
from one memory location to the next.<br>
<br>
See also: <a href="https://www.reddit.com/r/Python/comments/5oatp5/one_bit_data_type_in_numpy/" rel="noreferrer" target="_blank">https://www.reddit.com/r/Python/comments/5oatp5/one_bit_data_type_in_numpy/</a><br>
<br>
> What I’m hoping for is that there’s a structure that is ‘viewed’ as<br>
> nan-able float data, but backed but a more efficient structures<br>
> internally.<br>
<br>
There are good implementations of this idea, such as:<br>
<br>
<a href="https://github.com/ilanschnell/bitarray" rel="noreferrer" target="_blank">https://github.com/ilanschnell/bitarray</a><br>
<br>
Those structures cannot typically utilize the NumPy machinery, though.<br>
With the new array function interface, you should at least be able to<br>
build something that has something close to the NumPy API.<br>
<br>
Best regards,<br>
Stéfan<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div></div>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div></div>