Open page200 opened 6 days ago
Here is unpack_bits()
in numpy/numpy/_core/src/multiarray/compiled_base.c
Ha! I actually thought of this a while ago, but then I didn't see any immediate use, so I didn't pursue the idea. If you think it's useful, we could definitely add this.
It would be useful.
Maybe we can even forgo the overhead of the parameter checks that NumPy does, or at least do "memoization" so that those checks are performed only once instead of in each call?
Maybe we can even forgo the overhead of the parameter checks that NumPy does, or at least do "memoization" so that those checks are performed only once instead of in each call?
That would break numpy
-compatibility. If you're concerned about the keyword arguments, then we should do this in utils
and not as a standard numpy
function. We could simply define a class, and then unpack_bits
could be a method of that class. That would save the time of the parameter checks.
Are there plans to implement
unpackbits()
?And what are good practices for getting the same result fast while
unpackbits()
is not implemented?I'd like to use the resulting bits as Boolean indices into a constant integer array
X
or donp.nditer(np.nonzero(X))
or whatever is fastest for achieving the same effect.