Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean python2 specifics #28

Merged
merged 2 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ppl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions ppl/bit_arrays.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion ppl/congruence.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion ppl/constraint.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 8 additions & 36 deletions ppl/generator.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@
# 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
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":
Expand Down Expand Up @@ -667,24 +664,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

Expand Down Expand Up @@ -1224,18 +1211,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
2 changes: 0 additions & 2 deletions ppl/linear_algebra.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion ppl/mip_problem.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion ppl/polyhedron.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading