From 2b9dfaf3f65b330f921cedbcf8212272007087e6 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Sun, 3 Sep 2023 16:13:19 +0200 Subject: [PATCH 1/2] remove python2 parts --- ppl/generator.pyx | 43 ++++++++----------------------------------- 1 file changed, 8 insertions(+), 35 deletions(-) diff --git a/ppl/generator.pyx b/ppl/generator.pyx index 8314def..1e2b267 100644 --- a/ppl/generator.pyx +++ b/ppl/generator.pyx @@ -25,8 +25,6 @@ from gmpy2 cimport GMPy_MPZ_From_mpz, import_gmpy2 from cython.operator cimport dereference as deref from .linear_algebra cimport PPL_Coefficient_from_pyobject -import sys -cdef int PY_MAJOR_VERSION = sys.version_info.major # PPL can use floating-point arithmetic to compute integers cdef extern from "ppl.hh" namespace "Parma_Polyhedra_Library": @@ -667,24 +665,14 @@ cdef class Generator(object): """ le = Linear_Expression(self.coefficients(), 0) t = self.thisptr.type() - if PY_MAJOR_VERSION == 2: - if t == LINE or t == RAY: - return (_unpickle_generator, (self.type(), le)) - elif t == POINT or t == CLOSURE_POINT: - return (_unpickle_generator, (self.type(), le, self.divisor())) - else: - raise RuntimeError - elif PY_MAJOR_VERSION == 3: - if t == LINE: - return (Generator.line, (le,)) - elif t == RAY: - return (Generator.ray, (le,)) - elif t == POINT: - return (Generator.point, (le, self.divisor())) - elif t == CLOSURE_POINT: - return (Generator.closure_point, (le, self.divisor())) - else: - raise RuntimeError + if t == LINE: + return (Generator.line, (le,)) + elif t == RAY: + return (Generator.ray, (le,)) + elif t == POINT: + return (Generator.point, (le, self.divisor())) + elif t == CLOSURE_POINT: + return (Generator.closure_point, (le, self.divisor())) else: raise RuntimeError @@ -1224,18 +1212,3 @@ cdef _wrap_Poly_Gen_Relation(PPL_Poly_Gen_Relation relation): cdef Poly_Gen_Relation rel = Poly_Gen_Relation(True) rel.thisptr = new PPL_Poly_Gen_Relation(relation) return rel - -if PY_MAJOR_VERSION == 2: - def _unpickle_generator(*args): - t = args[0] - args = args[1:] - if t == 'line': - return Generator.line(*args) - elif t == 'ray': - return Generator.ray(*args) - elif t == 'point': - return Generator.point(*args) - elif t == 'closure_point': - return Generator.closure_point(*args) - else: - raise RuntimeError From a89006223291fd08023f0d73688a750c2086a74d Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Sun, 3 Sep 2023 16:16:16 +0200 Subject: [PATCH 2/2] remove use of __future__ --- ppl/__init__.py | 1 - ppl/bit_arrays.pyx | 2 -- ppl/congruence.pyx | 1 - ppl/constraint.pyx | 1 - ppl/generator.pyx | 1 - ppl/linear_algebra.pyx | 2 -- ppl/mip_problem.pyx | 1 - ppl/polyhedron.pyx | 1 - 8 files changed, 10 deletions(-) diff --git a/ppl/__init__.py b/ppl/__init__.py index d05cacc..e983530 100644 --- a/ppl/__init__.py +++ b/ppl/__init__.py @@ -126,7 +126,6 @@ Split the main code into several files. Remove the _mutable_immutable class. """ -from __future__ import absolute_import from .linear_algebra import ( Variable, Variables_Set, Linear_Expression, diff --git a/ppl/bit_arrays.pyx b/ppl/bit_arrays.pyx index ab43ad2..22de403 100644 --- a/ppl/bit_arrays.pyx +++ b/ppl/bit_arrays.pyx @@ -9,8 +9,6 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from __future__ import absolute_import, print_function - from libc.limits cimport ULONG_MAX from .ppl_decl cimport PPL_Bit_Row diff --git a/ppl/congruence.pyx b/ppl/congruence.pyx index 2b8b7bb..943ff6e 100644 --- a/ppl/congruence.pyx +++ b/ppl/congruence.pyx @@ -8,7 +8,6 @@ # 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 diff --git a/ppl/constraint.pyx b/ppl/constraint.pyx index e61a1ec..770bfce 100644 --- a/ppl/constraint.pyx +++ b/ppl/constraint.pyx @@ -19,7 +19,6 @@ # the License, or (at youroption) any later version. # http://www.gnu.org/licenses/ #***************************************************************************** -from __future__ import absolute_import, print_function from gmpy2 cimport GMPy_MPZ_From_mpz, import_gmpy2 from cython.operator cimport dereference as deref diff --git a/ppl/generator.pyx b/ppl/generator.pyx index 1e2b267..f1792dc 100644 --- a/ppl/generator.pyx +++ b/ppl/generator.pyx @@ -19,7 +19,6 @@ # the License, or (at youroption) any later version. # http://www.gnu.org/licenses/ #***************************************************************************** -from __future__ import absolute_import, print_function from gmpy2 cimport GMPy_MPZ_From_mpz, import_gmpy2 from cython.operator cimport dereference as deref diff --git a/ppl/linear_algebra.pyx b/ppl/linear_algebra.pyx index 58f2d79..1f837c4 100644 --- a/ppl/linear_algebra.pyx +++ b/ppl/linear_algebra.pyx @@ -20,8 +20,6 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from __future__ import absolute_import, print_function - cimport cython from gmpy2 cimport import_gmpy2, mpz, GMPy_MPZ_From_mpz, MPZ_Check diff --git a/ppl/mip_problem.pyx b/ppl/mip_problem.pyx index c17feec..2d0b737 100644 --- a/ppl/mip_problem.pyx +++ b/ppl/mip_problem.pyx @@ -19,7 +19,6 @@ # the License, or (at youroption) any later version. # http://www.gnu.org/licenses/ #***************************************************************************** -from __future__ import absolute_import, print_function from cysignals.signals cimport sig_on, sig_off from gmpy2 cimport import_gmpy2, GMPy_MPQ_From_mpz diff --git a/ppl/polyhedron.pyx b/ppl/polyhedron.pyx index 84e1bc0..19b2700 100644 --- a/ppl/polyhedron.pyx +++ b/ppl/polyhedron.pyx @@ -19,7 +19,6 @@ # the License, or (at youroption) any later version. # http://www.gnu.org/licenses/ #***************************************************************************** -from __future__ import absolute_import, print_function from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE from cysignals.signals cimport sig_on, sig_off