%global _empty_manifest_terminate_build 0 Name: python-permuta Version: 2.2.0 Release: 1 Summary: A comprehensive high performance permutation library. License: BSD-3 URL: https://github.com/PermutaTriangle/Permuta Source0: https://mirrors.nju.edu.cn/pypi/web/packages/80/6a/f4e241c4aaf7d13cbc4d14c40f9f976104742fe3b262cd5b6fcee3c0c7b0/permuta-2.2.0.tar.gz BuildArch: noarch %description To install Permuta on your system, run: pip install permuta It is also possible to install Permuta in development mode to work on the source code, in which case you run the following after cloning the repository: ./setup.py develop To run the unit tests: pip install -r test_requirements.txt ./setup.py test Using Permuta ############# Once you've installed Permuta, it can be imported by a Python script or an interactive Python session, just like any other Python library: >>> from permuta import * Importing ``*`` from it supplies you with the 'Perm' and 'PermSet' classes along with the 'AvoidanceClass' class (with alias 'Av') for generating perms avoiding a set of patterns. It also gives you the 'MeshPatt' class and some other submodules which we will not discuss in this readme. Creating a single perm ###################### Permutations are zero-based in Permuta and can be created using any iterable. >>> Perm() # Empty perm Perm(()) >>> Perm([]) # Another empty perm Perm(()) >>> Perm((0, 1, 2, 3)) # The zero-based version of 1234 Perm((0, 1, 2, 3)) >>> Perm((2, 1, 3)) # Warning: it will initialise with any iterable Perm((2, 1, 3)) Permutations can also be created using some specific class methods. >>> Perm.from_string("201") # strings Perm((2, 0, 1)) >>> Perm.one_based((1, 3, 2, 4)) # one-based iterable of integers Perm((0, 2, 1, 3)) >>> Perm.to_standard("a2gsv3") # standardising any iterable using '<' Perm((2, 0, 3, 4, 5, 1)) >>> Perm.from_integer(210) # an integer between 0 and 9876543210 Perm((2, 1, 0)) >>> Perm.from_integer(321) # any integer given is standardised Perm((2, 1, 0)) >>> Perm.from_integer(201) Perm((2, 0, 1)) Printing perms gives zero-based strings. >>> print(Perm(())) ε >>> print(Perm((2, 1, 0))) 210 >>> print(Perm((6, 2, 10, 9, 3, 8, 0, 1, 5, 11, 4, 7))) (6)(2)(10)(9)(3)(8)(0)(1)(5)(11)(4)(7) The avoids, contains, and occurrence methods enable working with patterns: >>> p = Perm((0,2,1,3)) >>> p.contains(Perm((2, 1, 0))) False >>> p.avoids(Perm((0, 1))) False >>> list(p.occurrences_of(Perm((1, 0)))) [(1, 2)] >>> list(Perm((0, 1)).occurrences_in(p)) [(0, 1), (0, 2), (0, 3), (1, 3), (2, 3)] The basic symmetries are implemented: >>> [p.reverse(), p.complement(), p.inverse()] [Perm((3, 1, 2, 0)), Perm((3, 1, 2, 0)), Perm((0, 2, 1, 3))] To take direct sums and skew sums we use ``+`` and ``-``: >>> q = Perm((0, 1, 2, 3, 4)) >>> p + q Perm((0, 2, 1, 3, 4, 5, 6, 7, 8)) >>> p - q Perm((5, 7, 6, 8, 0, 1, 2, 3, 4)) There are numerous practical methods available: >>> list(p.fixed_points()) [0, 3] >>> list(p.ascents()) [0, 2] >>> list(p.descents()) [1] >>> list(p.inversions()) [(1, 2)] >>> p.major_index() 2 Creating a perm class ##################### Perm classes are specified with a basis: >>> basis = Basis(Perm((1, 0, 2)), Perm((1, 2, 0))) >>> basis Basis((Perm((1, 0, 2)), Perm((1, 2, 0)))) >>> perm_class = Av(basis) >>> perm_class Av(Basis((Perm((1, 0, 2)), Perm((1, 2, 0))))) You can ask whether a perm belongs to the perm class: >>> Perm((3, 2, 1, 0)) in perm_class True >>> Perm((0, 2, 1, 3)) in perm_class False You can get its enumeration up to a fixed length. >>> perm_class.enumeration(10) [1, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512] >>> perm_class.count(11) 1024 You can also look to see if some well know enumeration strategies apply to a given class. >>> from permuta.enumeration_strategies import find_strategies >>> basis = [Perm((3, 2, 0, 1)), Perm((1, 0, 2, 3))] >>> for strat in find_strategies(basis): The insertion encoding of permutations: Corollary 10 >>> basis = [Perm((1, 2, 0, 3)), Perm((2, 0, 1, 3)), Perm((0, 1, 2, 3))] >>> for strat in find_strategies(basis): Enumeration of Permutation Classes and Weighted Labelled Independent Sets: Corollary 4.3 Permutation statistics ###################### With the ``PermutationStatistic`` class we can look for distributions of statistics for classes and look for statistics preservations (or transformation) either for two classes or given a bijection. First we need to import it. >>> from permuta.permutils.statistics import PermutationStatistic To see a distribution for a given statistic we grab its instance and provide a length and a class (no class will use the set of all permutations). >>> PermutationStatistic.show_predefined_statistics() # Show all statistics with id [0] Number of inversions [1] Number of non-inversions [2] Major index [3] Number of descents [4] Number of ascents [5] Number of peaks [6] Number of valleys [7] Number of cycles [8] Number of left-to-right minimas [9] Number of left-to-right maximas [10] Number of right-to-left minimas [11] Number of right-to-left maximas [12] Number of fixed points [13] Order [14] Longest increasing subsequence [15] Longest decreasing subsequence [16] Depth [17] Number of bounces [18] Maximum drop size [19] Number of primes in the column sums [20] Holeyness of a permutation [21] Number of stack-sorts needed [22] Number of pop-stack-sorts needed [23] Number of pinnacles [24] Number of cyclic peaks [25] Number of cyclic valleys [26] Number of double excedance [27] Number of double drops [28] Number of foremaxima [29] Number of afterminima [30] Number of aftermaxima [31] Number of foreminima >>> depth = PermutationStatistic.get_by_index(16) >>> depth.distribution_for_length(5) [1, 4, 12, 24, 35, 24, 20] >>> depth.distribution_up_to(4, Av.from_string("123")) [[1], [1], [1, 1], [0, 2, 3], [0, 0, 3, 7, 4]] Given a bijection as a dictionary, we can check which statistics are preserved with ``check_all_preservations`` and which are transformed with ``check_all_transformed`` >>> bijection = {p: p.reverse() for p in Perm.up_to_length(5)} >>> for stat in PermutationStatistic.check_all_preservations(bijection): Number of peaks Number of valleys Holeyness of a permutation Number of pinnacles We can find all (predefined) statistics equally distributed over two permutation classes with ``equally_distributed``. We also support checks for joint distribution of more than one statistics with ``jointly_equally_distributed`` and transformation of jointly distributed stats with ``jointly_transformed_equally_distributed``. >>> cls1 = Av.from_string("2143,415263") >>> cls2 = Av.from_string("3142") >>> for stat in PermutationStatistic.equally_distributed(cls1, cls2, 6): Major index Number of descents Number of ascents Number of peaks Number of valleys Number of left-to-right minimas Number of right-to-left maximas Longest increasing subsequence Longest decreasing subsequence Number of pinnacles %package -n python3-permuta Summary: A comprehensive high performance permutation library. Provides: python-permuta BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-permuta To install Permuta on your system, run: pip install permuta It is also possible to install Permuta in development mode to work on the source code, in which case you run the following after cloning the repository: ./setup.py develop To run the unit tests: pip install -r test_requirements.txt ./setup.py test Using Permuta ############# Once you've installed Permuta, it can be imported by a Python script or an interactive Python session, just like any other Python library: >>> from permuta import * Importing ``*`` from it supplies you with the 'Perm' and 'PermSet' classes along with the 'AvoidanceClass' class (with alias 'Av') for generating perms avoiding a set of patterns. It also gives you the 'MeshPatt' class and some other submodules which we will not discuss in this readme. Creating a single perm ###################### Permutations are zero-based in Permuta and can be created using any iterable. >>> Perm() # Empty perm Perm(()) >>> Perm([]) # Another empty perm Perm(()) >>> Perm((0, 1, 2, 3)) # The zero-based version of 1234 Perm((0, 1, 2, 3)) >>> Perm((2, 1, 3)) # Warning: it will initialise with any iterable Perm((2, 1, 3)) Permutations can also be created using some specific class methods. >>> Perm.from_string("201") # strings Perm((2, 0, 1)) >>> Perm.one_based((1, 3, 2, 4)) # one-based iterable of integers Perm((0, 2, 1, 3)) >>> Perm.to_standard("a2gsv3") # standardising any iterable using '<' Perm((2, 0, 3, 4, 5, 1)) >>> Perm.from_integer(210) # an integer between 0 and 9876543210 Perm((2, 1, 0)) >>> Perm.from_integer(321) # any integer given is standardised Perm((2, 1, 0)) >>> Perm.from_integer(201) Perm((2, 0, 1)) Printing perms gives zero-based strings. >>> print(Perm(())) ε >>> print(Perm((2, 1, 0))) 210 >>> print(Perm((6, 2, 10, 9, 3, 8, 0, 1, 5, 11, 4, 7))) (6)(2)(10)(9)(3)(8)(0)(1)(5)(11)(4)(7) The avoids, contains, and occurrence methods enable working with patterns: >>> p = Perm((0,2,1,3)) >>> p.contains(Perm((2, 1, 0))) False >>> p.avoids(Perm((0, 1))) False >>> list(p.occurrences_of(Perm((1, 0)))) [(1, 2)] >>> list(Perm((0, 1)).occurrences_in(p)) [(0, 1), (0, 2), (0, 3), (1, 3), (2, 3)] The basic symmetries are implemented: >>> [p.reverse(), p.complement(), p.inverse()] [Perm((3, 1, 2, 0)), Perm((3, 1, 2, 0)), Perm((0, 2, 1, 3))] To take direct sums and skew sums we use ``+`` and ``-``: >>> q = Perm((0, 1, 2, 3, 4)) >>> p + q Perm((0, 2, 1, 3, 4, 5, 6, 7, 8)) >>> p - q Perm((5, 7, 6, 8, 0, 1, 2, 3, 4)) There are numerous practical methods available: >>> list(p.fixed_points()) [0, 3] >>> list(p.ascents()) [0, 2] >>> list(p.descents()) [1] >>> list(p.inversions()) [(1, 2)] >>> p.major_index() 2 Creating a perm class ##################### Perm classes are specified with a basis: >>> basis = Basis(Perm((1, 0, 2)), Perm((1, 2, 0))) >>> basis Basis((Perm((1, 0, 2)), Perm((1, 2, 0)))) >>> perm_class = Av(basis) >>> perm_class Av(Basis((Perm((1, 0, 2)), Perm((1, 2, 0))))) You can ask whether a perm belongs to the perm class: >>> Perm((3, 2, 1, 0)) in perm_class True >>> Perm((0, 2, 1, 3)) in perm_class False You can get its enumeration up to a fixed length. >>> perm_class.enumeration(10) [1, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512] >>> perm_class.count(11) 1024 You can also look to see if some well know enumeration strategies apply to a given class. >>> from permuta.enumeration_strategies import find_strategies >>> basis = [Perm((3, 2, 0, 1)), Perm((1, 0, 2, 3))] >>> for strat in find_strategies(basis): The insertion encoding of permutations: Corollary 10 >>> basis = [Perm((1, 2, 0, 3)), Perm((2, 0, 1, 3)), Perm((0, 1, 2, 3))] >>> for strat in find_strategies(basis): Enumeration of Permutation Classes and Weighted Labelled Independent Sets: Corollary 4.3 Permutation statistics ###################### With the ``PermutationStatistic`` class we can look for distributions of statistics for classes and look for statistics preservations (or transformation) either for two classes or given a bijection. First we need to import it. >>> from permuta.permutils.statistics import PermutationStatistic To see a distribution for a given statistic we grab its instance and provide a length and a class (no class will use the set of all permutations). >>> PermutationStatistic.show_predefined_statistics() # Show all statistics with id [0] Number of inversions [1] Number of non-inversions [2] Major index [3] Number of descents [4] Number of ascents [5] Number of peaks [6] Number of valleys [7] Number of cycles [8] Number of left-to-right minimas [9] Number of left-to-right maximas [10] Number of right-to-left minimas [11] Number of right-to-left maximas [12] Number of fixed points [13] Order [14] Longest increasing subsequence [15] Longest decreasing subsequence [16] Depth [17] Number of bounces [18] Maximum drop size [19] Number of primes in the column sums [20] Holeyness of a permutation [21] Number of stack-sorts needed [22] Number of pop-stack-sorts needed [23] Number of pinnacles [24] Number of cyclic peaks [25] Number of cyclic valleys [26] Number of double excedance [27] Number of double drops [28] Number of foremaxima [29] Number of afterminima [30] Number of aftermaxima [31] Number of foreminima >>> depth = PermutationStatistic.get_by_index(16) >>> depth.distribution_for_length(5) [1, 4, 12, 24, 35, 24, 20] >>> depth.distribution_up_to(4, Av.from_string("123")) [[1], [1], [1, 1], [0, 2, 3], [0, 0, 3, 7, 4]] Given a bijection as a dictionary, we can check which statistics are preserved with ``check_all_preservations`` and which are transformed with ``check_all_transformed`` >>> bijection = {p: p.reverse() for p in Perm.up_to_length(5)} >>> for stat in PermutationStatistic.check_all_preservations(bijection): Number of peaks Number of valleys Holeyness of a permutation Number of pinnacles We can find all (predefined) statistics equally distributed over two permutation classes with ``equally_distributed``. We also support checks for joint distribution of more than one statistics with ``jointly_equally_distributed`` and transformation of jointly distributed stats with ``jointly_transformed_equally_distributed``. >>> cls1 = Av.from_string("2143,415263") >>> cls2 = Av.from_string("3142") >>> for stat in PermutationStatistic.equally_distributed(cls1, cls2, 6): Major index Number of descents Number of ascents Number of peaks Number of valleys Number of left-to-right minimas Number of right-to-left maximas Longest increasing subsequence Longest decreasing subsequence Number of pinnacles %package help Summary: Development documents and examples for permuta Provides: python3-permuta-doc %description help To install Permuta on your system, run: pip install permuta It is also possible to install Permuta in development mode to work on the source code, in which case you run the following after cloning the repository: ./setup.py develop To run the unit tests: pip install -r test_requirements.txt ./setup.py test Using Permuta ############# Once you've installed Permuta, it can be imported by a Python script or an interactive Python session, just like any other Python library: >>> from permuta import * Importing ``*`` from it supplies you with the 'Perm' and 'PermSet' classes along with the 'AvoidanceClass' class (with alias 'Av') for generating perms avoiding a set of patterns. It also gives you the 'MeshPatt' class and some other submodules which we will not discuss in this readme. Creating a single perm ###################### Permutations are zero-based in Permuta and can be created using any iterable. >>> Perm() # Empty perm Perm(()) >>> Perm([]) # Another empty perm Perm(()) >>> Perm((0, 1, 2, 3)) # The zero-based version of 1234 Perm((0, 1, 2, 3)) >>> Perm((2, 1, 3)) # Warning: it will initialise with any iterable Perm((2, 1, 3)) Permutations can also be created using some specific class methods. >>> Perm.from_string("201") # strings Perm((2, 0, 1)) >>> Perm.one_based((1, 3, 2, 4)) # one-based iterable of integers Perm((0, 2, 1, 3)) >>> Perm.to_standard("a2gsv3") # standardising any iterable using '<' Perm((2, 0, 3, 4, 5, 1)) >>> Perm.from_integer(210) # an integer between 0 and 9876543210 Perm((2, 1, 0)) >>> Perm.from_integer(321) # any integer given is standardised Perm((2, 1, 0)) >>> Perm.from_integer(201) Perm((2, 0, 1)) Printing perms gives zero-based strings. >>> print(Perm(())) ε >>> print(Perm((2, 1, 0))) 210 >>> print(Perm((6, 2, 10, 9, 3, 8, 0, 1, 5, 11, 4, 7))) (6)(2)(10)(9)(3)(8)(0)(1)(5)(11)(4)(7) The avoids, contains, and occurrence methods enable working with patterns: >>> p = Perm((0,2,1,3)) >>> p.contains(Perm((2, 1, 0))) False >>> p.avoids(Perm((0, 1))) False >>> list(p.occurrences_of(Perm((1, 0)))) [(1, 2)] >>> list(Perm((0, 1)).occurrences_in(p)) [(0, 1), (0, 2), (0, 3), (1, 3), (2, 3)] The basic symmetries are implemented: >>> [p.reverse(), p.complement(), p.inverse()] [Perm((3, 1, 2, 0)), Perm((3, 1, 2, 0)), Perm((0, 2, 1, 3))] To take direct sums and skew sums we use ``+`` and ``-``: >>> q = Perm((0, 1, 2, 3, 4)) >>> p + q Perm((0, 2, 1, 3, 4, 5, 6, 7, 8)) >>> p - q Perm((5, 7, 6, 8, 0, 1, 2, 3, 4)) There are numerous practical methods available: >>> list(p.fixed_points()) [0, 3] >>> list(p.ascents()) [0, 2] >>> list(p.descents()) [1] >>> list(p.inversions()) [(1, 2)] >>> p.major_index() 2 Creating a perm class ##################### Perm classes are specified with a basis: >>> basis = Basis(Perm((1, 0, 2)), Perm((1, 2, 0))) >>> basis Basis((Perm((1, 0, 2)), Perm((1, 2, 0)))) >>> perm_class = Av(basis) >>> perm_class Av(Basis((Perm((1, 0, 2)), Perm((1, 2, 0))))) You can ask whether a perm belongs to the perm class: >>> Perm((3, 2, 1, 0)) in perm_class True >>> Perm((0, 2, 1, 3)) in perm_class False You can get its enumeration up to a fixed length. >>> perm_class.enumeration(10) [1, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512] >>> perm_class.count(11) 1024 You can also look to see if some well know enumeration strategies apply to a given class. >>> from permuta.enumeration_strategies import find_strategies >>> basis = [Perm((3, 2, 0, 1)), Perm((1, 0, 2, 3))] >>> for strat in find_strategies(basis): The insertion encoding of permutations: Corollary 10 >>> basis = [Perm((1, 2, 0, 3)), Perm((2, 0, 1, 3)), Perm((0, 1, 2, 3))] >>> for strat in find_strategies(basis): Enumeration of Permutation Classes and Weighted Labelled Independent Sets: Corollary 4.3 Permutation statistics ###################### With the ``PermutationStatistic`` class we can look for distributions of statistics for classes and look for statistics preservations (or transformation) either for two classes or given a bijection. First we need to import it. >>> from permuta.permutils.statistics import PermutationStatistic To see a distribution for a given statistic we grab its instance and provide a length and a class (no class will use the set of all permutations). >>> PermutationStatistic.show_predefined_statistics() # Show all statistics with id [0] Number of inversions [1] Number of non-inversions [2] Major index [3] Number of descents [4] Number of ascents [5] Number of peaks [6] Number of valleys [7] Number of cycles [8] Number of left-to-right minimas [9] Number of left-to-right maximas [10] Number of right-to-left minimas [11] Number of right-to-left maximas [12] Number of fixed points [13] Order [14] Longest increasing subsequence [15] Longest decreasing subsequence [16] Depth [17] Number of bounces [18] Maximum drop size [19] Number of primes in the column sums [20] Holeyness of a permutation [21] Number of stack-sorts needed [22] Number of pop-stack-sorts needed [23] Number of pinnacles [24] Number of cyclic peaks [25] Number of cyclic valleys [26] Number of double excedance [27] Number of double drops [28] Number of foremaxima [29] Number of afterminima [30] Number of aftermaxima [31] Number of foreminima >>> depth = PermutationStatistic.get_by_index(16) >>> depth.distribution_for_length(5) [1, 4, 12, 24, 35, 24, 20] >>> depth.distribution_up_to(4, Av.from_string("123")) [[1], [1], [1, 1], [0, 2, 3], [0, 0, 3, 7, 4]] Given a bijection as a dictionary, we can check which statistics are preserved with ``check_all_preservations`` and which are transformed with ``check_all_transformed`` >>> bijection = {p: p.reverse() for p in Perm.up_to_length(5)} >>> for stat in PermutationStatistic.check_all_preservations(bijection): Number of peaks Number of valleys Holeyness of a permutation Number of pinnacles We can find all (predefined) statistics equally distributed over two permutation classes with ``equally_distributed``. We also support checks for joint distribution of more than one statistics with ``jointly_equally_distributed`` and transformation of jointly distributed stats with ``jointly_transformed_equally_distributed``. >>> cls1 = Av.from_string("2143,415263") >>> cls2 = Av.from_string("3142") >>> for stat in PermutationStatistic.equally_distributed(cls1, cls2, 6): Major index Number of descents Number of ascents Number of peaks Number of valleys Number of left-to-right minimas Number of right-to-left maximas Longest increasing subsequence Longest decreasing subsequence Number of pinnacles %prep %autosetup -n permuta-2.2.0 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-permuta -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Tue May 30 2023 Python_Bot - 2.2.0-1 - Package Spec generated