Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
348a27c
Add LabelledPerms: auto_bisc input with labels kept as bitmaps
ulfarsson Oct 18, 2026
de4fa24
Test auto_bisc's growth past the labelled lengths with LabelledPerms
ulfarsson Oct 18, 2026
b207768
Export LabelledPerms from permuta.bisc and document it in the README
ulfarsson Oct 18, 2026
f449beb
Define LabelledPerms' bit order by Perm.unrank
ulfarsson Oct 18, 2026
9332c71
Name LabelledPerms' variables by what they hold
ulfarsson Oct 21, 2026
0099214
Make LabelledPerms and its tests easier to read
ulfarsson Oct 22, 2026
38c9dfa
Reject malformed bitmaps in LabelledPerms
ulfarsson Oct 22, 2026
58e57db
Test the labels option and LabelledPerms given a property and bitmaps
ulfarsson Oct 22, 2026
a5268a9
bisc labels what a LabelledPerms lacks, and labels="bitmaps" needs a …
ulfarsson Oct 22, 2026
a8b80bf
Test how bisc treats a LabelledPerms, and label up to max(m, n)
ulfarsson Oct 22, 2026
69057c8
Correct the memory figures in the docs
ulfarsson Oct 22, 2026
c54c542
Docstrings, messages and edge-case tests for LabelledPerms
ulfarsson Oct 22, 2026
7ade65a
Rename LabelledPerms to PropertyBitmaps
ulfarsson Oct 23, 2026
1769c1b
Plainer code where Henning stopped in PropertyBitmaps.__init__
ulfarsson Oct 23, 2026
6584339
Make the views a Mapping of Collections
ulfarsson Oct 23, 2026
1c8f7ac
Type bisc.py and let mypy check it
ulfarsson Oct 23, 2026
ea42763
Name the bit operations
ulfarsson Oct 23, 2026
80b9f04
Turn every input of bisc and auto_bisc into a PropertyBitmaps
ulfarsson Oct 23, 2026
84df804
Read a length with few wanted permutations by unranking them
ulfarsson Oct 23, 2026
67f16bb
Test how bisc and auto_bisc take each kind of input
ulfarsson Oct 23, 2026
c6dcbdf
Correct what the texts say a tuple and a property do
ulfarsson Oct 23, 2026
925c4a9
Stop auto_bisc when a tuple's bad permutations stop short
ulfarsson Oct 23, 2026
0d437fa
Let in take any sequence that is a permutation of the length
ulfarsson Oct 23, 2026
b4b27e3
Readability points from the review of round 4
ulfarsson Oct 23, 2026
41e9bc0
Keep a length with few good permutations as the indices of those
ulfarsson Oct 24, 2026
841c8dc
Test both forms in which a length's labels are kept
ulfarsson Oct 24, 2026
dd7b00f
Keep the indices of a length past 20 in a list
ulfarsson Oct 24, 2026
de9c0d3
Label a length in add_length with a bit per good permutation once its…
ulfarsson Oct 24, 2026
847e1c6
Keep a dense length's bitmap as bytes, so that reading it copies nothing
ulfarsson Oct 24, 2026
e69810d
Test the gaps the review of round 6 found in the two forms' tests
ulfarsson Oct 24, 2026
9ac4e3d
Readability and repetition points from the review of round 6
ulfarsson Oct 24, 2026
b746f89
Iterate a view through one small generator for each form
ulfarsson Oct 24, 2026
04e66c0
Tell the two forms apart in the tests by each length's container
ulfarsson Oct 24, 2026
a3c966e
Refuse a listed sequence that is not a permutation by its values
ulfarsson Oct 24, 2026
b14d825
Count a view's permutations without len(), so that past length 20 the…
ulfarsson Oct 24, 2026
b64af63
Test the gaps the review of round 7 found in the two forms' tests
ulfarsson Oct 24, 2026
7da301c
Readability points from the review of round 7
ulfarsson Oct 24, 2026
496d536
Keep the README's BiSC paragraph short
ulfarsson Oct 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,31 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## Unreleased

### Added
Comment thread
ulfarsson marked this conversation as resolved.
- `PropertyBitmaps` in `permuta.bisc`: a property's values on the permutations,
made from a property, given as bitmaps, or both. Each length is kept as a bitmap
(lexicographic order) or, when fewer than one permutation in 64 is good, as the
sorted indices of the good ones, whichever is smaller (in a list past length
20, where an index can need more than 8 bytes). `auto_bisc` and `bisc`
accept it as input, and label the lengths it lacks with its property.

### Changed
- `bisc` and `auto_bisc` turn every input into a `PropertyBitmaps` and read the
good and the bad permutations through its views, in lexicographic order, for
the same results in far less memory at longer lengths: the permutations of
length 10 take 454 KB as a bitmap, and 0.9 to 1.8 GB as lists of `Perm` objects,
depending on the Python, and a length with few good permutations takes 8 bytes
for each of them, to length 20.
- A permutation listed twice in the input of `bisc` or `auto_bisc` counts once.
Before, duplicates could make `bisc` take a length as complete when it was not.
- `auto_bisc` raises a `ValueError` when the good and the bad permutations of a
length, from a tuple of dictionaries or a stored set, overlap or are not
together all of that length's permutations.
- `bisc` and `auto_bisc` raise a `ValueError` for a permutation given under the
key of another length, and for a `Perm` given whose values are not those of a
permutation of its length, such as one written from 1.
- `bisc` accepts any mapping of lengths to permutations, not only a `dict`.

### Fixed
- Fixed bug in `Perm.rtlmax_ltrmin_decomposition` and fixed associated tests.

Expand Down
18 changes: 17 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,23 @@ permutations that can be imported from ``permuta.bisc.perm_properties``, such
as ``smooth``, ``forest-like``, ``baxter``, ``simsun``, ``quick_sortable``, etc.

Both ``bisc`` and ``auto_bisc`` can accept input in the form of a property,
or a list of permutations (satisfying some property).
a list of permutations (satisfying some property), or a ``PropertyBitmaps``.

Whatever the input, ``bisc`` and ``auto_bisc`` keep the permutations satisfying
the property, and those that do not, length by length, in a
``PropertyBitmaps``. A length is kept as a bitmap, a bit for each permutation:
the permutations of length 10 take 454 KB as a bitmap, where they take 0.9 to
1.8 GB as lists of ``Perm`` objects.

.. code-block:: python

>>> property_bitmaps = PropertyBitmaps(Perm.stack_sortable)
>>> for length in range(6):
... property_bitmaps.add_length(length)
>>> len(property_bitmaps.good[5]), len(property_bitmaps.bad[5])
(42, 78)
>>> bisc(property_bitmaps, 3, 5)
{3: {Perm((1, 2, 0)): [set()]}}

License
#######
Expand Down
12 changes: 9 additions & 3 deletions permuta/bisc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# type: ignore

from .bisc import auto_bisc, bisc, create_bisc_input, read_bisc_file, write_bisc_files
from .bisc import (
PropertyBitmaps,
auto_bisc,
bisc,
create_bisc_input,
read_bisc_file,
write_bisc_files,
)
from .bisc_subfunctions import (
patterns_suffice_for_bad,
patterns_suffice_for_good,
Expand All @@ -10,6 +15,7 @@
)

__all__ = [
"PropertyBitmaps",
"auto_bisc",
"bisc",
"create_bisc_input",
Expand Down
Loading
Loading