diff options
author | Ganesh Kathiresan <ganesh3597@gmail.com> | 2021-11-02 03:35:27 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-01 17:05:27 -0500 |
commit | fae6fa47a3cf9b9c64af2f5bd11a3b644b1763d2 (patch) | |
tree | 835df556a0beaa6822692428c9ca4e9d6ccb76e1 /doc/release | |
parent | 987d25bebb3564eca4a86712ccdeba93016758ed (diff) | |
download | numpy-fae6fa47a3cf9b9c64af2f5bd11a3b644b1763d2.tar.gz |
ENH: Adding `scalar.bit_count()` (popcount) (#19355)
Adding bitcount method to scalars, e.g.:
a = np.int32(1023).bit_count()
* ENH: Implementation of bit_count (popcount)
* ENH: Add bit_count to integer scalar type
* ENH: Annotations for bit_count
* ENH, WIP: Documentation for bit_count
* DOC: Added `bit_count` (#19355)
* BUG: Fixed windows 32 bit issue with no `__popcnt64`
* DOC: Refined docstring for bit_count
* TST: Tests for bit_count
* ENH, MAINT: Changed return type to uint_8 | Removed extra braces and fixed typo
* BUG: Fixed syntax of bit_count
* DOC, BUG: Fixed bit_count example
* DOC, BUG: (#19355) Removed bit_count from routines.math.rst | Improved release notes
* BUG: Added type suffix to magic constants
* ENH: Handle 32 bit windows popcount | Refactored popcount implementation to new function
* MAINT: Refactor type_methods, separate integer definitions
* DOC: Added double-ticks
Diffstat (limited to 'doc/release')
-rw-r--r-- | doc/release/upcoming_changes/19355.new_feature.rst | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/release/upcoming_changes/19355.new_feature.rst b/doc/release/upcoming_changes/19355.new_feature.rst new file mode 100644 index 000000000..cfa50b7a1 --- /dev/null +++ b/doc/release/upcoming_changes/19355.new_feature.rst @@ -0,0 +1,13 @@ +``bit_count`` to compute the number of 1-bits in an integer +----------------------------------------------------------- + +Computes the number of 1-bits in the absolute value of the input. +This works on all the numpy integer types. Analogous to the builtin +``int.bit_count`` or ``popcount`` in C++. + +.. code-block:: python + + >>> np.uint32(1023).bit_count() + 10 + >>> np.int32(-127).bit_count() + 7 |