|
1 | 1 | Reference |
2 | 2 | ========= |
3 | 3 |
|
4 | | -bitarray version: 3.4.3 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__ |
| 4 | +bitarray version: 3.5.0 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__ |
5 | 5 |
|
6 | 6 | In the following, ``item`` and ``value`` are usually a single bit - |
7 | 7 | an integer 0 or 1. |
@@ -502,6 +502,19 @@ This sub-module was added in version 1.2. |
502 | 502 | New in version 1.8 |
503 | 503 |
|
504 | 504 |
|
| 505 | +``random_p(n, /, p=0.5, endian=None)`` -> bitarray |
| 506 | + Return pseudo-random bitarray of length ``n``. Each bit has probability ``p`` of |
| 507 | + being 1. Equivalent to ``bitarray((random() < p for _ in range(n)), endian)``. |
| 508 | + The bitarrays are reproducible when calling Python's ``random.seed()`` with a |
| 509 | + specific seed value. |
| 510 | + |
| 511 | + This function requires Python 3.12 or higher, as it depends on the standard |
| 512 | + library function ``random.binomialvariate()``. Raises ``NotImplementedError`` |
| 513 | + when Python version is too low. |
| 514 | + |
| 515 | + New in version 3.5 |
| 516 | + |
| 517 | + |
505 | 518 | ``sc_decode(stream)`` -> bitarray |
506 | 519 | Decompress binary stream (an integer iterator, or bytes-like object) of a |
507 | 520 | sparse compressed (``sc``) bitarray, and return the decoded bitarray. |
@@ -545,8 +558,8 @@ This sub-module was added in version 1.2. |
545 | 558 | iteration is stopped as soon as one mismatch is found. |
546 | 559 |
|
547 | 560 |
|
548 | | -``urandom(length, /, endian=None)`` -> bitarray |
549 | | - Return a bitarray of ``length`` random bits (uses ``os.urandom``). |
| 561 | +``urandom(n, /, endian=None)`` -> bitarray |
| 562 | + Return random bitarray of length ``n`` (uses ``os.urandom()``). |
550 | 563 |
|
551 | 564 | New in version 1.7 |
552 | 565 |
|
|
0 commit comments