-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from PermutaTriangle/develop
Version 2.2.0
- Loading branch information
Showing
24 changed files
with
8,016 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
dfa_db/* | ||
.mypy_cache | ||
# Mac stuff | ||
*.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 21.6b0 | ||
rev: 21.9b0 | ||
hooks: | ||
- id: black |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,51 @@ | ||
{ | ||
"upload_type": "software", | ||
"title": "Permuta: A Python Library for Permutations and Patterns", | ||
"creators": [ | ||
{ | ||
"name": "Ragnar Pall Ardal" | ||
}, | ||
{ | ||
"name": "Tomas Ken Magnusson" | ||
"name": "Arnar Bjarni Arnarson" | ||
}, | ||
{ | ||
"affiliation": "Reykjavik University", | ||
"name": "Émile Nadeau" | ||
}, | ||
{ | ||
"name": "Bjarni Jens Kristinsson" | ||
"name": "Christian Bean" | ||
}, | ||
{ | ||
"name": "Bjarki Agust Gudmundsson" | ||
"name": "Alfur Birkir Bjarnason" | ||
}, | ||
{ | ||
"affiliation": "Reykjavik University", | ||
"name": "Christian Bean" | ||
"name": "Jon Steinn Eliasson" | ||
}, | ||
{ | ||
"affiliation": "Reykjavik University", | ||
"name": "Henning Ulfarsson" | ||
"name": "Bjarki Agust Gudmundsson" | ||
}, | ||
{ | ||
"affiliation": "Reykjavik University", | ||
"name": "Jon Steinn Eliasson" | ||
"name": "Sigurjón Ingi Jónsson" | ||
} | ||
{ | ||
"name": "Bjarni Jens Kristinsson" | ||
}, | ||
{ | ||
"name": "Murray Tannock" | ||
"name": "Tomas Ken Magnusson" | ||
}, | ||
{ | ||
"name": "Alfur Birkir Bjarnason" | ||
"affiliation": "Reykjavik University", | ||
"name": "Émile Nadeau" | ||
}, | ||
{ | ||
"affiliation": "Marquette University", | ||
"name": "Jay Pantone" | ||
}, | ||
{ | ||
"name": "Arnar Bjarni Arnarson" | ||
"name": "Murray Tannock" | ||
}, | ||
{ | ||
"affiliation": "Reykjavik University", | ||
"name": "Sigurjón Ingi Jónsson" | ||
} | ||
"name": "Henning Ulfarsson" | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from permuta.enumeration_strategies.abstract_strategy import EnumerationStrategy | ||
from permuta.permutils.pin_words import PinWords | ||
|
||
|
||
class FinitelyManySimplesStrategy(EnumerationStrategy): | ||
"""Enumeration strategies related to the class having finitely many simple | ||
permutations.""" | ||
|
||
def applies(self) -> bool: | ||
return PinWords.has_finite_simples(self.basis) | ||
|
||
@classmethod | ||
def reference(cls) -> str: | ||
return "The class contains only finitely many simple permutations" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import itertools | ||
|
||
from permuta import Perm | ||
|
||
|
||
class Bijections: | ||
"""A collection of known bijections.""" | ||
|
||
# pylint: disable=too-few-public-methods | ||
|
||
@staticmethod | ||
def simion_and_schmidt(perm: Perm, inverse: bool = False) -> Perm: | ||
"""The bijection from `Restricted permutations` by R. Simion and F. Schmidt | ||
between Av(123) and Av(132). | ||
""" | ||
n = len(perm) | ||
if n == 0: | ||
return Perm() | ||
if inverse: | ||
if perm.contains(Perm((0, 2, 1))): | ||
raise ValueError("Map only works for 132 avoiding permutations") | ||
return Bijections._simion_and_schmidt_inv(perm, n) | ||
if perm.contains(Perm((0, 1, 2))): | ||
raise ValueError("Map only works for 123 avoiding permutations") | ||
return Bijections._simion_and_schmidt(perm, n) | ||
|
||
@staticmethod | ||
def _simion_and_schmidt(perm: Perm, n: int) -> Perm: | ||
used, img, min_val = {perm[0]}, [perm[0]] * n, perm[0] | ||
for idx, val in itertools.islice(enumerate(perm), 1, None): | ||
if min_val > val: # val is L2R minima | ||
img[idx], min_val = val, val | ||
else: | ||
img[idx] = next(k for k in range(min_val + 1, n) if k not in used) | ||
used.add(img[idx]) | ||
return Perm(img) | ||
|
||
@staticmethod | ||
def _simion_and_schmidt_inv(perm: Perm, n: int) -> Perm: | ||
used, img, min_val = {perm[0]}, [perm[0]] * n, perm[0] | ||
for idx, val in itertools.islice(enumerate(perm), 1, None): | ||
if min_val > val: # val is L2R minima | ||
img[idx], min_val = val, val | ||
else: | ||
img[idx] = next(k for k in range(n - 1, -1, -1) if k not in used) | ||
used.add(img[idx]) | ||
return Perm(img) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.