permutatriangle / permuta Goto Github PK
View Code? Open in Web Editor NEWA native Python library for permutation pattern research
License: BSD 3-Clause "New" or "Revised" License
A native Python library for permutation pattern research
License: BSD 3-Clause "New" or "Revised" License
Ideally make it automatically update when something is pushed.
Travis allows you to test on Windows. We should do it https://docs.travis-ci.com/user/reference/windows/
Mesh patterns should order according to
Perm
ordering)Currently 1) is implemented but not 2). Example:
>>> from permuta import *
>>> p = Perm((0, 1, 2))
>>> q = Perm((1, 0, 2))
>>> p < q
True
>>> MeshPatt(p, [(1, 1)]) < MeshPatt(q, [(2, 2)])
True
>>> mp1 = MeshPatt(p, [(1, 1)])
>>> mp2 = MeshPatt(p, [(2, 2)])
>>> mp1 < mp2
False
>>> mp2 >= mp1
False
If you want to compute the permutation in a lot of classes. The cache get too big and fill the memory. A workaround is to use the above code snippet to clear the cache.
from permuta._perm_set.unbounded.described.avoiding.avoiding import AvoidingGeneric
AvoidingGeneric._AvoidingGeneric__CLASS_CACHE = {}
Of course something better should be implemented.
Should we not add a description on how to use pip to install this?
That's how I run it in my virtualenv.
I'd like to be able to use p.show()
to show the permutation p on screen (ascii style), possibly with options to show it in a browser, plot window or whatever.
Additionally p.export(format=svg)
, p.export(format=tikz)
etc. for exporting permutations to use in other contexts.
I just realized that our generic Avoidance Class is very basic at the moment; just inserting a new maximum in every possible place and checking for avoidance. We should be remembering viable insertion indices. And maybe we could use Kuszmaul's methods to speed us up some. Implementing these should be very simple, and shouldn't take but a day, with some performance considerations.
from permuta import *
from permuta.bisc import *
from permuta.bisc.permsets.perm_properties import stack_sortable
causes an error.
Not too important, but it would be cool to implement the O(n) version for Permutation._left_to_right_details
The BibTeX link at the bottom of the readme does not link to the newest version of the library.
Because Perm
s and MeshPatt
s can't be compared in sorting, a basis cannot consist of a mix of both object types. See below for example:
>>> from permuta import *
>>> Av({Perm((0, 1)), MeshPatt(Perm((1, 0)), [])})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/bjarni/.venvs/CombCov/lib/python3.7/site-packages/permuta/permset.py", line 99, in __new__
return PermSet.avoiding(basis)
File "/Users/bjarni/.venvs/CombCov/lib/python3.7/site-packages/permuta/permset.py", line 75, in avoiding
return cls(BasisCls(basis))
File "/Users/bjarni/.venvs/CombCov/lib/python3.7/site-packages/permuta/descriptors/basis.py", line 19, in __new__
return tuple.__new__(cls).union(patts, cls.ALLOWED_BASIS_ELEMENT_TYPES)
File "/Users/bjarni/.venvs/CombCov/lib/python3.7/site-packages/permuta/descriptors/basis.py", line 42, in union
patts = sorted(patts) # Necessarily non-empty
File "/Users/bjarni/.venvs/CombCov/lib/python3.7/site-packages/permuta/perm.py", line 2215, in __lt__
return (len(self), tuple(self)) < (len(other), tuple(other))
TypeError: object of type 'int' has no len()
Possible fixes includes
(1) implementing the comparator on the level of the abstract interface Patt
so that Perm
s and MeshPatt
s can be compared or
(2) convert Perm
s to MeshPatt
s in the basis if at least one of the elements is a MeshPatt
.
If you run this code
from permuta import Perm
p = Perm((0,1,2))
p.sum_indecomposable_sequence()
You get
Traceback (most recent call last):
File "bug.py", line 4, in <module>
p.sum_indecomposable_sequence()
File "/home/enadeau/repos/Permuta/permuta/perm.py", line 1744, in sum_indecomposable_sequence
S = self.downset()
AttributeError: 'Perm' object has no attribute 'downset'
I'm not sure what this function is supposed to do, but we should fix that.
I tried adding images to the readme when I added the demo branch, and it simply didn't work. AND for some reason the Travis CI badge doesn't even show up anymore either!
I just found out about the debug constant in python which is apparently used to optimize away things away. So for example, the loop in
for n in range(10000):
if __debug__:
print(n)
will be completely removed from the code if compiled with the optimize flag.
We could use this for our Perm constructor and whatnot. That is, only do the expensive sanity checks on the input to the constructor if debug is True.
Sources:
A StackOverflow question
Another one
I haven't gone throught the docs properly yet, but word on the SO-street is that it is da bomb
It would be good to make polynomial classes an enumeration strategy so that it gets integrated in the cli when we implement #117
As title says. We have the "all clear" to remove these. Mostly they are un-pythonic synonyms that clutter up the source code.
Use the github python gitignore template, plz
It's nice
The json files for the bisc algorithm aren't included with the package on pypi.
This code
from permuta import *
p = Perm((0,1,2,3))
enum = [len(Av(p).of_length(n)) for n in range(8)]
E = MeshPatt(Perm((0,1,2)), [(0,0), (0,1), (1,0)])
F = MeshPatt(Perm((0,1,2)), [(3,3), (3,2), (2,3)])
print(E.ascii_plot())
print(F.ascii_plot())
for n in range(8):
c = 0
for p in Av(p).of_length(n):
print(p)
if not E.contained_in(p) and not F.contained_in(p):
c += 1
print(c)
print(enum)
Print that
| | |
-+-+-●-
| | |
-+-●-+-
▒| | |
-●-+-+-
▒|▒| |
| |▒|▒
-+-+-●-
| | |▒
-+-●-+-
| | |
-●-+-+-
| | |
ε
1
0
0
0
0
0
0
0
[1, 1, 2, 6, 23, 103, 513, 2761]
Need to fix that
Separate logic and "interface" (output) in BiSC and move the latter to cli.py
.
The file permuta/bisc/permsets/perm_properties.py
import some stuff from sympy
but sympy
is not listed as a dependency in the setup.py
. For the next release we need to either add sympy
as dependency of remove it from perm_properties.py
.
It would be helpful to link up all of our enumeration strategies to the cli so that permtools can be our first go to when enumerating classes. Currently, it only checks for regular insertion encodings.
It is time Henning made the description a bit more professional ;)
sorted([Perm((1, 0)), 5])
raises RecursionError: maximum recursion depth exceeded in comparison
rather than TypeError: no viable comparison between types permuta.Perm and int
(or something like that)
Add an Avoiders class to permuta.permutation_sets. It should take in a pattern (or a set of patterns) and some length (or a lower and an upper bound), and iterating through that class should give all permutations of the given length that avoid the specified patterns.
This should either replace the PermutationsAvoiding* classes in permuta.permutation_sets, or they should be merged into the Avoiders class as faster methods for specific patterns.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.