[Numpy-discussion] Boolean arrays with nulls?
chris.barker at noaa.gov
Mon Apr 22 12:20:05 EDT 2019
On Thu, Apr 18, 2019 at 10:52 AM Stuart Reynolds <stuart at stuartreynolds.net>
> Is float8 a thing?
no, but np.float16 is -- so at least only twice as much memory as youo need
array([ nan, inf, -inf], dtype=float16)
I think masked arrays are going to be just as much, as they need to carry
> On Thu, Apr 18, 2019 at 9:46 AM Stefan van der Walt <stefanv at berkeley.edu>
>> Hi Stuart,
>> On Thu, 18 Apr 2019 09:12:31 -0700, Stuart Reynolds wrote:
>> > Is there an efficient way to represent bool arrays with null entries?
>> You can use the bool dtype:
>> In : x = np.array([True, False, True])
>> In : x
>> Out: array([ True, False, True])
>> In : x.dtype
>> Out: dtype('bool')
>> You should note that this stores one True/False value per byte, so it is
>> not optimal in terms of memory use. There is no easy way to do
>> bit-arrays with NumPy, because we use strides to determine how to move
>> from one memory location to the next.
>> See also:
>> > What I’m hoping for is that there’s a structure that is ‘viewed’ as
>> > nan-able float data, but backed but a more efficient structures
>> > internally.
>> There are good implementations of this idea, such as:
>> Those structures cannot typically utilize the NumPy machinery, though.
>> With the new array function interface, you should at least be able to
>> build something that has something close to the NumPy API.
>> Best regards,
>> NumPy-Discussion mailing list
>> NumPy-Discussion at python.org
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion