Skip to content

Commit

Permalink
add release date - update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ilanschnell committed Dec 17, 2023
1 parent 583f379 commit a4e9303
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 41 deletions.
7 changes: 4 additions & 3 deletions CHANGE_LOG
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
2023-12-XX 2.9.0:
2023-12-17 2.9.0:
-------------------
* deprecate support for Python 2 - Python 2.7 support will be removed
in bitarray version 3.0,
see [roadmap](https://github.com/ilanschnell/bitarray#roadmap)
* `bitarray(n)` for integer initializer `n` will always return a bitarray
of length `n` with all items initialized to `0`, see #212
* allow sub-bitarray in `.count()`, #212
* add `util.ones()`
* `.find()` and `.index()`: add keyword argument `right` for rightmost index
* `.itersearch()`: add start and stop argument, and keyword
argument `right` (for descending order - starting with rightmost match)
* deprecate support for Python 2 - Python 2 support will be removed in
bitarray version 3.0
* deprecate `util.rindex()` (will be removed in 3.0 release),
use `.index(..., right=True)` instead
* deprecate `util.make_endian()` (will be removed in 3.0 release),
Expand Down
65 changes: 48 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Once you have installed the package, you may want to test it:
$ python -c 'import bitarray; bitarray.test()'
bitarray is installed in: /Users/ilan/bitarray/bitarray
bitarray version: 2.8.5
bitarray version: 2.9.0
sys.version: 3.11.0 (main, Oct 25 2022) [Clang 14.0.4]
sys.prefix: /Users/ilan/Mini3/envs/py311
pointer size: 64 bit
Expand Down Expand Up @@ -427,11 +427,13 @@ and can therefore be used as a dictionary key:
Reference
=========

bitarray version: 2.8.5 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
bitarray version: 2.9.0 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__

In the following, ``item`` and ``value`` are usually a single bit -
an integer 0 or 1.

Also, ``sub_bitarray`` refers to either a bitarray, or an ``item``.


The bitarray object:
--------------------
Expand All @@ -442,7 +444,7 @@ The bitarray object:
The initializer may be of the following types:

``int``: Create a bitarray of given integer length. The initial values are
uninitialized.
all ``0``.

``str``: Create bitarray from a string of ``0`` and ``1``.

Expand Down Expand Up @@ -511,13 +513,20 @@ bitarray methods:
Return a copy of the bitarray.


``count(value=1, start=0, stop=<end of array>, step=1, /)`` -> int
Count number of occurrences of ``value`` in the bitarray.
``count(value=1, start=0, stop=<end>, step=1, /)`` -> int
Number of occurrences of ``value`` bitarray within ``[start:stop:step]``.
Optional arguments ``start``, ``stop`` and ``step`` are interpreted in
slice notation, meaning ``a.count(value, start, stop, step)`` equals
``a[start:stop:step].count(value)``.
The ``value`` may also be a sub-bitarray. In this case non-overlapping
occurrences are counted within ``[start:stop]`` (``step`` must be 1).

New in version 1.1.0: optional start and stop arguments.

New in version 2.3.7: optional step argument.

New in version 2.9: add non-overlapping sub-bitarray count.


``decode(code, /)`` -> list
Given a prefix code (a dict mapping symbols to bitarrays, or ``decodetree``
Expand Down Expand Up @@ -545,13 +554,15 @@ bitarray methods:
a multiple of 8, and return the number of bits added [0..7].


``find(sub_bitarray, start=0, stop=<end of array>, /)`` -> int
Return lowest index where sub_bitarray is found, such that sub_bitarray
is contained within ``[start:stop]``.
``find(sub_bitarray, start=0, stop=<end>, /, right=False)`` -> int
Return lowest (or rightmost when ``right=True``) index where sub_bitarray
is found, such that sub_bitarray is contained within ``[start:stop]``.
Return -1 when sub_bitarray is not found.

New in version 2.1.

New in version 2.9: add optional keyword argument ``right``.


``frombytes(bytes, /)``
Extend bitarray with raw bytes from a bytes-like object.
Expand All @@ -569,11 +580,13 @@ bitarray methods:
is still read and appended).


``index(sub_bitarray, start=0, stop=<end of array>, /)`` -> int
Return lowest index where sub_bitarray is found, such that sub_bitarray
is contained within ``[start:stop]``.
``index(sub_bitarray, start=0, stop=<end>, /, right=False)`` -> int
Return lowest (or rightmost when ``right=True``) index where sub_bitarray
is found, such that sub_bitarray is contained within ``[start:stop]``.
Raises ``ValueError`` when the sub_bitarray is not present.

New in version 2.9: add optional keyword argument ``right``.


``insert(index, value, /)``
Insert ``value`` into bitarray before ``index``.
Expand All @@ -592,9 +605,14 @@ bitarray methods:
the symbols.


``itersearch(sub_bitarray, /)`` -> iterator
Searches for given sub_bitarray in self, and return an iterator over
the start positions where sub_bitarray matches self.
``itersearch(sub_bitarray, start=0, stop=<end>, /, right=False)`` -> iterator
Return iterator over indices where sub_bitarray is found, such that
sub_bitarray is contained within ``[start:stop]``.
The indices are iterated in ascending order (from lowest to highest),
unless ``right=True``, which will iterate in descending oder (starting with
rightmost match).

New in version 2.9: optional start and stop arguments - add optional keyword argument ``right``.


``pack(bytes, /)``
Expand Down Expand Up @@ -730,6 +748,13 @@ This sub-module was added in version 1.2.
endianness, which may be 'big', 'little'.


``ones(length, /, endian=None)`` -> bitarray
Create a bitarray of length, with all values 1, and optional
endianness, which may be 'big', 'little'.

New in version 2.9.


``urandom(length, /, endian=None)`` -> bitarray
Return a bitarray of ``length`` random bits (uses ``os.urandom``).

Expand All @@ -755,13 +780,19 @@ This sub-module was added in version 1.2.

New in version 1.3.

New in version 2.9: deprecated - use ``bitarray()``.

``rindex(bitarray, value=1, start=0, stop=<end of array>, /)`` -> int
Return rightmost (highest) index of ``value`` in bitarray.
Raises ``ValueError`` if value is not present.

``rindex(bitarray, sub_bitarray=1, start=0, stop=<end>, /)`` -> int
Return rightmost (highest) index where sub_bitarray (or item - defaults
to 1) is found in bitarray (``a``), such that sub_bitarray is contained
within ``a[start:stop]``.
Raises ``ValueError`` when the sub_bitarray is not present.

New in version 2.3.0: optional start and stop arguments.

New in version 2.9: deprecated - use ``.index(..., right=1)``.


``strip(bitarray, /, mode='right')`` -> bitarray
Return a new bitarray with zeros stripped from left, right or both ends.
Expand Down
18 changes: 18 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
Change log
==========

**2.9.0** (2023-12-17):

* deprecate support for Python 2 - Python 2.7 support will be removed
in bitarray version 3.0,
see `roadmap <https://github.com/ilanschnell/bitarray#roadmap>`__
* ``bitarray(n)`` for integer initializer ``n`` will always return a bitarray
of length ``n`` with all items initialized to ``0``, see `#212 <https://github.com/ilanschnell/bitarray/issues/212>`__
* allow sub-bitarray in ``.count()``, `#212 <https://github.com/ilanschnell/bitarray/issues/212>`__
* add ``util.ones()``
* ``.find()`` and ``.index()``: add keyword argument ``right`` for rightmost index
* ``.itersearch()``: add start and stop argument, and keyword
argument ``right`` (for descending order - starting with rightmost match)
* deprecate ``util.rindex()`` (will be removed in 3.0 release),
use ``.index(..., right=True)`` instead
* deprecate ``util.make_endian()`` (will be removed in 3.0 release),
use ``bitarray(..., endian=...)`` instead


**2.8.5** (2023-12-09):

* speedup unaligned copies by always using word shifts (in combination
Expand Down
63 changes: 47 additions & 16 deletions doc/reference.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
Reference
=========

bitarray version: 2.8.5 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
bitarray version: 2.9.0 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__

In the following, ``item`` and ``value`` are usually a single bit -
an integer 0 or 1.

Also, ``sub_bitarray`` refers to either a bitarray, or an ``item``.


The bitarray object:
--------------------
Expand All @@ -16,7 +18,7 @@ The bitarray object:
The initializer may be of the following types:

``int``: Create a bitarray of given integer length. The initial values are
uninitialized.
all ``0``.

``str``: Create bitarray from a string of ``0`` and ``1``.

Expand Down Expand Up @@ -85,13 +87,20 @@ bitarray methods:
Return a copy of the bitarray.


``count(value=1, start=0, stop=<end of array>, step=1, /)`` -> int
Count number of occurrences of ``value`` in the bitarray.
``count(value=1, start=0, stop=<end>, step=1, /)`` -> int
Number of occurrences of ``value`` bitarray within ``[start:stop:step]``.
Optional arguments ``start``, ``stop`` and ``step`` are interpreted in
slice notation, meaning ``a.count(value, start, stop, step)`` equals
``a[start:stop:step].count(value)``.
The ``value`` may also be a sub-bitarray. In this case non-overlapping
occurrences are counted within ``[start:stop]`` (``step`` must be 1).

New in version 1.1.0: optional start and stop arguments.

New in version 2.3.7: optional step argument.

New in version 2.9: add non-overlapping sub-bitarray count.


``decode(code, /)`` -> list
Given a prefix code (a dict mapping symbols to bitarrays, or ``decodetree``
Expand Down Expand Up @@ -119,13 +128,15 @@ bitarray methods:
a multiple of 8, and return the number of bits added [0..7].


``find(sub_bitarray, start=0, stop=<end of array>, /)`` -> int
Return lowest index where sub_bitarray is found, such that sub_bitarray
is contained within ``[start:stop]``.
``find(sub_bitarray, start=0, stop=<end>, /, right=False)`` -> int
Return lowest (or rightmost when ``right=True``) index where sub_bitarray
is found, such that sub_bitarray is contained within ``[start:stop]``.
Return -1 when sub_bitarray is not found.

New in version 2.1.

New in version 2.9: add optional keyword argument ``right``.


``frombytes(bytes, /)``
Extend bitarray with raw bytes from a bytes-like object.
Expand All @@ -143,11 +154,13 @@ bitarray methods:
is still read and appended).


``index(sub_bitarray, start=0, stop=<end of array>, /)`` -> int
Return lowest index where sub_bitarray is found, such that sub_bitarray
is contained within ``[start:stop]``.
``index(sub_bitarray, start=0, stop=<end>, /, right=False)`` -> int
Return lowest (or rightmost when ``right=True``) index where sub_bitarray
is found, such that sub_bitarray is contained within ``[start:stop]``.
Raises ``ValueError`` when the sub_bitarray is not present.

New in version 2.9: add optional keyword argument ``right``.


``insert(index, value, /)``
Insert ``value`` into bitarray before ``index``.
Expand All @@ -166,9 +179,14 @@ bitarray methods:
the symbols.


``itersearch(sub_bitarray, /)`` -> iterator
Searches for given sub_bitarray in self, and return an iterator over
the start positions where sub_bitarray matches self.
``itersearch(sub_bitarray, start=0, stop=<end>, /, right=False)`` -> iterator
Return iterator over indices where sub_bitarray is found, such that
sub_bitarray is contained within ``[start:stop]``.
The indices are iterated in ascending order (from lowest to highest),
unless ``right=True``, which will iterate in descending oder (starting with
rightmost match).

New in version 2.9: optional start and stop arguments - add optional keyword argument ``right``.


``pack(bytes, /)``
Expand Down Expand Up @@ -304,6 +322,13 @@ This sub-module was added in version 1.2.
endianness, which may be 'big', 'little'.


``ones(length, /, endian=None)`` -> bitarray
Create a bitarray of length, with all values 1, and optional
endianness, which may be 'big', 'little'.

New in version 2.9.


``urandom(length, /, endian=None)`` -> bitarray
Return a bitarray of ``length`` random bits (uses ``os.urandom``).

Expand All @@ -329,13 +354,19 @@ This sub-module was added in version 1.2.

New in version 1.3.

New in version 2.9: deprecated - use ``bitarray()``.

``rindex(bitarray, value=1, start=0, stop=<end of array>, /)`` -> int
Return rightmost (highest) index of ``value`` in bitarray.
Raises ``ValueError`` if value is not present.

``rindex(bitarray, sub_bitarray=1, start=0, stop=<end>, /)`` -> int
Return rightmost (highest) index where sub_bitarray (or item - defaults
to 1) is found in bitarray (``a``), such that sub_bitarray is contained
within ``a[start:stop]``.
Raises ``ValueError`` when the sub_bitarray is not present.

New in version 2.3.0: optional start and stop arguments.

New in version 2.9: deprecated - use ``.index(..., right=1)``.


``strip(bitarray, /, mode='right')`` -> bitarray
Return a new bitarray with zeros stripped from left, right or both ends.
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

if sys.version_info[0] == 2:
print("""\
**************************************************************************
* Python 2 support of bitarray is deprecated (as of bitarray version 2.9)
* and will be removed in bitarray version 3.0.
**************************************************************************
****************************************************************************
* Python 2 support of bitarray is deprecated (as of bitarray version 2.9)
* and will be removed in bitarray version 3.0.
****************************************************************************
""")

if "test" in sys.argv:
Expand Down
2 changes: 1 addition & 1 deletion update_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def write_reference(fo):
In the following, ``item`` and ``value`` are usually a single bit -
an integer 0 or 1.
Also, ``sub_bitarray`` refers to either a bitarray, or an item.
Also, ``sub_bitarray`` refers to either a bitarray, or an ``item``.
The bitarray object:
Expand Down

0 comments on commit a4e9303

Please sign in to comment.