Adding count parameter to unpackbits (PR-10855)
Hi all, I was about to merge it, but was noot sure it was really discussed before (and it would be a long time ago). The pull requests: https://github.com/numpy/numpy/pull/10855 Proposes to add a count parameter to unpackbits: ``count`` allows subsetting the number of bits that will be unpacked up-front, rather than reshaping and subsetting later, making the ``packbits`` operation invertible, and the unpacking less wasteful. Counts larger than the number of available bits add zero padding. Negative counts trim bits off the end instead of counting from the beginning. None counts implement the existing behavior of unpacking everything. This seems like a pretty small API addition, but I thought I would ping the list again before merging in case anyone objects to it or feels it should be modified. In other words, the count parameter is much the same as indexing the result: np.unpackbits(x)[:count] although it will zero pad if count is out of bounds. Which is necessary if it is to invert a `np.packbits` when less than 8 bits are packed. If no one speaks up, I plan to merge it soon. Best, Sebastian
participants (1)
-
Sebastian Berg