diff -Nru pplpy-0.8.4/CHANGES.txt pplpy-0.8.7/CHANGES.txt --- pplpy-0.8.4/CHANGES.txt 2019-01-29 19:09:27.000000000 +0000 +++ pplpy-0.8.7/CHANGES.txt 2021-01-20 18:47:15.000000000 +0000 @@ -3,6 +3,8 @@ - some more support for PPL objects: permute_space_dimensions, Bit_Row, Bit_Matrix - upgrade gmpy2 version dependency + - add pyproject.toml and setup.cfg files + - remove the OK functions which caused trouble for clang on FreeBSD v0.7, 2017/11/24 - use of gmpy2 for integers and rationals (Vincent Delecroix/Vincent Klein) - tests on travis (Vincent Delecroix/Vincent Klein) diff -Nru pplpy-0.8.4/debian/changelog pplpy-0.8.7/debian/changelog --- pplpy-0.8.4/debian/changelog 2020-12-07 17:21:59.000000000 +0000 +++ pplpy-0.8.7/debian/changelog 2021-01-29 08:14:39.000000000 +0000 @@ -1,14 +1,14 @@ -pplpy (0.8.4-4build2) hirsute; urgency=medium +pplpy (0.8.7-1) unstable; urgency=medium - * No-change rebuild to drop python3.8 extensions. + * New upstream release. + * Bump debhelper-compat level to 13. + * Bump standards-version to 4.5.1. + * Declare d/rules doesn't require root. + * Drop upstreamed patches and update remaining one. + * Add an upstream metadata file. + * Add missing depends on gmpy2. - -- Matthias Klose Mon, 07 Dec 2020 18:21:59 +0100 - -pplpy (0.8.4-4build1) hirsute; urgency=medium - - * No-change rebuild to build with python3.9 as supported. - - -- Matthias Klose Mon, 26 Oct 2020 13:44:21 +0100 + -- Julien Puydt Fri, 29 Jan 2021 09:14:39 +0100 pplpy (0.8.4-4) unstable; urgency=medium diff -Nru pplpy-0.8.4/debian/control pplpy-0.8.7/debian/control --- pplpy-0.8.4/debian/control 2020-02-24 20:30:27.000000000 +0000 +++ pplpy-0.8.7/debian/control 2021-01-29 08:14:39.000000000 +0000 @@ -4,7 +4,7 @@ Maintainer: Debian Science Team Uploaders: Tobias Hansen , Julien Puydt Build-Depends: - debhelper-compat (= 12), + debhelper-compat (= 13), dh-python (>= 3.20180313), cython3 (>= 0.26), libgmp-dev, @@ -18,14 +18,15 @@ python3-gmpy2, python3-setuptools, python3-sphinx, -Standards-Version: 4.5.0 +Standards-Version: 4.5.1 Homepage: https://gitlab.com/videlec/pplpy Vcs-Git: https://salsa.debian.org/science-team/pplpy.git Vcs-Browser: https://salsa.debian.org/science-team/pplpy +Rules-Requires-Root: no Package: python3-ppl Architecture: any -Depends: ${python3:Depends}, ${shlibs:Depends}, ${misc:Depends}, python3-cysignals-pari +Depends: ${python3:Depends}, ${shlibs:Depends}, ${misc:Depends}, python3-cysignals-pari, python3-gmpy2 Description: Python interface to PPL -- Python 3 A Python interface to the C++ Parma Polyhedra Library (PPL), which allows computations with polyhedra and grids, like mixed diff -Nru pplpy-0.8.4/debian/patches/fix_doctest_32bit.patch pplpy-0.8.7/debian/patches/fix_doctest_32bit.patch --- pplpy-0.8.4/debian/patches/fix_doctest_32bit.patch 2020-02-24 20:30:27.000000000 +0000 +++ pplpy-0.8.7/debian/patches/fix_doctest_32bit.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -From 2201fa183c1a160b57b4d1eb35c41b6ac57c56aa Mon Sep 17 00:00:00 2001 -From: Vincent Delecroix -Date: Mon, 2 Sep 2019 15:24:17 +0200 -Subject: [PATCH] Fix Issue #20 - -On 32 bit architecture and Python2, the output of BHRZ03_widening_assign -and H79_widening_assign are long Python integers. We fix an issue with -doctests that do not match "0L" with "0". ---- - ppl/polyhedron.pyx | 22 ++++++++++++---------- - 1 file changed, 12 insertions(+), 10 deletions(-) - ---- a/ppl/polyhedron.pyx -+++ b/ppl/polyhedron.pyx -@@ -1615,13 +1615,14 @@ - >>> known_result = NNC_Polyhedron(2) - >>> known_result.add_constraint(y >= 0) - >>> known_result.add_constraint(y < 1) -- >>> tp = 1 -- >>> tp = ph2.BHRZ03_widening_assign(ph1, tp); tp -- 0 -+ >>> tp = ph2.BHRZ03_widening_assign(ph1, 1) -+ >>> tp == 0 -+ True - >>> ph2 == ph2_copy - True -- >>> tp = ph2.BHRZ03_widening_assign(ph1, tp); tp -- 0 -+ >>> tp = ph2.BHRZ03_widening_assign(ph1, 0) -+ >>> tp == 0 -+ True - >>> ph2 == known_result - True - """ -@@ -1815,13 +1816,14 @@ - >>> ph2_copy = C_Polyhedron(ph2) - >>> known_result = C_Polyhedron(2) - >>> known_result.add_constraint(y >= 0) -- >>> tp = 1 -- >>> tp = ph2.H79_widening_assign(ph1, tp); tp -- 0 -+ >>> tp = ph2.H79_widening_assign(ph1, 1) -+ >>> tp == 0 -+ True - >>> ph2 == ph2_copy - True -- >>> tp = ph2.H79_widening_assign(ph1, tp); tp -- 0 -+ >>> tp = ph2.H79_widening_assign(ph1, 0) -+ >>> tp == 0 -+ True - >>> ph2 == known_result - True - """ diff -Nru pplpy-0.8.4/debian/patches/fix_typos.patch pplpy-0.8.7/debian/patches/fix_typos.patch --- pplpy-0.8.4/debian/patches/fix_typos.patch 2020-02-24 20:30:27.000000000 +0000 +++ pplpy-0.8.7/debian/patches/fix_typos.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -Author: Julien Puydt -Description: Fix typos -Forwarded: yes - ---- pplpy.orig/ppl/linear_algebra.pyx -+++ pplpy/ppl/linear_algebra.pyx -@@ -956,7 +956,7 @@ - - def is_equal_to(self, Linear_Expression other): - """ -- Test equality with an other linear expression. -+ Test equality with another linear expression. - - OUTPUT: boolean - ---- pplpy.orig/ppl/polyhedron.pyx -+++ pplpy/ppl/polyhedron.pyx -@@ -1487,7 +1487,7 @@ - - .. note:: - -- The modified polyhedron is not neccessarily a lattice -+ The modified polyhedron is not necessarily a lattice - polyhedron; Some vertices will, in general, still be - rational. Lattice points interior to the polyhedron may be - lost in the process. -@@ -1595,7 +1595,7 @@ - True - - if this method is going to be called too many times, the -- ``tp`` parameter allows to reduce the computation cost by -+ ``tp`` parameter allows one to reduce the computation cost by - computing the widening only when ``tp`` is equal to 0, - otherwise the this method will decrement the value of ``tp`` - and return it. -@@ -1796,7 +1796,7 @@ - this->space_dimension() == 2, y.space_dimension() == 3. - - if this method is going to be called too many times, the -- ``tp`` parameter allows to reduce the computation cost by -+ ``tp`` parameter allows one to reduce the computation cost by - computing the widening only when ``tp`` is equal to 0, - otherwise the this method will decrement the value of ``tp`` - and return it. diff -Nru pplpy-0.8.4/debian/patches/local-mathjax.patch pplpy-0.8.7/debian/patches/local-mathjax.patch --- pplpy-0.8.4/debian/patches/local-mathjax.patch 2020-02-24 20:30:27.000000000 +0000 +++ pplpy-0.8.7/debian/patches/local-mathjax.patch 2021-01-29 08:14:39.000000000 +0000 @@ -1,6 +1,7 @@ Description: Use the local mathjax version We have to use the local copy of mathjax. Author: Tobias Hansen +Forwarded: Debian-specific --- a/docs/source/conf.py +++ b/docs/source/conf.py diff -Nru pplpy-0.8.4/debian/patches/series pplpy-0.8.7/debian/patches/series --- pplpy-0.8.4/debian/patches/series 2020-02-24 20:30:27.000000000 +0000 +++ pplpy-0.8.7/debian/patches/series 2021-01-29 08:14:39.000000000 +0000 @@ -1,3 +1 @@ local-mathjax.patch -fix_typos.patch -fix_doctest_32bit.patch diff -Nru pplpy-0.8.4/debian/upstream/metadata pplpy-0.8.7/debian/upstream/metadata --- pplpy-0.8.4/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ pplpy-0.8.7/debian/upstream/metadata 2021-01-29 08:14:39.000000000 +0000 @@ -0,0 +1,4 @@ +Bug-Database: https://gitlab.com/videlec/pplpy/issues +Bug-Submit: https://gitlab.com/videlec/pplpy/issues/new +Repository: https://gitlab.com/videlec/pplpy.git +Repository-Browse: https://gitlab.com/videlec/pplpy diff -Nru pplpy-0.8.4/debian/watch pplpy-0.8.7/debian/watch --- pplpy-0.8.4/debian/watch 2020-02-24 20:30:27.000000000 +0000 +++ pplpy-0.8.7/debian/watch 2021-01-29 08:14:39.000000000 +0000 @@ -1,2 +1,2 @@ version=4 -https://gitlab.com/videlec/pplpy/tags?sort=updated_desc .*/pplpy-@ANY_VERSION@.tar.bz2 +https://gitlab.com/videlec/pplpy/-/tags?sort=updated_desc .*/pplpy-@ANY_VERSION@.tar.bz2 diff -Nru pplpy-0.8.4/docs/Makefile pplpy-0.8.7/docs/Makefile --- pplpy-0.8.4/docs/Makefile 2019-02-14 21:08:53.000000000 +0000 +++ pplpy-0.8.7/docs/Makefile 2021-01-20 18:47:15.000000000 +0000 @@ -1,8 +1,9 @@ # Minimal makefile for Sphinx documentation -# +# NOTE: we removed the shortcut $(O) for passing options to +# sphinx-build as this is undocummented and sometimes +# confusing. # You can set these variables from the command line. -#SPHINXOPTS = SPHINXBUILD = sphinx-build SPHINXPROJ = pplpy SOURCEDIR = source @@ -10,11 +11,11 @@ # Put it first so that "make" without argument is like "make help". help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) .PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +# "make mode" option. %: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) diff -Nru pplpy-0.8.4/docs/source/conf.py pplpy-0.8.7/docs/source/conf.py --- pplpy-0.8.4/docs/source/conf.py 2019-02-14 22:06:33.000000000 +0000 +++ pplpy-0.8.7/docs/source/conf.py 2021-01-20 18:47:15.000000000 +0000 @@ -43,7 +43,16 @@ # built documents. # # The short X.Y version. -version = release = open('../../version.txt').read()[:-1] +import configparser +config = configparser.ConfigParser(allow_no_value=True) +try: + with open("../../setup.cfg", encoding='utf-8') as f: + config.read_string(f.read()) +except TypeError: + # NOTE: encoding is not a keyword in Python 2 + with open("../../setup.cfg") as f: + config.read_string(f.read().decode('utf-8')) +version = release = config['metadata']['version'] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. diff -Nru pplpy-0.8.4/docs/source/index.rst pplpy-0.8.7/docs/source/index.rst --- pplpy-0.8.4/docs/source/index.rst 2018-06-05 11:50:37.000000000 +0000 +++ pplpy-0.8.7/docs/source/index.rst 2021-01-20 18:47:15.000000000 +0000 @@ -111,3 +111,11 @@ :members: :undoc-members: :show-inheritance: + +Module `ppl.congruence` +----------------------- + +.. automodule:: ppl.congruence + :members: + :undoc-members: + :show-inheritance: diff -Nru pplpy-0.8.4/.gitignore pplpy-0.8.7/.gitignore --- pplpy-0.8.4/.gitignore 1970-01-01 00:00:00.000000000 +0000 +++ pplpy-0.8.7/.gitignore 2021-01-20 18:47:15.000000000 +0000 @@ -0,0 +1,19 @@ +build/* +ppl.so +ppl/*.c +ppl/*.cpp +ppl/*.so +ppl/cygmp/*.c +ppl/cygmp/*.cpp +ppl/cygmp/*.so +*.so +*.o +*.pyc +*.c +*.cpp +*.swp +dist/ +pplpy.egg-info/ +docs/build/ +.idea/* +/.tox diff -Nru pplpy-0.8.4/.gitlab-ci.yml pplpy-0.8.7/.gitlab-ci.yml --- pplpy-0.8.4/.gitlab-ci.yml 1970-01-01 00:00:00.000000000 +0000 +++ pplpy-0.8.7/.gitlab-ci.yml 2021-01-20 18:47:15.000000000 +0000 @@ -0,0 +1,47 @@ +image: ubuntu:18.04 +before_script: +- export DEBIAN_FRONTEND=noninteractive # avoid tzdata interactive configuration +- apt-get -qq update +- apt-get install -y apt-utils git libgmp-dev libmpfr-dev libmpc-dev libppl-dev $PKGS +- $PYTHON -m pip install --upgrade pip +# NOTE: currently it seems not possible to build the sdist without manually installing +# dependencies. pyproject.toml is ignored by the call to 'setup.py sdist' below and the +# install_requires of setuptools is broken with Cython. +- $PYTHON -m pip install setuptools wheel Cython cysignals sphinx "gmpy2>=2.1.0b1" +- $PYTHON setup.py sdist +- $PYTHON -m pip -v install dist/pplpy-*.tar.gz + +.template_script: + script: &test_script + # run tests + - $PYTHON setup.py test + # build documentation + - make -w -C docs html + +python2.7: + stage: test + variables: + PYTHON: python + PKGS: python-pip python-sphinx python-configparser + script: *test_script + +python3.6: + stage: test + variables: + PYTHON: python3 + PKGS: python3-pip python3-sphinx + script: *test_script + +python3.7: + stage: test + variables: + PYTHON: python3.7 + PKGS: python3.7 python3.7-dev python3-pip python3-sphinx + script: *test_script + +python3.8: + stage: test + variables: + PYTHON: python3.8 + PKGS: python3.8 python3.8-dev python3-pip python3-sphinx + script: *test_script diff -Nru pplpy-0.8.4/MANIFEST.in pplpy-0.8.7/MANIFEST.in --- pplpy-0.8.4/MANIFEST.in 2019-01-29 18:58:34.000000000 +0000 +++ pplpy-0.8.7/MANIFEST.in 2021-01-20 18:47:15.000000000 +0000 @@ -1,4 +1,4 @@ -include README.rst LICENSE.txt CHANGES.txt setup.py version.txt +include README.rst LICENSE.txt CHANGES.txt pyproject.toml setup.py setup.cfg tox.ini recursive-include ppl *.pxd *.pyx *.py recursive-include tests *.pyx *.py include ppl/ppl_shim.cc diff -Nru pplpy-0.8.4/PKG-INFO pplpy-0.8.7/PKG-INFO --- pplpy-0.8.4/PKG-INFO 2019-02-28 15:21:19.000000000 +0000 +++ pplpy-0.8.7/PKG-INFO 1970-01-01 00:00:00.000000000 +0000 @@ -1,143 +0,0 @@ -Metadata-Version: 1.1 -Name: pplpy -Version: 0.8.4 -Summary: Python PPL wrapper -Home-page: https://gitlab.com/videlec/pplpy -Author: Vincent Delecroix -Author-email: vincent.delecroix@labri.fr -License: GPL v3 -Download-URL: https://pypi.org/project/pplpy/#files -Description: PPL Python wrapper - ================== - - This Python package provides a wrapper to the C++ `Parma Polyhedra Library - (PPL) `_. - - The whole package started as a fork of a tiny part of the `Sage - `_ software. - - How it works - ------------ - - The names of objects and methods are the same as in the library: - - .. code:: python - - >>> import ppl - >>> x = ppl.Variable(0) - >>> y = ppl.Variable(1) - >>> z = ppl.Variable(2) - >>> cs = ppl.Constraint_System() - >>> cs.insert(x >= 0) - >>> cs.insert(y >= 0) - >>> cs.insert(z >= 0) - >>> cs.insert(x + y + z == 1) - >>> poly = ppl.C_Polyhedron(cs) - >>> poly.minimized_generators() - Generator_System {point(1/1, 0/1, 0/1), point(0/1, 1/1, 0/1), point(0/1, 0/1, 1/1)} - - The available objects and functions from the `ppl` Python module are: - - - `Variable`, `Variables_Set`, `Linear_Expression` (defined in `ppl.linear_algebra`) - - - `MIP_Problem` (defined in `ppl.mip_problem`) - - - `C_Polyhedron`, `NNC_Polyhedron` (defined in `ppl.polyhedron`) - - - `Generator`, `Generator_System`, `Poly_Gen_Relation`, `point`, - `closure_point`, `ray`, `line` (defined in `ppl.generator`) - - - `Constraint`, `Constraint_System`, `Poly_Con_Relation`, - `inequality`, `equation`, `strict_inequality` (defined in `ppl.constraint`) - - Installation - ------------ - - The project is available at `Python Package Index `_ and - can be installed with pip:: - - $ pip install pplpy - - Note that if you have gmp and ppl installed in a non standard directory (e.g. you use brew - on MacOSX) then you need to set appropriately the variables `CFLAGS` before calling `pip`. For - example:: - - $ export CFLAGS="-I/path/to/gmp/include/ -L/path/to/gmp/lib/ -I/path/to/ppl/include/ -L/path/to/ppl/lib $CFLAGS" - $ pip install pplpy - - Using from Cython - ----------------- - - All Python classes from pplpy are extension types and can be used with Cython. Each - extension type carries an attribute `thisptr` that holds a pointer to - the corresponding C++ object from ppl. - - A complete example is provided with the files `tests/testpplpy.pyx` and `tests/setup.py`. - - Source - ------ - - You can find the latest version of the source code on gitlab: - https://gitlab.com/videlec/pplpy - - Documentation - ------------- - - An online version of the documentation is available at http://www.labri.fr/perso/vdelecro/pplpy/latest/ - - Compiling the html documentation requires make and `sphinx `_. - Before building the documentation, you need to install the pplpy package (sphinx uses Python introspection). - The documentation source code is contained in the repository `docs` where there is a standard - Makefile with a target `html`. Running `make html` in the `docs` repository builds the documentation - inside `docs/build/html`. For more configuration options, run `make help`. - - License - ------- - - pplpy is distributed under the terms of the GNU General Public License (GPL) - published by the Free Software Foundation; either version 3 of - the License, or (at your option) any later version. See http://www.gnu.org/licenses/. - - Requirements - ------------ - - - `gmp `_ - - - `mpfr `_ - - - `mpc `_ - - - `PPL `_ - - - `Cython `_ - - - `cysignals `_ - - - `gmpy2 `_: version 2.1.0a4 from sources (see below) - - On Debian/Ubuntu systems these can be installed with:: - - $ sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev libppl-dev cython - $ pip install cysignals --user - $ pip install gmpy2==2.1.0a4 --user - - The pip optional option `--user` allows to install python packages for a single - user with no need for administrator rights. The two pip install commands might - be replaced by `sudo pip install PKG` (not recommanded). On recent Debian/Ubuntu systems, - cysignals is also available as a package under the name `python-cysignals` for - Python 2 and `python3-cysignals` for Python 3. - -Keywords: polyhedron,polytope,convex,mathematics,ppl,milp,linear-programming -Platform: any -Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3) -Classifier: Programming Language :: C++ -Classifier: Programming Language :: Python -Classifier: Development Status :: 3 - Alpha -Classifier: Operating System :: Unix -Classifier: Intended Audience :: Science/Research -Classifier: Programming Language :: Python :: 2 -Classifier: Programming Language :: Python :: 2.7 -Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.4 -Classifier: Programming Language :: Python :: 3.5 -Classifier: Programming Language :: Python :: 3.6 diff -Nru pplpy-0.8.4/ppl/bit_arrays.pyx pplpy-0.8.7/ppl/bit_arrays.pyx --- pplpy-0.8.4/ppl/bit_arrays.pyx 2019-02-28 15:16:26.000000000 +0000 +++ pplpy-0.8.7/ppl/bit_arrays.pyx 2021-01-20 18:47:15.000000000 +0000 @@ -61,19 +61,6 @@ """ raise TypeError("Bit_Row unhashable") - def OK(self): - r""" - Check if all the invariants are satisfied - - Examples: - - >>> from ppl import Bit_Row - >>> r = Bit_Row() - >>> r.OK() - True - """ - return self.thisptr.OK() - def set(self, unsigned long k): r""" Set the bit in position ``k`` diff -Nru pplpy-0.8.4/ppl/congruence.pxd pplpy-0.8.7/ppl/congruence.pxd --- pplpy-0.8.4/ppl/congruence.pxd 1970-01-01 00:00:00.000000000 +0000 +++ pplpy-0.8.7/ppl/congruence.pxd 2021-01-20 18:47:15.000000000 +0000 @@ -0,0 +1,9 @@ +from .ppl_decl cimport * + +cdef _wrap_Congruence(PPL_Congruence) + +cdef class Congruence(object): + cdef PPL_Congruence *thisptr + +cdef class Congruence_System(object): + cdef PPL_Congruence_System *thisptr diff -Nru pplpy-0.8.4/ppl/congruence.pyx pplpy-0.8.7/ppl/congruence.pyx --- pplpy-0.8.4/ppl/congruence.pyx 1970-01-01 00:00:00.000000000 +0000 +++ pplpy-0.8.7/ppl/congruence.pyx 2021-01-20 18:47:15.000000000 +0000 @@ -0,0 +1,346 @@ +# distutils: language = c++ +# distutils: libraries = gmp gmpxx ppl m +#***************************************************************************** +# Copyright (C) 2020 Vincent Delecroix +# +# Distributed under the terms of the GNU General Public License (GPL) +# as published by the Free Software Foundation; either version 3 of +# the License, or (at youroption) any later version. +# http://www.gnu.org/licenses/ +#***************************************************************************** +from __future__ import absolute_import, print_function + +from cython.operator cimport dereference as deref +from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE + +from gmpy2 cimport GMPy_MPZ_From_mpz, mpz, import_gmpy2, MPZ_Check + +from .constraint cimport Constraint +from .linear_algebra cimport Variable, Linear_Expression, PPL_Coefficient_from_pyobject + +import_gmpy2() + +def _dummy(): + raise ValueError + +cdef class Congruence(object): + r""" + Wrapper for PPL's ``Congruence`` class. + + >>> import ppl + >>> x = ppl.Variable(0) + >>> y = ppl.Variable(1) + >>> ppl.Congruence(x + 2*y - 1, 7) + x0+2*x1-1==0 (mod 7) + >>> ppl.Congruence(x + y == 2, 5) + x0+x1-2==0 (mod 5) + """ + def __init__(self, arg=None, mod=None): + if arg is None: + self.thisptr = new PPL_Congruence() + elif isinstance(arg, Congruence): + self.thisptr = new PPL_Congruence(( arg).thisptr[0]) + elif isinstance(arg, Variable): + self.thisptr = new PPL_Congruence() + if mod is None: + mod = mpz(1) + self.thisptr[0] = modulo(PPL_Linear_Expression(( arg).thisptr[0]), + PPL_Coefficient_from_pyobject(mod)) + elif isinstance(arg, Linear_Expression): + self.thisptr = new PPL_Congruence() + if mod is None: + mod = mpz(1) + self.thisptr[0] = modulo(( arg).thisptr[0], + PPL_Coefficient_from_pyobject(mod)) + elif isinstance(arg, Constraint): + self.thisptr = new PPL_Congruence(( arg).thisptr[0]) + if mod is None: + mod = mpz(1) + self.thisptr.set_modulus(PPL_Coefficient_from_pyobject(mod)) + else: + raise TypeError("invalid argument for Congruence") + + def __cinit__(self): + self.thisptr = NULL + + def __dealloc__(self): + del self.thisptr + + def is_equal(self, Congruence other): + r""" + Return whether ``self`` is equal to ``other``. + + Examples: + + >>> import ppl + >>> x = ppl.Variable(0) + >>> Congruence(x + 1, 3).is_equal(Congruence(x + 1, 3)) + True + >>> Congruence(x, 3).is_equal(Congruence(x - 2, 3)) + False + >>> Congruence(x, 3).is_equal(Congruence(x , 2)) + False + """ + return ( self).thisptr[0] == ( other).thisptr[0] + + def coefficient(self, v): + r""" + Return the coefficient ``v`` of this congruence. + + Examples: + + >>> import ppl + >>> x = ppl.Variable(0) + >>> y = ppl.Variable(1) + >>> c = (2 * x + y == 1) % 12 + >>> c.coefficient(0) + mpz(2) + >>> c.coefficient(x) + mpz(2) + + Note that contrarily to :class:`Linear_Expression` the congruences raise + an error when trying to access a coefficient beyond the dimension + + >>> c.coefficient(ppl.Variable(13)) + Traceback (most recent call last): + ... + ValueError: PPL::Congruence::coefficient(v): + this->space_dimension() == 2, v.space_dimension() == 14. + """ + cdef Variable vv + if type(v) is Variable: + vv = v + else: + vv = Variable(v) + return GMPy_MPZ_From_mpz(self.thisptr.coefficient(vv.thisptr[0]).get_mpz_t()) + + def coefficients(self): + r""" + Return the coefficients of this congruence as a tuple. + + Examples: + + >>> import ppl + >>> x = ppl.Variable(0) + >>> y = ppl.Variable(1) + >>> t = ppl.Variable(3) + >>> c = ppl.Congruence(x + 2*y + t - 1, 7) + >>> c.coefficients() + (mpz(1), mpz(2), mpz(0), mpz(1)) + """ + cdef int d = self.space_dimension() + cdef int i + coeffs = [] + for i in range(0,d): + coeffs.append(GMPy_MPZ_From_mpz(self.thisptr.coefficient(PPL_Variable(i)).get_mpz_t())) + return tuple(coeffs) + + def modulus(self): + r""" + Return the modulus of this congruence. + + Examples: + + >>> import ppl + >>> x = ppl.Variable(0) + >>> y = ppl.Variable(1) + >>> c = ppl.Congruence(x + 2*y - 3, 7) + >>> c.modulus() + mpz(7) + """ + return GMPy_MPZ_From_mpz(self.thisptr.modulus().get_mpz_t()) + + def inhomogeneous_term(self): + r""" + Return the inhomogeneous term of this congruence. + + Examples: + + >>> import ppl + >>> x = ppl.Variable(0) + >>> y = ppl.Variable(1) + >>> c = ppl.Congruence(x + 2*y - 3, 7) + >>> c.inhomogeneous_term() + mpz(-3) + """ + return GMPy_MPZ_From_mpz(self.thisptr.inhomogeneous_term().get_mpz_t()) + + def space_dimension(self): + return self.thisptr.space_dimension() + + def __repr__(self): + s = '' + v = [Variable(i) for i in range(self.space_dimension())] + e = sum(self.coefficient(x)*x for x in v) + e += self.inhomogeneous_term() + s = repr(e) + '==0 (mod %s)' % self.modulus() + return s + + def __reduce__(self): + r""" + >>> from ppl import Variable, Congruence, Congruence_System + >>> from pickle import loads, dumps + >>> x = Variable(0) + >>> y = Variable(1) + >>> z = Variable(2) + >>> c1 = Congruence(2*x + 3*y - 5*z == 3, 12) + >>> c1 + 2*x0+3*x1-5*x2-3==0 (mod 12) + >>> loads(dumps(c1)) + 2*x0+3*x1-5*x2-3==0 (mod 12) + >>> assert c1.is_equal(loads(dumps(c1))) + """ + le = Linear_Expression(self.coefficients(), self.inhomogeneous_term()) + return (congruence, (le == 0, self.modulus())) + +cdef class Congruence_System(object): + r""" + Wrapper for PPL's ``Congruence_System`` class. + + >>> from ppl import Variable, Congruence, Congruence_System + >>> x = Variable(0) + >>> y = Variable(1) + >>> z = Variable(2) + >>> c1 = Congruence(2*x + 3*y - 5*z == 0, 12) + >>> c2 = Congruence(4*x + y == 5, 18) + >>> C = Congruence_System() + >>> C.insert(c1) + >>> C.insert(c2) + >>> C + Congruence_System {2*x0+3*x1-5*x2==0 (mod 12), 4*x0+x1+13==0 (mod 18)} + """ + def __init__(self, arg=None): + if arg is None: + self.thisptr = new PPL_Congruence_System() + elif isinstance(arg, Congruence): + c = arg + self.thisptr = new PPL_Congruence_System(c.thisptr[0]) + elif isinstance(arg, Congruence_System): + cs = arg + self.thisptr = new PPL_Congruence_System(cs.thisptr[0]) + elif isinstance(arg, (list, tuple)): + self.thisptr = new PPL_Congruence_System() + for congruence in arg: + self.insert(congruence) + + def ascii_dump(self): + r""" + Write an ASCII dump of this congruence to stderr. + + Examples: + + >>> cmd = 'from ppl import Variable, Congruence_System\n' + >>> cmd += 'x = Variable(0)\n' + >>> cmd += 'y = Variable(1)\n' + >>> cmd += 'cs = Congruence_System( (3*x == 2*y+1) % 7 )\n' + >>> cmd += 'cs.ascii_dump()\n' + >>> import subprocess, sys + >>> proc = subprocess.Popen([sys.executable, '-c', cmd], stderr=subprocess.PIPE) + >>> out, err = proc.communicate() + >>> print(str(err.decode('ascii'))) + 1 x 2 SPARSE + size 3 6 3 -2 m 7 + + """ + self.thisptr.ascii_dump() + + def __len__(self): + r""" + Return the number of congruences in the system. + + Examples: + + >>> from ppl import Variable, Congruence_System + >>> x = Variable(0) + >>> y = Variable(1) + >>> cs = Congruence_System( [(x == 3) % 15, (2*y == 7) % 12]) + >>> len(cs) + 2 + >>> cs.insert((2*x + y == 12) % 22) + >>> len(cs) + 3 + >>> cs.clear() + >>> len(cs) + 0 + """ + cdef Py_ssize_t l = 0 + cdef PPL_Congruence_System_iterator * csi_ptr = new PPL_Congruence_System_iterator(self.thisptr[0].begin()) + + while csi_ptr[0] != self.thisptr[0].end(): + l += 1 + csi_ptr[0].inc(1) + del csi_ptr + return l + + def __iter__(self): + cdef PPL_Congruence_System_iterator * csi_ptr = new PPL_Congruence_System_iterator(self.thisptr[0].begin()) + + try: + while csi_ptr[0] != self.thisptr[0].end(): + yield _wrap_Congruence(deref(csi_ptr[0].inc(1))) + finally: + del csi_ptr + + def __repr__(self): + s = 'Congruence_System {' + s += ', '.join([ repr(c) for c in self ]) + s += '}' + return s + + def insert(self, Congruence c): + r""" + Insert the congruence ``c`` into the congruence system. + + Examples: + + >>> from ppl import Variable, Congruence_System + >>> x = Variable(0) + >>> y = Variable(1) + >>> cs = Congruence_System() + >>> cs.insert((3 * x + 2 == 0) % 13) + >>> cs + Congruence_System {3*x0+2==0 (mod 13)} + """ + self.thisptr.insert(c.thisptr[0]) + + def clear(self): + r""" + Remove all congruences from this congruence system. + + >>> from ppl import Variable, Congruence_System + >>> x = Variable(0) + >>> y = Variable(1) + >>> cs = Congruence_System([(3*x+2*y+1 == 3) % 15, (x+2*y + 7 == 0) % 22]) + >>> len(cs) + 2 + >>> cs.clear() + >>> len(cs) + 0 + """ + self.thisptr.clear() + + def __reduce__(self): + """ + Pickle object. + + Examples: + + >>> from ppl import Variable, Congruence_System + >>> from pickle import loads, dumps + >>> x = Variable(0) + >>> y = Variable(1) + >>> cs = Congruence_System([(3*x+2*y+1 == 3) % 15, (x+2*y + 7 == 0) % 22]) + >>> cs + Congruence_System {3*x0+2*x1+13==0 (mod 15), x0+2*x1+7==0 (mod 22)} + >>> loads(dumps(cs)) + Congruence_System {3*x0+2*x1+13==0 (mod 15), x0+2*x1+7==0 (mod 22)} + """ + return (Congruence_System, (tuple(self),)) + +cdef _wrap_Congruence(PPL_Congruence congruence): + cdef Congruence c = Congruence.__new__(Congruence) + c.thisptr = new PPL_Congruence(congruence) + return c + +def congruence(le, m): + return Congruence(le, m) diff -Nru pplpy-0.8.4/ppl/constraint.pyx pplpy-0.8.7/ppl/constraint.pyx --- pplpy-0.8.4/ppl/constraint.pyx 2019-02-14 09:51:09.000000000 +0000 +++ pplpy-0.8.7/ppl/constraint.pyx 2021-01-20 18:47:15.000000000 +0000 @@ -11,7 +11,7 @@ # 2016 Jori Mäntysalo # 2016 Matthias Koeppe # 2016-2017 Frédéric Chapoton -# 2016-2018 Vincent Delecroix +# 2016-2020 Vincent Delecroix # 2017-2018 Vincent Klein # # Distributed under the terms of the GNU General Public License (GPL) @@ -21,10 +21,12 @@ #***************************************************************************** from __future__ import absolute_import, print_function -from gmpy2 cimport GMPy_MPZ_From_mpz, import_gmpy2 +from gmpy2 cimport GMPy_MPZ_From_mpz, mpz, import_gmpy2, MPZ_Check from cython.operator cimport dereference as deref from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE +from .congruence cimport Congruence + # PPL can use floating-point arithmetic to compute integers cdef extern from "ppl.hh" namespace "Parma_Polyhedra_Library": cdef void set_rounding_for_PPL() @@ -492,21 +494,6 @@ """ self.thisptr.ascii_dump() - def OK(self): - """ - Check if all the invariants are satisfied. - - Examples: - - >>> from ppl import Variable - >>> x = Variable(0) - >>> y = Variable(1) - >>> ineq = (3*x+2*y+1>=0) - >>> ineq.OK() - True - """ - return self.thisptr.OK() - def __reduce__(self): """ Pickle object. @@ -552,10 +539,28 @@ cpp_cycle.push_back(PPL_Variable(i)) self.thisptr.permute_space_dimensions(cpp_cycle) + def __mod__(self, m): + r""" + Return this equality modulo m + + >>> import ppl + >>> x = ppl.Variable(0) + >>> y = ppl.Variable(1) + >>> (2*x + 3*y == 3) % 5 + 2*x0+3*x1-3==0 (mod 5) + + >>> (x <= 3) % 5 + Traceback (most recent call last): + ... + ValueError: PPL::Congruence::Congruence(c, r): + constraint c must be an equality. + """ + return Congruence(self, m) + #################################################### def inequality(expression): """ - Constuct an inequality. + Construct an inequality. INPUT: @@ -580,7 +585,7 @@ #################################################### def strict_inequality(expression): """ - Constuct a strict inequality. + Construct a strict inequality. INPUT: @@ -605,7 +610,7 @@ #################################################### def equation(expression): """ - Constuct an equation. + Construct an equation. INPUT: @@ -848,21 +853,6 @@ """ self.thisptr.ascii_dump() - def OK(self): - """ - Check if all the invariants are satisfied. - - Examples: - - >>> from ppl import Variable, Constraint_System - >>> x = Variable(0) - >>> y = Variable(1) - >>> cs = Constraint_System( 3*x+2*y+1 <= 10 ) - >>> cs.OK() - True - """ - return self.thisptr.OK() - def __len__(self): """ Return the number of constraints in the system. @@ -871,16 +861,28 @@ >>> from ppl import Variable, Constraint_System >>> x = Variable(0) - >>> cs = Constraint_System( x>0 ) - >>> cs.insert( x<1 ) + >>> cs = Constraint_System( [x>0, x<1] ) >>> len(cs) 2 + >>> cs.insert(2*x < 3) + >>> len(cs) + 3 + >>> cs.clear() + >>> len(cs) + 0 """ - return sum(1 for c in self) + cdef Py_ssize_t l = 0 + cdef PPL_Constraint_System_iterator *csi_ptr = new PPL_Constraint_System_iterator(self.thisptr[0].begin()) + while csi_ptr[0] != self.thisptr[0].end(): + l += 1 + csi_ptr[0].inc(1) + del csi_ptr + return l def __iter__(self): """ Iterate through the constraints of the system. + Examples: >>> from ppl import Variable, Constraint_System @@ -913,7 +915,7 @@ ... StopIteration """ - cdef PPL_cs_iterator *csi_ptr = new PPL_cs_iterator(self.thisptr[0].begin()) + cdef PPL_Constraint_System_iterator *csi_ptr = new PPL_Constraint_System_iterator(self.thisptr[0].begin()) try: while csi_ptr[0] != self.thisptr[0].end(): yield _wrap_Constraint(deref(csi_ptr[0].inc(1))) @@ -996,7 +998,7 @@ >>> loads(dumps(cs)) Constraint_System {-3*x0-2*x1+2>0, -x0-1>0} """ - return (Constraint_System, (tuple(self), )) + return (Constraint_System, (tuple(self),)) cdef class Poly_Con_Relation(object): r""" @@ -1200,18 +1202,6 @@ """ self.thisptr.ascii_dump() - def OK(self, check_non_empty=False): - """ - Check if all the invariants are satisfied. - - Examples: - - >>> from ppl import Poly_Con_Relation - >>> Poly_Con_Relation.nothing().OK() - True - """ - return self.thisptr.OK() - def __repr__(self): r""" Return a string representation. diff -Nru pplpy-0.8.4/ppl/generator.pxd pplpy-0.8.7/ppl/generator.pxd --- pplpy-0.8.4/ppl/generator.pxd 2017-04-28 19:38:54.000000000 +0000 +++ pplpy-0.8.7/ppl/generator.pxd 2021-01-20 18:47:15.000000000 +0000 @@ -1,4 +1,6 @@ -from ppl_decl cimport * +from __future__ import absolute_import + +from .ppl_decl cimport * from .linear_algebra cimport * cdef _wrap_Generator(PPL_Generator generator) diff -Nru pplpy-0.8.4/ppl/generator.pyx pplpy-0.8.7/ppl/generator.pyx --- pplpy-0.8.4/ppl/generator.pyx 2018-08-30 03:44:39.000000000 +0000 +++ pplpy-0.8.7/ppl/generator.pyx 2021-01-20 18:47:15.000000000 +0000 @@ -647,21 +647,6 @@ """ self.thisptr.ascii_dump() - def OK(self): - """ - Check if all the invariants are satisfied. - - Examples: - - >>> from ppl import Variable - >>> x = Variable(0) - >>> y = Variable(1) - >>> e = 3*x+2*y+1 - >>> e.OK() - True - """ - return self.thisptr.OK() - def __reduce__(self): """ Pickle object. @@ -921,21 +906,6 @@ """ self.thisptr.ascii_dump() - def OK(self): - """ - Check if all the invariants are satisfied. - - Examples: - - >>> from ppl import Variable, Generator_System, point - >>> x = Variable(0) - >>> y = Variable(1) - >>> gs = Generator_System( point(3*x+2*y+1) ) - >>> gs.OK() - True - """ - return self.thisptr.OK() - def __len__(self): """ Return the number of generators in the system. @@ -1228,18 +1198,6 @@ """ self.thisptr.ascii_dump() - def OK(self, check_non_empty=False): - """ - Check if all the invariants are satisfied. - - Examples: - - >>> from ppl import Poly_Gen_Relation - >>> Poly_Gen_Relation.nothing().OK() - True - """ - return self.thisptr.OK() - def __repr__(self): r""" Return a string representation. diff -Nru pplpy-0.8.4/ppl/__init__.py pplpy-0.8.7/ppl/__init__.py --- pplpy-0.8.4/ppl/__init__.py 2019-01-18 13:43:35.000000000 +0000 +++ pplpy-0.8.7/ppl/__init__.py 2021-01-20 18:47:15.000000000 +0000 @@ -79,7 +79,7 @@ mpz(5) * PPL supports (topologically) closed polyhedra - (:class:`C_Polyhedron`) as well as not neccesarily closed polyhedra + (:class:`C_Polyhedron`) as well as not necessarily closed polyhedra (:class:`NNC_Polyhedron`). Only the latter allows closure points (=points of the closure but not of the actual polyhedron) and strict inequalities (``>`` and ``<``) @@ -89,7 +89,7 @@ ``PPL_Linear_Expression``. The Python wrapper has the same name as the original library class, that is, just ``Linear_Expression``. In short: -* If you are using the Python wrapper (if in doubt: thats you), then +* If you are using the Python wrapper (if in doubt: that's you), then you use the same names as the PPL C++ class library. * If you are writing your own Cython code, you can access the @@ -118,9 +118,10 @@ AUTHORS: -- Volker Braun (2010-10-08): initial version (within Sage). -- Risan (2012-02-19): extension for MIP_Problem class (within Sage) -- Vincent Delecroix (2016): convert Sage files into a standalone Python package +- Volker Braun (2010): initial version (within Sage). +- Risan (2012): extension for MIP_Problem class (within Sage) +- Vincent Delecroix (2016-2020): convert Sage files into a standalone Python package, + interface bit_array, interface congruence - Vincent Klein (2017): improve doctest support and Python 3 compatibility Split the main code into several files. Remove the _mutable_immutable class. @@ -145,4 +146,6 @@ Constraint, Constraint_System, Poly_Con_Relation, inequality, equation, strict_inequality) +from .congruence import Congruence, Congruence_System + from .bit_arrays import Bit_Row, Bit_Matrix diff -Nru pplpy-0.8.4/ppl/linear_algebra.pxd pplpy-0.8.7/ppl/linear_algebra.pxd --- pplpy-0.8.4/ppl/linear_algebra.pxd 2019-02-14 21:45:23.000000000 +0000 +++ pplpy-0.8.7/ppl/linear_algebra.pxd 2021-01-20 18:47:15.000000000 +0000 @@ -1,4 +1,6 @@ -from ppl_decl cimport * +from __future__ import absolute_import + +from .ppl_decl cimport * cdef class Variable(object): cdef PPL_Variable *thisptr diff -Nru pplpy-0.8.4/ppl/linear_algebra.pyx pplpy-0.8.7/ppl/linear_algebra.pyx --- pplpy-0.8.4/ppl/linear_algebra.pyx 2019-02-15 05:36:37.000000000 +0000 +++ pplpy-0.8.7/ppl/linear_algebra.pyx 2021-01-20 18:47:15.000000000 +0000 @@ -11,7 +11,7 @@ # 2016 Jori Mäntysalo # 2016 Matthias Koeppe # 2016-2017 Frédéric Chapoton -# 2016-2018 Vincent Delecroix +# 2016-2020 Vincent Delecroix # 2017-2018 Vincent Klein # # Distributed under the terms of the GNU General Public License (GPL) @@ -29,7 +29,7 @@ from cpython.object cimport PyObject from gmpy2 cimport import_gmpy2, mpz, GMPy_MPZ_From_mpz, MPZ_Check from .constraint cimport _make_Constraint_from_richcmp -from .ppl_decl cimport mpz_t, mpz_init, mpz_class +from .ppl_decl cimport mpz_t, mpz_init, mpz_class, modulo # initialize gmpy2 C API import_gmpy2() @@ -147,23 +147,6 @@ """ return self.thisptr.id() - def OK(self): - """ - Checks if all the invariants are satisfied. - - OUTPUT: - - Boolean. - - Examples: - - >>> from ppl import Variable - >>> x = Variable(0) - >>> x.OK() - True - """ - return self.thisptr.OK() - def space_dimension(self): r""" Return the dimension of the vector space enclosing ``self``. @@ -439,29 +422,11 @@ """ del self.thisptr - def OK(self): - """ - Checks if all the invariants are satisfied. - - OUTPUT: - - Boolean. - - EXAMPLES:: - - >>> from ppl import Variable, Variables_Set - >>> v123 = Variable(123) - >>> S = Variables_Set(v123) - >>> S.OK() - True - """ - return self.thisptr.OK() - def space_dimension(self): r""" Returns the dimension of the smallest vector space enclosing all the variables whose indexes are in the set. - OUPUT: + OUTPUT: Integer. @@ -581,8 +546,6 @@ >>> x = Variable(123) >>> expr = x+1; expr x123+1 - >>> expr.OK() - True >>> expr.coefficient(x) mpz(1) >>> expr.coefficient( Variable(124) ) @@ -829,6 +792,8 @@ >>> e = 3*x+1 >>> e.coefficient(x) mpz(3) + >>> e.coefficient(Variable(13)) + mpz(0) """ cdef Variable vv if type(v) is Variable: @@ -956,7 +921,7 @@ def is_equal_to(self, Linear_Expression other): """ - Test equality with an other linear expression. + Test equality with another linear expression. OUTPUT: boolean @@ -995,21 +960,6 @@ """ self.thisptr.ascii_dump() - def OK(self): - """ - Check if all the invariants are satisfied. - - Examples: - - >>> from ppl import Variable - >>> x = Variable(0) - >>> y = Variable(1) - >>> e = 3*x+2*y+1 - >>> e.OK() - True - """ - return self.thisptr.OK() - def __repr__(self): r""" Return a string representation of the linear expression. @@ -1036,7 +986,7 @@ """ s = '' first = True - for i in range(0,self.space_dimension()): + for i in range(self.space_dimension()): x = Variable(i) coeff = self.coefficient(x) if coeff == 0: continue diff -Nru pplpy-0.8.4/ppl/mip_problem.pyx pplpy-0.8.7/ppl/mip_problem.pyx --- pplpy-0.8.4/ppl/mip_problem.pyx 2018-08-24 14:28:22.000000000 +0000 +++ pplpy-0.8.7/ppl/mip_problem.pyx 2021-01-20 18:47:15.000000000 +0000 @@ -646,24 +646,3 @@ finally: sig_off() return _wrap_Generator(g[0]) - - def OK(self): - """ - Check if all the invariants are satisfied. - - OUTPUT: - - ``True`` if and only if ``self`` satisfies all the invariants. - - Examples: - - >>> from ppl import Variable, MIP_Problem - >>> x = Variable(0) - >>> y = Variable(1) - >>> m = MIP_Problem() - >>> m.add_space_dimensions_and_embed(2) - >>> m.add_constraint(x >= 0) - >>> m.OK() - True - """ - return self.thisptr.OK() diff -Nru pplpy-0.8.4/ppl/polyhedron.pyx pplpy-0.8.7/ppl/polyhedron.pyx --- pplpy-0.8.4/ppl/polyhedron.pyx 2019-02-20 09:54:21.000000000 +0000 +++ pplpy-0.8.7/ppl/polyhedron.pyx 2021-01-20 18:47:15.000000000 +0000 @@ -1026,7 +1026,7 @@ Adds a copy of constraint ``c`` to the system of constraints of ``self``, without minimizing the result. - See alse :meth:`add_constraints`. + See also :meth:`add_constraints`. INPUT: @@ -1148,7 +1148,7 @@ Adds a copy of constraints in ``cs`` to the system of constraints of ``self``, without minimizing the result. - See alse :meth:`add_constraint`. + See also :meth:`add_constraint`. INPUT: @@ -1207,7 +1207,7 @@ Adds a copy of the generators in ``gs`` to the system of generators of ``self``, without minimizing the result. - See alse :meth:`add_generator`. + See also :meth:`add_generator`. INPUT: @@ -1487,7 +1487,7 @@ .. note:: - The modified polyhedron is not neccessarily a lattice + The modified polyhedron is not necessarily a lattice polyhedron; Some vertices will, in general, still be rational. Lattice points interior to the polyhedron may be lost in the process. @@ -1595,7 +1595,7 @@ True if this method is going to be called too many times, the - ``tp`` parameter allows to reduce the computation cost by + ``tp`` parameter allows one to reduce the computation cost by computing the widening only when ``tp`` is equal to 0, otherwise the this method will decrement the value of ``tp`` and return it. @@ -1615,13 +1615,14 @@ >>> known_result = NNC_Polyhedron(2) >>> known_result.add_constraint(y >= 0) >>> known_result.add_constraint(y < 1) - >>> tp = 1 - >>> tp = ph2.BHRZ03_widening_assign(ph1, tp); tp - 0 + >>> tp = ph2.BHRZ03_widening_assign(ph1, 1) + >>> tp == 0 + True >>> ph2 == ph2_copy True - >>> tp = ph2.BHRZ03_widening_assign(ph1, tp); tp - 0 + >>> tp = ph2.BHRZ03_widening_assign(ph1, 0) + >>> tp == 0 + True >>> ph2 == known_result True """ @@ -1796,7 +1797,7 @@ this->space_dimension() == 2, y.space_dimension() == 3. if this method is going to be called too many times, the - ``tp`` parameter allows to reduce the computation cost by + ``tp`` parameter allows one to reduce the computation cost by computing the widening only when ``tp`` is equal to 0, otherwise the this method will decrement the value of ``tp`` and return it. @@ -1815,13 +1816,14 @@ >>> ph2_copy = C_Polyhedron(ph2) >>> known_result = C_Polyhedron(2) >>> known_result.add_constraint(y >= 0) - >>> tp = 1 - >>> tp = ph2.H79_widening_assign(ph1, tp); tp - 0 + >>> tp = ph2.H79_widening_assign(ph1, 1) + >>> tp == 0 + True >>> ph2 == ph2_copy True - >>> tp = ph2.H79_widening_assign(ph1, tp); tp - 0 + >>> tp = ph2.H79_widening_assign(ph1, 0) + >>> tp == 0 + True >>> ph2 == known_result True """ @@ -2088,7 +2090,7 @@ r""" Assign to ``self`` the concatenation of ``self`` and ``y``. - This functions returns the Cartiesian product of ``self`` and + This functions returns the Cartesian product of ``self`` and ``y``. Viewing a polyhedron as a set of tuples (its points), it is @@ -2319,42 +2321,6 @@ """ return self.thisptr.max_space_dimension() - def OK(self, check_non_empty=False): - """ - Check if all the invariants are satisfied. - - The check is performed so as to intrude as little as - possible. If the library has been compiled with run-time - assertions enabled, error messages are written on std::cerr in - case invariants are violated. This is useful for the purpose - of debugging the library. - - INPUT: - - - ``check_not_empty`` -- boolean. ``True`` if and only if, in - addition to checking the invariants, ``self`` must be - checked to be not empty. - - OUTPUT: - - ``True`` if and only if ``self`` satisfies all the invariants - and either ``check_not_empty`` is ``False`` or ``self`` is not - empty. - - Examples: - - >>> from ppl import Variable - >>> x = Variable(0) - >>> y = Variable(1) - >>> e = 3*x+2*y+1 - >>> e.OK() - True - """ - sig_on() - cdef bint result = self.thisptr.OK() - sig_off() - return result - def hash_code(self): r""" Return a hash code diff -Nru pplpy-0.8.4/ppl/ppl_decl.pxd pplpy-0.8.7/ppl/ppl_decl.pxd --- pplpy-0.8.4/ppl/ppl_decl.pxd 2019-02-20 09:54:21.000000000 +0000 +++ pplpy-0.8.7/ppl/ppl_decl.pxd 2021-01-20 18:47:15.000000000 +0000 @@ -35,7 +35,6 @@ ctypedef enum PPL_MIP_Problem_Control_Parameter_Value: PRICING_STEEPEST_EDGE_FLOAT, PRICING_STEEPEST_EDGE_EXACT, PRICING_TEXTBOOK - cdef extern from "ppl.hh" namespace "Parma_Polyhedra_Library": ctypedef size_t PPL_dimension_type "Parma_Polyhedra_Library::dimension_type" ctypedef mpz_class PPL_Coefficient "Parma_Polyhedra_Library::Coefficient" @@ -46,6 +45,8 @@ cdef cppclass PPL_Generator_System "Parma_Polyhedra_Library::Generator_System" cdef cppclass PPL_Constraint "Parma_Polyhedra_Library::Constraint" cdef cppclass PPL_Constraint_System "Parma_Polyhedra_Library::Constraint_System" + cdef cppclass PPL_Congruence "Parma_Polyhedra_Library::Congruence" + cdef cppclass PPL_Congruence_System "Parma_Polyhedra_Library::Congruence_System" cdef cppclass PPL_Polyhedron "Parma_Polyhedra_Library::Polyhedron" cdef cppclass PPL_C_Polyhedron "Parma_Polyhedra_Library::C_Polyhedron" (PPL_Polyhedron) cdef cppclass PPL_NNC_Polyhedron "Parma_Polyhedra_Library::NNC_Polyhedron" (PPL_Polyhedron) @@ -53,15 +54,16 @@ cdef cppclass PPL_Poly_Con_Relation "Parma_Polyhedra_Library::Poly_Con_Relation" cdef cppclass PPL_MIP_Problem "Parma_Polyhedra_Library::MIP_Problem" cdef cppclass PPL_mip_iterator "Parma_Polyhedra_Library::MIP_Problem::const_iterator" - cdef cppclass PPL_gs_iterator "Parma_Polyhedra_Library::Generator_System_const_iterator" - cdef cppclass PPL_cs_iterator "Parma_Polyhedra_Library::Constraint_System_const_iterator" + cdef cppclass PPL_gs_iterator "Parma_Polyhedra_Library::Generator_System::const_iterator" + cdef cppclass PPL_Constraint_System_iterator "Parma_Polyhedra_Library::Constraint_System::const_iterator" + cdef cppclass PPL_Congruence_System_iterator "Parma_Polyhedra_Library::Congruence_System::const_iterator" + cdef cppclass PPL_Bit_Row "Parma_Polyhedra_Library::Bit_Row" cdef cppclass PPL_Bit_Matrix "Parma_Polyhedra_Library::Bit_Matrix" cdef cppclass PPL_Variable: PPL_Variable(PPL_dimension_type i) PPL_dimension_type id() - bint OK() PPL_dimension_type space_dimension() cdef cppclass PPL_Variables_Set: @@ -72,7 +74,6 @@ void insert(PPL_Variable v) size_t size() void ascii_dump() - bint OK() # class Parma_Polyhedra_Library::Linear_Expression # lines 28238-28879 of ppl.hh @@ -102,7 +103,6 @@ bint all_zeroes(const PPL_Variables_Set& v) void ascii_dump() - bint OK() #PPL_Linear_Expression operator+=(PPL_Linear_Expression& e) #PPL_Linear_Expression operator-=(PPL_Linear_Expression& e) @@ -117,6 +117,7 @@ PPL_Constraint operator<=(PPL_Linear_Expression& e) PPL_Constraint operator< (PPL_Linear_Expression& e) + cdef cppclass PPL_Constraint: PPL_Constraint() PPL_Constraint(PPL_Constraint &g) @@ -132,7 +133,6 @@ bint is_inconsistent() bint is_equivalent_to(PPL_Constraint &y) void ascii_dump() - bint OK() void permute_space_dimensions(const cppvector[PPL_Variable]& cycle) except +ValueError cdef cppclass PPL_Generator: @@ -149,9 +149,57 @@ PPL_Coefficient divisor() except + bint is_equivalent_to(PPL_Generator &y) void ascii_dump() - bint OK() void permute_space_dimensions(const cppvector[PPL_Variable]& cycle) except +ValueError + cdef cppclass PPL_Congruence: + PPL_Congruence() + PPL_Congruence(const PPL_Congruence &g) + PPL_Congruence(const PPL_Constraint &c) except +ValueError + PPL_dimension_type space_dimension() + # NOTE: curiously, this can raise an error (behavior different from Linear_Expression) + PPL_Coefficient coefficient(PPL_Variable v) except +ValueError + PPL_Coefficient inhomogeneous_term() + PPL_Coefficient modulus() + void set_modulus(PPL_Coefficient& m) + void scale(PPL_Coefficient& m) + bint is_tautological() + bint is_inconsistent() + bint is_proper_congruence() + bint is_equality() + void ascii_dump() + void swap_space_dimension(PPL_Variable v1, PPL_Variable v2) + void set_space_dimension(PPL_dimension_type n) + void shift_space_dimensions(PPL_Variable v, PPL_dimension_type n) + void sign_normalize() + void normalize() + void strong_normalize() + PPL_dimension_type max_space_dimension() + + cppbool operator==(const PPL_Congruence &x, const PPL_Congruence &y) + cppbool operator!=(const PPL_Congruence &x, const PPL_Congruence &y) + + cdef cppclass PPL_Congruence_System: + PPL_Congruence_System() + PPL_Congruence_System(PPL_Congruence &c) + PPL_Congruence_System(PPL_Congruence_System &cs) + PPL_dimension_type space_dimension() + PPL_Congruence_System_iterator begin() + PPL_Congruence_System_iterator end() + bint has_equalities() + bint has_strict_inequalities() + void clear() + void insert(PPL_Congruence &g) + bint empty() + void ascii_dump() + + cdef cppclass PPL_Congruence_System_iterator: + PPL_Congruence_System_iterator() + PPL_Congruence_System_iterator(PPL_Congruence_System_iterator &csi) + PPL_Congruence& operator* () + PPL_Congruence_System_iterator inc "operator++" (int i) + cppbool operator==(PPL_Congruence_System_iterator& y) + cppbool operator!=(PPL_Congruence_System_iterator& y) + cdef cppclass PPL_Generator_System: PPL_Generator_System() PPL_Generator_System(PPL_Generator &g) @@ -164,7 +212,6 @@ void insert(PPL_Generator &g) bint empty() void ascii_dump() - bint OK() cdef cppclass PPL_mip_iterator: PPL_mip_iterator(PPL_mip_iterator &mipi) @@ -181,28 +228,27 @@ cppbool operator==(PPL_gs_iterator& y) cppbool operator!=(PPL_gs_iterator& y) - cdef cppclass PPL_cs_iterator: - PPL_cs_iterator() - PPL_cs_iterator(PPL_cs_iterator &csi) + cdef cppclass PPL_Constraint_System_iterator: + PPL_Constraint_System_iterator() + PPL_Constraint_System_iterator(PPL_Constraint_System_iterator &csi) PPL_Constraint& operator* () - PPL_cs_iterator inc "operator++" (int i) - cppbool operator==(PPL_cs_iterator& y) - cppbool operator!=(PPL_cs_iterator& y) + PPL_Constraint_System_iterator inc "operator++" (int i) + cppbool operator==(PPL_Constraint_System_iterator& y) + cppbool operator!=(PPL_Constraint_System_iterator& y) cdef cppclass PPL_Constraint_System: PPL_Constraint_System() PPL_Constraint_System(PPL_Constraint &g) PPL_Constraint_System(PPL_Constraint_System &gs) PPL_dimension_type space_dimension() - PPL_cs_iterator begin() - PPL_cs_iterator end() + PPL_Constraint_System_iterator begin() + PPL_Constraint_System_iterator end() bint has_equalities() bint has_strict_inequalities() void clear() void insert(PPL_Constraint &g) bint empty() void ascii_dump() - bint OK() cdef enum PPL_Degenerate_Element "Parma_Polyhedra_Library::Degenerate_Element": UNIVERSE, EMPTY @@ -274,7 +320,6 @@ void ascii_dump() int hash_code() PPL_dimension_type max_space_dimension() - bint OK(cppbool check_not_empty=false) bint operator!=(PPL_Polyhedron &y) bint operator==(PPL_Polyhedron &y) @@ -295,13 +340,11 @@ PPL_Poly_Gen_Relation(PPL_Poly_Gen_Relation &cpy_from) bint implies(PPL_Poly_Gen_Relation &y) void ascii_dump() - bint OK() cdef cppclass PPL_Poly_Con_Relation: PPL_Poly_Con_Relation(PPL_Poly_Con_Relation &cpy_from) bint implies(PPL_Poly_Con_Relation &y) void ascii_dump() - bint OK() cdef cppclass PPL_MIP_Problem: PPL_MIP_Problem(PPL_MIP_Problem &cpy_from) @@ -323,7 +366,6 @@ PPL_Generator& feasible_point() PPL_Generator optimizing_point() except +ValueError void optimal_value(PPL_Coefficient &num, PPL_Coefficient &den) except +ValueError - bint OK() PPL_MIP_Problem_Control_Parameter_Value get_control_parameter(PPL_MIP_Problem_Control_Parameter_Name name) void set_control_parameter(PPL_MIP_Problem_Control_Parameter_Value value) PPL_mip_iterator constraints_begin() @@ -347,7 +389,6 @@ unsigned long count_ones() cppbool empty() - cppbool OK() cdef cppclass PPL_Bit_Matrix: PPL_Bit_Matrix() @@ -364,7 +405,6 @@ PPL_dimension_type num_rows() void sort_rows() - cppbool OK() cdef extern from "ppl.hh": PPL_Generator PPL_line "Parma_Polyhedra_Library::line" (PPL_Linear_Expression &e) except +ValueError @@ -386,3 +426,5 @@ cdef extern from "ppl_shim.hh": PPL_Poly_Gen_Relation* new_relation_with(PPL_Polyhedron &p, PPL_Generator &g) except +ValueError PPL_Poly_Con_Relation* new_relation_with(PPL_Polyhedron &p, PPL_Constraint &c) except +ValueError + + PPL_Congruence modulo(const PPL_Linear_Expression &expr, PPL_Coefficient& mod) diff -Nru pplpy-0.8.4/ppl/ppl_shim.cc pplpy-0.8.7/ppl/ppl_shim.cc --- pplpy-0.8.4/ppl/ppl_shim.cc 2017-05-18 15:22:13.000000000 +0000 +++ pplpy-0.8.7/ppl/ppl_shim.cc 2021-01-20 18:47:15.000000000 +0000 @@ -9,3 +9,8 @@ { return new Poly_Con_Relation(p.relation_with(c)); } + +Congruence modulo(const Linear_Expression &expr, mpz_class mod) +{ + return (expr %= 0) / mod; +} diff -Nru pplpy-0.8.4/ppl/ppl_shim.hh pplpy-0.8.7/ppl/ppl_shim.hh --- pplpy-0.8.4/ppl/ppl_shim.hh 2017-04-28 19:38:54.000000000 +0000 +++ pplpy-0.8.7/ppl/ppl_shim.hh 2021-01-20 18:47:15.000000000 +0000 @@ -11,4 +11,7 @@ Poly_Gen_Relation* new_relation_with(const Polyhedron &p, const Generator &g); Poly_Con_Relation* new_relation_with(const Polyhedron &p, const Constraint &c); -#endif \ No newline at end of file +// the weird usage of the %= operator confuses Cython +Congruence modulo(const Linear_Expression &e, mpz_class mod); + +#endif diff -Nru pplpy-0.8.4/pplpy.egg-info/dependency_links.txt pplpy-0.8.7/pplpy.egg-info/dependency_links.txt --- pplpy-0.8.4/pplpy.egg-info/dependency_links.txt 2019-02-28 15:21:16.000000000 +0000 +++ pplpy-0.8.7/pplpy.egg-info/dependency_links.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ - diff -Nru pplpy-0.8.4/pplpy.egg-info/PKG-INFO pplpy-0.8.7/pplpy.egg-info/PKG-INFO --- pplpy-0.8.4/pplpy.egg-info/PKG-INFO 2019-02-28 15:21:16.000000000 +0000 +++ pplpy-0.8.7/pplpy.egg-info/PKG-INFO 1970-01-01 00:00:00.000000000 +0000 @@ -1,143 +0,0 @@ -Metadata-Version: 1.1 -Name: pplpy -Version: 0.8.4 -Summary: Python PPL wrapper -Home-page: https://gitlab.com/videlec/pplpy -Author: Vincent Delecroix -Author-email: vincent.delecroix@labri.fr -License: GPL v3 -Download-URL: https://pypi.org/project/pplpy/#files -Description: PPL Python wrapper - ================== - - This Python package provides a wrapper to the C++ `Parma Polyhedra Library - (PPL) `_. - - The whole package started as a fork of a tiny part of the `Sage - `_ software. - - How it works - ------------ - - The names of objects and methods are the same as in the library: - - .. code:: python - - >>> import ppl - >>> x = ppl.Variable(0) - >>> y = ppl.Variable(1) - >>> z = ppl.Variable(2) - >>> cs = ppl.Constraint_System() - >>> cs.insert(x >= 0) - >>> cs.insert(y >= 0) - >>> cs.insert(z >= 0) - >>> cs.insert(x + y + z == 1) - >>> poly = ppl.C_Polyhedron(cs) - >>> poly.minimized_generators() - Generator_System {point(1/1, 0/1, 0/1), point(0/1, 1/1, 0/1), point(0/1, 0/1, 1/1)} - - The available objects and functions from the `ppl` Python module are: - - - `Variable`, `Variables_Set`, `Linear_Expression` (defined in `ppl.linear_algebra`) - - - `MIP_Problem` (defined in `ppl.mip_problem`) - - - `C_Polyhedron`, `NNC_Polyhedron` (defined in `ppl.polyhedron`) - - - `Generator`, `Generator_System`, `Poly_Gen_Relation`, `point`, - `closure_point`, `ray`, `line` (defined in `ppl.generator`) - - - `Constraint`, `Constraint_System`, `Poly_Con_Relation`, - `inequality`, `equation`, `strict_inequality` (defined in `ppl.constraint`) - - Installation - ------------ - - The project is available at `Python Package Index `_ and - can be installed with pip:: - - $ pip install pplpy - - Note that if you have gmp and ppl installed in a non standard directory (e.g. you use brew - on MacOSX) then you need to set appropriately the variables `CFLAGS` before calling `pip`. For - example:: - - $ export CFLAGS="-I/path/to/gmp/include/ -L/path/to/gmp/lib/ -I/path/to/ppl/include/ -L/path/to/ppl/lib $CFLAGS" - $ pip install pplpy - - Using from Cython - ----------------- - - All Python classes from pplpy are extension types and can be used with Cython. Each - extension type carries an attribute `thisptr` that holds a pointer to - the corresponding C++ object from ppl. - - A complete example is provided with the files `tests/testpplpy.pyx` and `tests/setup.py`. - - Source - ------ - - You can find the latest version of the source code on gitlab: - https://gitlab.com/videlec/pplpy - - Documentation - ------------- - - An online version of the documentation is available at http://www.labri.fr/perso/vdelecro/pplpy/latest/ - - Compiling the html documentation requires make and `sphinx `_. - Before building the documentation, you need to install the pplpy package (sphinx uses Python introspection). - The documentation source code is contained in the repository `docs` where there is a standard - Makefile with a target `html`. Running `make html` in the `docs` repository builds the documentation - inside `docs/build/html`. For more configuration options, run `make help`. - - License - ------- - - pplpy is distributed under the terms of the GNU General Public License (GPL) - published by the Free Software Foundation; either version 3 of - the License, or (at your option) any later version. See http://www.gnu.org/licenses/. - - Requirements - ------------ - - - `gmp `_ - - - `mpfr `_ - - - `mpc `_ - - - `PPL `_ - - - `Cython `_ - - - `cysignals `_ - - - `gmpy2 `_: version 2.1.0a4 from sources (see below) - - On Debian/Ubuntu systems these can be installed with:: - - $ sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev libppl-dev cython - $ pip install cysignals --user - $ pip install gmpy2==2.1.0a4 --user - - The pip optional option `--user` allows to install python packages for a single - user with no need for administrator rights. The two pip install commands might - be replaced by `sudo pip install PKG` (not recommanded). On recent Debian/Ubuntu systems, - cysignals is also available as a package under the name `python-cysignals` for - Python 2 and `python3-cysignals` for Python 3. - -Keywords: polyhedron,polytope,convex,mathematics,ppl,milp,linear-programming -Platform: any -Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3) -Classifier: Programming Language :: C++ -Classifier: Programming Language :: Python -Classifier: Development Status :: 3 - Alpha -Classifier: Operating System :: Unix -Classifier: Intended Audience :: Science/Research -Classifier: Programming Language :: Python :: 2 -Classifier: Programming Language :: Python :: 2.7 -Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.4 -Classifier: Programming Language :: Python :: 3.5 -Classifier: Programming Language :: Python :: 3.6 diff -Nru pplpy-0.8.4/pplpy.egg-info/requires.txt pplpy-0.8.7/pplpy.egg-info/requires.txt --- pplpy-0.8.4/pplpy.egg-info/requires.txt 2019-02-28 15:21:16.000000000 +0000 +++ pplpy-0.8.7/pplpy.egg-info/requires.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -Cython -cysignals -gmpy2 diff -Nru pplpy-0.8.4/pplpy.egg-info/SOURCES.txt pplpy-0.8.7/pplpy.egg-info/SOURCES.txt --- pplpy-0.8.4/pplpy.egg-info/SOURCES.txt 2019-02-28 15:21:18.000000000 +0000 +++ pplpy-0.8.7/pplpy.egg-info/SOURCES.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -CHANGES.txt -LICENSE.txt -MANIFEST.in -README.rst -setup.py -version.txt -docs/Makefile -docs/source/conf.py -docs/source/index.rst -ppl/__init__.py -ppl/bit_arrays.pxd -ppl/bit_arrays.pyx -ppl/constraint.pxd -ppl/constraint.pyx -ppl/generator.pxd -ppl/generator.pyx -ppl/linear_algebra.pxd -ppl/linear_algebra.pyx -ppl/mip_problem.pxd -ppl/mip_problem.pyx -ppl/polyhedron.pxd -ppl/polyhedron.pyx -ppl/ppl_decl.pxd -ppl/ppl_shim.cc -ppl/ppl_shim.hh -pplpy.egg-info/PKG-INFO -pplpy.egg-info/SOURCES.txt -pplpy.egg-info/dependency_links.txt -pplpy.egg-info/requires.txt -pplpy.egg-info/top_level.txt -tests/runtests.py -tests/setup.py -tests/setup2.py -tests/test_constraint.py -tests/test_variable.py -tests/testpplpy.pyx -tests/testpplpy2.pyx \ No newline at end of file diff -Nru pplpy-0.8.4/pplpy.egg-info/top_level.txt pplpy-0.8.7/pplpy.egg-info/top_level.txt --- pplpy-0.8.4/pplpy.egg-info/top_level.txt 2019-02-28 15:21:16.000000000 +0000 +++ pplpy-0.8.7/pplpy.egg-info/top_level.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -ppl diff -Nru pplpy-0.8.4/pyproject.toml pplpy-0.8.7/pyproject.toml --- pplpy-0.8.4/pyproject.toml 1970-01-01 00:00:00.000000000 +0000 +++ pplpy-0.8.7/pyproject.toml 2021-01-20 18:47:15.000000000 +0000 @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel", "Cython", "cysignals", "sphinx", "gmpy2>=2.1.0b1"] +build-backend = "setuptools.build_meta" diff -Nru pplpy-0.8.4/README.rst pplpy-0.8.7/README.rst --- pplpy-0.8.4/README.rst 2019-01-31 08:21:07.000000000 +0000 +++ pplpy-0.8.7/README.rst 2021-01-20 18:47:15.000000000 +0000 @@ -104,16 +104,16 @@ - `cysignals `_ -- `gmpy2 `_: version 2.1.0a4 from sources (see below) +- `gmpy2 `_: version >= 2.1.0a4 from sources (see below) On Debian/Ubuntu systems these can be installed with:: $ sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev libppl-dev cython $ pip install cysignals --user - $ pip install gmpy2==2.1.0a4 --user + $ pip install gmpy2 --pre --user The pip optional option `--user` allows to install python packages for a single user with no need for administrator rights. The two pip install commands might -be replaced by `sudo pip install PKG` (not recommanded). On recent Debian/Ubuntu systems, +be replaced by `sudo pip install PKG` (not recommended). On recent Debian/Ubuntu systems, cysignals is also available as a package under the name `python-cysignals` for Python 2 and `python3-cysignals` for Python 3. diff -Nru pplpy-0.8.4/setup.cfg pplpy-0.8.7/setup.cfg --- pplpy-0.8.4/setup.cfg 2019-02-28 15:21:19.000000000 +0000 +++ pplpy-0.8.7/setup.cfg 2021-01-20 18:47:15.000000000 +0000 @@ -1,4 +1,35 @@ -[egg_info] -tag_build = -tag_date = 0 +[metadata] +name = pplpy +version = 0.8.7 +description = Python PPL wrapper +author = Vincent Delecroix +author_email = vincent.delecroix@labri.fr +url = https://gitlab.com/videlec/pplpy +download_url = https://pypi.org/project/pplpy/#files +license = GPL v3 +platforms = any +classifiers = + License :: OSI Approved :: GNU General Public License v3 (GPLv3) + Programming Language :: C++ + Programming Language :: Python + Development Status :: 5 - Production/Stable + Operating System :: Unix + Intended Audience :: Science/Research + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.4 + Programming Language :: Python :: 3.5 + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 +keywords = + polyhedron + polytope + convex + mathematics + ppl + milp + linear-programming +[options] +packages = ppl diff -Nru pplpy-0.8.4/setup.py pplpy-0.8.7/setup.py --- pplpy-0.8.4/setup.py 2019-02-14 10:12:15.000000000 +0000 +++ pplpy-0.8.7/setup.py 2021-01-20 18:47:15.000000000 +0000 @@ -1,9 +1,20 @@ #!/usr/bin/env python + +import os +import sys + from setuptools import setup +from setuptools.config import read_configuration +from setuptools.extension import Extension + from distutils.command.build_ext import build_ext as _build_ext from distutils.cmd import Command -from setuptools.extension import Extension -import sys + +dir_path = os.path.dirname(os.path.realpath(__file__)) +conf_dict = read_configuration(os.path.join(dir_path, "setup.cfg")) +# NOTE: Python2.7 do not support multiple dictionaries unpacking +kwds = conf_dict['metadata'] +kwds.update(conf_dict['options']) # Adapted from Cython's new_build_ext class build_ext(_build_ext): @@ -25,7 +36,10 @@ sys.exit(1) self.distribution.ext_modules[:] = cythonize( - self.distribution.ext_modules, include_path=sys.path) + self.distribution.ext_modules, + include_path=sys.path, + compiler_directives={'embedsignature': True}) + _build_ext.finalize_options(self) class TestCommand(Command): @@ -62,62 +76,22 @@ os.chdir(old_path) rmtree(tempdir_path) -with open('version.txt') as f: - VERSION = f.read()[:-1] - assert 2 <= len(VERSION.split('.')) <= 3 - extensions = [ - Extension('ppl.linear_algebra', - sources=['ppl/linear_algebra.pyx', 'ppl/ppl_shim.cc'], - depends=['ppl/*']), - Extension('ppl.mip_problem', - sources=['ppl/mip_problem.pyx', 'ppl/ppl_shim.cc'], - depends=['ppl/*']), - Extension('ppl.polyhedron', - sources = ['ppl/polyhedron.pyx', 'ppl/ppl_shim.cc'], - depends=['ppl/*']), - Extension('ppl.generator', - sources = ['ppl/generator.pyx', 'ppl/ppl_shim.cc'], - depends=['ppl/*']), - Extension('ppl.constraint', - sources = ['ppl/constraint.pyx', 'ppl/ppl_shim.cc'], - depends=['ppl/*']), - Extension('ppl.bit_arrays', - sources = ['ppl/bit_arrays.pyx', 'ppl/ppl_shim.cc'], - depends=['ppl/*']) + Extension('ppl.linear_algebra', sources=['ppl/linear_algebra.pyx', 'ppl/ppl_shim.cc']), + Extension('ppl.mip_problem', sources=['ppl/mip_problem.pyx', 'ppl/ppl_shim.cc']), + Extension('ppl.polyhedron', sources = ['ppl/polyhedron.pyx', 'ppl/ppl_shim.cc']), + Extension('ppl.generator', sources = ['ppl/generator.pyx', 'ppl/ppl_shim.cc']), + Extension('ppl.constraint', sources = ['ppl/constraint.pyx', 'ppl/ppl_shim.cc']), + Extension('ppl.congruence', sources=['ppl/congruence.pyx', 'ppl/ppl_shim.cc']), + Extension('ppl.bit_arrays', sources = ['ppl/bit_arrays.pyx', 'ppl/ppl_shim.cc']), ] setup( - name='pplpy', - version=VERSION, - description='Python PPL wrapper', - long_description=open("README.rst").read(), - author='Vincent Delecroix', - author_email='vincent.delecroix@labri.fr', - url='https://gitlab.com/videlec/pplpy', - download_url='https://pypi.org/project/pplpy/#files', - license='GPL v3', - platforms=['any'], - packages=['ppl'], - package_dir={'ppl': 'ppl'}, - package_data={'ppl': ['*.pxd', '*.h', '*.hh']}, - install_requires=['Cython', 'cysignals', 'gmpy2'], # For pip install, pip can't read setup_requires - include_dirs=['ppl'] + sys.path, - ext_modules=extensions, - classifiers=[ - "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", - "Programming Language :: C++", - "Programming Language :: Python", - "Development Status :: 3 - Alpha", - "Operating System :: Unix", - "Intended Audience :: Science/Research", - "Programming Language :: Python :: 2", - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - ], - keywords=['polyhedron', 'polytope', 'convex', 'mathematics', 'ppl', 'milp', 'linear-programming'], - cmdclass = {'build_ext': build_ext, 'test': TestCommand} + long_description = open("README.rst").read(), + package_dir = {'ppl': 'ppl'}, + package_data = {'ppl': ['*.pxd', '*.h', '*.hh']}, + include_dirs = ['ppl'] + sys.path, + ext_modules = extensions, + cmdclass = {'build_ext': build_ext, 'test': TestCommand}, + **kwds ) diff -Nru pplpy-0.8.4/tests/runtests.py pplpy-0.8.7/tests/runtests.py --- pplpy-0.8.4/tests/runtests.py 2019-02-14 10:09:44.000000000 +0000 +++ pplpy-0.8.7/tests/runtests.py 2021-01-20 18:47:15.000000000 +0000 @@ -11,7 +11,7 @@ print("Running pplpy doctests") print('-'*80) import doctest -for mod in [ppl, ppl.linear_algebra, ppl.mip_problem, ppl.polyhedron, ppl.generator, ppl.constraint, ppl.bit_arrays]: +for mod in [ppl, ppl.linear_algebra, ppl.mip_problem, ppl.polyhedron, ppl.generator, ppl.constraint, ppl.congruence, ppl.bit_arrays]: res = doctest.testmod(mod, optionflags=doctest.ELLIPSIS | doctest.REPORT_NDIFF) print(mod) print(res) diff -Nru pplpy-0.8.4/tox.ini pplpy-0.8.7/tox.ini --- pplpy-0.8.4/tox.ini 1970-01-01 00:00:00.000000000 +0000 +++ pplpy-0.8.7/tox.ini 2021-01-20 18:47:15.000000000 +0000 @@ -0,0 +1,9 @@ +[tox] +envlist = py27, py36, py37, py38 +skip_missing_interpreters = true + +[testenv] +whitelist_externals = make +commands = + {envpython} setup.py test + make -w -C docs html diff -Nru pplpy-0.8.4/version.txt pplpy-0.8.7/version.txt --- pplpy-0.8.4/version.txt 2019-02-28 15:20:24.000000000 +0000 +++ pplpy-0.8.7/version.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -0.8.4