Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0ff8230

Browse files
committed
DOC: Improved bitwise_count documentation
* Added return type for integer inputs * Refined release note * Refined external references for popcount
1 parent 3e398c0 commit 0ff8230

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

doc/release/upcoming_changes/19355.new_feature.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
`np.bitwise_count` to compute the number of 1-bits in an integer
2-
----------------------------------------------------------------
1+
`np.bitwise_count` to compute the number of 1-bits in an integer array
2+
----------------------------------------------------------------------
33

44
This new function counts the number of 1-bits in a number.
5-
These work on all the numpy integer types, as well as the
6-
builtin arbitrary-precision `Decimal` and `long` types.
7-
Internally, this function calls `np.bit_count`
5+
`np.bitwise_count` works on all the numpy integer types and
6+
integer-like objects.
87

98
.. code-block:: python
109

numpy/core/code_generators/ufunc_docstrings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4230,15 +4230,18 @@ def add_newdoc(place, name, doc):
42304230
-------
42314231
y : ndarray
42324232
The corresponding number of 1-bits in the input.
4233+
Returns uint8 for all integer types
42334234
$OUT_SCALAR_1
42344235
42354236
References
42364237
----------
4237-
.. [1] https://stackoverflow.com/a/109025/5671364
4238+
.. [1] https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
42384239
42394240
.. [2] Wikipedia, "Hamming weight",
42404241
https://en.wikipedia.org/wiki/Hamming_weight
42414242
4243+
.. [3] http://aggregate.ee.engr.uky.edu/MAGIC/#Population%20Count%20(Ones%20Count)
4244+
42424245
Examples
42434246
--------
42444247
>>> np.bitwise_count(1023)

0 commit comments

Comments
 (0)