Skip to content

Commit 90138f3

Browse files
Merge pull request #155 from PermutaTriangle/develop
v2.0.3
2 parents fddc2d1 + aed5335 commit 90138f3

File tree

22 files changed

+1131
-317
lines changed

22 files changed

+1131
-317
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: build-and-deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-python@v2
14+
with:
15+
python-version: 3.8
16+
- name: install dependencies
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install setuptools wheel twine
20+
- name: build
21+
run: python setup.py sdist
22+
- name: deploy
23+
env:
24+
TWINE_USERNAME: __token__
25+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
26+
run: twine upload dist/*

.github/workflows/test.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
7+
test:
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
include:
12+
- python: 3.8
13+
toxenv: flake8
14+
os: ubuntu-latest
15+
- python: 3.8
16+
toxenv: mypy
17+
os: ubuntu-latest
18+
- python: 3.8
19+
toxenv: pylint
20+
os: ubuntu-latest
21+
- python: 3.8
22+
toxenv: black
23+
os: ubuntu-latest
24+
25+
- python: 3.7
26+
toxenv: py37
27+
os: ubuntu-latest
28+
- python: 3.8
29+
toxenv: py38
30+
os: ubuntu-latest
31+
- python: 3.9
32+
toxenv: py39
33+
os: ubuntu-latest
34+
- python: pypy-3.7
35+
toxenv: pypy37
36+
os: ubuntu-latest
37+
38+
- python: 3.8
39+
toxenv: py38
40+
os: macos-latest
41+
- python: 3.8
42+
toxenv: py38
43+
os: windows-latest
44+
45+
runs-on: ${{ matrix.os }}
46+
steps:
47+
- uses: actions/checkout@v2
48+
- uses: actions/setup-python@v2
49+
with:
50+
python-version: ${{ matrix.python }}
51+
- name: install dependencies
52+
run: python -m pip install --upgrade pip tox
53+
- name: run
54+
env:
55+
TOXENV: ${{ matrix.toxenv }}
56+
run: tox
57+
- name: setup
58+
run: python setup.py install

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: stable
3+
rev: 20.8b0
44
hooks:
55
- id: black

.pylintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ ignore= tests
99
init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.append(os.path.dirname(find_pylintrc())+'/permuta')"
1010
disable=bad-continuation,
1111
missing-module-docstring,
12-
fixme
12+
fixme,
13+
unsubscriptable-object
1314
good-names=i,j,n,k,x,y,_
1415

1516
[SIMILARITIES]

.travis.yml

Lines changed: 0 additions & 52 deletions
This file was deleted.

.zenodo.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"upload_type": "software",
3+
"creators": [
4+
{
5+
"name": "Ragnar Pall Ardal"
6+
},
7+
{
8+
"name": "Tomas Ken Magnusson"
9+
},
10+
{
11+
"affiliation": "Reykjavik University",
12+
"name": "Émile Nadeau"
13+
},
14+
{
15+
"name": "Bjarni Jens Kristinsson"
16+
},
17+
{
18+
"name": "Bjarki Agust Gudmundsson"
19+
},
20+
{
21+
"affiliation": "Reykjavik University",
22+
"name": "Christian Bean"
23+
},
24+
{
25+
"affiliation": "Reykjavik University",
26+
"name": "Henning Ulfarsson"
27+
},
28+
{
29+
"affiliation": "Reykjavik University",
30+
"name": "Jon Steinn Eliasson"
31+
},
32+
{
33+
"name": "Murray Tannock"
34+
},
35+
{
36+
"name": "Alfur Birkir Bjarnason"
37+
},
38+
{
39+
"affiliation": "Marquette University",
40+
"name": "Jay Pantone"
41+
},
42+
]
43+
}

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## Unreleased
88

9+
## 2.0.3 - 2021-04-28
10+
### Added
11+
- using Github Actions for testing and deployment
12+
- `containment_to_tikz` method in `Perm` that returns an iterator of tikz pictures
13+
displaying occurrences of classical patterns in self.
14+
- `permuta.permutils.PermutationStatistic` to check statistic distribution in
15+
classes and preservation and transformation in bijections.
16+
17+
### Deprecated
18+
- Python 3.6 is no longer supported
19+
920
## 2.0.2 - 2020-08-06
1021
### Fixed
1122
- Include the type hints in the pypi release.

README.rst

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,93 @@ You can get its enumeration up to a fixed length.
186186
>>> perm_class.count(11)
187187
1024
188188
189+
You can also look to see if some well know enumeration strategies apply to a
190+
given class.
191+
192+
.. code-block:: python
193+
194+
>>> from permuta.enumeration_strategies import find_strategies
195+
>>> basis = [Perm((3, 2, 0, 1)), Perm((1, 0, 2, 3))]
196+
>>> for strat in find_strategies(basis):
197+
... print(strat.reference())
198+
The insertion encoding of permutations: Corollary 10
199+
>>> basis = [Perm((1, 2, 0, 3)), Perm((2, 0, 1, 3)), Perm((0, 1, 2, 3))]
200+
>>> for strat in find_strategies(basis):
201+
... print(strat.reference())
202+
Enumeration of Permutation Classes and Weighted Labelled Independent Sets: Corollary 4.3
203+
204+
Permutation statistics
205+
######################
206+
207+
With the ``PermutationStatistic`` class we can look for distributions of statistics for
208+
classes and look for statistics preservations (or transformation) either for two classes
209+
or given a bijection. First we need to import it.
210+
211+
.. code-block:: python
212+
213+
>>> from permuta.permutils.statistics import PermutationStatistic
214+
215+
To see a distribution for a given statistic we grab its instance and provide a length
216+
and a class (no class will use the set of all permutations).
217+
218+
.. code-block:: python
219+
220+
>>> PermutationStatistic.show_predefined_statistics() # Show all statistics with id
221+
[0] Number of inversions
222+
[1] Number of non-inversions
223+
[2] Major index
224+
[3] Number of descents
225+
[4] Number of ascents
226+
[5] Number of peaks
227+
[6] Number of valleys
228+
[7] Number of cycles
229+
[8] Number of left-to-right minimas
230+
[9] Number of left-to-right maximas
231+
[10] Number of right-to-left minimas
232+
[11] Number of right-to-left maximas
233+
[12] Number of fixed points
234+
[13] Order
235+
[14] Longest increasing subsequence
236+
[15] Longest decreasing subsequence
237+
[16] Depth
238+
>>> depth = PermutationStatistic.get_by_index(16)
239+
>>> depth.distribution_for_length(5)
240+
[1, 4, 12, 24, 35, 24, 20]
241+
>>> depth.distribution_up_to(4, Av.from_string("123"))
242+
[[1], [1], [1, 1], [0, 2, 3], [0, 0, 3, 7, 4]]
243+
244+
Given a bijection as a dictionary, we can check which statistics are preserved with
245+
``check_all_preservations`` and which are transformed with ``check_all_transformed``
246+
247+
.. code-block:: python
248+
249+
>>> bijection = {p: p.reverse() for p in Perm.up_to_length(5)}
250+
>>> for stat in PermutationStatistic.check_all_preservations(bijection):
251+
... print(stat)
252+
Number of peaks
253+
Number of valleys
254+
255+
We can find all (predefined) statistics equally distributed over two permutation
256+
classes with ``equally_distributed``. We also support checks for joint distribution
257+
of more than one statistics with ``jointly_equally_distributed`` and transformation
258+
of jointly distributed stats with ``jointly_transformed_equally_distributed``.
259+
260+
.. code-block:: python
261+
262+
>>> cls1 = Av.from_string("2143,415263")
263+
>>> cls2 = Av.from_string("3142")
264+
>>> for stat in PermutationStatistic.equally_distributed(cls1, cls2, 6):
265+
... print(stat)
266+
Major index
267+
Number of descents
268+
Number of ascents
269+
Number of peaks
270+
Number of valleys
271+
Number of left-to-right minimas
272+
Number of right-to-left maximas
273+
Longest increasing subsequence
274+
Longest decreasing subsequence
275+
189276
The BiSC algorithm
190277
==================
191278

permuta/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from .patterns import BivincularPatt, CovincularPatt, MeshPatt, Perm, VincularPatt
22
from .perm_sets.permset import Av, Basis, MeshBasis
33

4+
__version__ = "2.0.3"
5+
46
__all__ = [
57
"Perm",
68
"Av",

permuta/cli.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ def get_parser() -> argparse.ArgumentParser:
6868
description="A tool to quickly get the enumeration of permutation classes",
6969
)
7070
count_parser.set_defaults(func=enumerate_class)
71-
count_parser.add_argument(
72-
"basis", help=basis_str,
73-
)
71+
count_parser.add_argument("basis", help=basis_str)
7472

7573
# The insenc command
7674
insenc_parser: argparse.ArgumentParser = subparsers.add_parser(
@@ -79,9 +77,7 @@ def get_parser() -> argparse.ArgumentParser:
7977
" encoding.",
8078
)
8179
insenc_parser.set_defaults(func=has_regular_insertion_encoding)
82-
insenc_parser.add_argument(
83-
"basis", help=basis_str,
84-
)
80+
insenc_parser.add_argument("basis", help=basis_str)
8581

8682
# The lexmin command
8783
lexmin_parser: argparse.ArgumentParser = subparsers.add_parser(
@@ -90,9 +86,7 @@ def get_parser() -> argparse.ArgumentParser:
9086
"representation of the basis.",
9187
)
9288
lexmin_parser.set_defaults(func=get_lex_min)
93-
lexmin_parser.add_argument(
94-
"basis", help=basis_str,
95-
)
89+
lexmin_parser.add_argument("basis", help=basis_str)
9690

9791
# The poly command
9892
poly_parser: argparse.ArgumentParser = subparsers.add_parser(

0 commit comments

Comments
 (0)