Skip to content

Commit 32e6f34

Browse files
committed
update indexing documentation, fixes #248
1 parent 730c524 commit 32e6f34

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

doc/indexing.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ considered masks. For example:
6464
Note that ``del a[mask]`` is equivalent to the in-place version of
6565
selecting the reverse mask ``a = a[~mask]``.
6666

67-
Also note that masked assignment is not implemented,
67+
As of bitarray version 3.1, masked assignment to bitarrays is also
68+
supported:
69+
70+
.. code-block:: python
71+
72+
>>> a = bitarray('1001001')
73+
>>> mask = bitarray('1010111')
74+
>>> a[mask] = bitarray("11100")
75+
>>> a
76+
bitarray('1011100')
77+
78+
However, masked assignment to Booleans is not implemented,
6879
as ``a[mask] = 1`` would be equivalent to the bitwise operation ``a |= mask``.
6980
And ``a[mask] = 0`` would be equivalent to ``a &= ~mask``.

0 commit comments

Comments
 (0)