From ba61c9e22305cdee79e50a09075c4fb1af9db3d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 24 Feb 2019 13:30:29 +0100 Subject: [PATCH] py3: some tiny fixes in numerical folder --- src/sage/numerical/backends/interactivelp_backend.pyx | 11 ++++++----- src/sage/numerical/linear_functions.pyx | 6 +++--- src/sage/numerical/mip.pyx | 9 +++++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/sage/numerical/backends/interactivelp_backend.pyx b/src/sage/numerical/backends/interactivelp_backend.pyx index 4699adabc10..4a75c855c65 100644 --- a/src/sage/numerical/backends/interactivelp_backend.pyx +++ b/src/sage/numerical/backends/interactivelp_backend.pyx @@ -8,7 +8,7 @@ AUTHORS: """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2010 Nathann Cohen # Copyright (C) 2016 Matthias Koeppe # @@ -16,8 +16,8 @@ AUTHORS: # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** from __future__ import print_function from sage.numerical.mip import MIPSolverException @@ -25,6 +25,7 @@ from sage.numerical.interactive_simplex_method import InteractiveLPProblem, defa from sage.modules.all import vector from copy import copy + cdef class InteractiveLPBackend: """ MIP Backend that works with :class:`InteractiveLPProblem`. @@ -593,7 +594,7 @@ cdef class InteractiveLPBackend: sage: p.nrows() 0 sage: p.add_linear_constraints(5, 0, None) - sage: p.add_col(range(5), range(5)) + sage: p.add_col(list(range(5)), list(range(5))) sage: p.nrows() 5 """ @@ -614,7 +615,7 @@ cdef class InteractiveLPBackend: sage: from sage.numerical.backends.generic_backend import get_solver sage: p = get_solver(solver = "InteractiveLP") sage: p.add_linear_constraints(5, 0, None) - sage: p.add_col(range(5), range(5)) + sage: p.add_col(list(range(5)), list(range(5))) sage: p.solve() 0 sage: p.objective_coefficient(0,1) diff --git a/src/sage/numerical/linear_functions.pyx b/src/sage/numerical/linear_functions.pyx index 809631cfe6c..cd0e11457a4 100644 --- a/src/sage/numerical/linear_functions.pyx +++ b/src/sage/numerical/linear_functions.pyx @@ -809,7 +809,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint): cpdef iteritems(self): """ - Iterate over the index, coefficient pairs + Iterate over the index, coefficient pairs. OUTPUT: @@ -822,11 +822,11 @@ cdef class LinearFunction(LinearFunctionOrConstraint): sage: p = MixedIntegerLinearProgram(solver = 'ppl') sage: x = p.new_variable() sage: f = 0.5 + 3/2*x[1] + 0.6*x[3] - sage: for id, coeff in f.iteritems(): + sage: for id, coeff in sorted(f.iteritems()): ....: print('id = {} coeff = {}'.format(id, coeff)) + id = -1 coeff = 1/2 id = 0 coeff = 3/2 id = 1 coeff = 3/5 - id = -1 coeff = 1/2 """ return self._f.iteritems() diff --git a/src/sage/numerical/mip.pyx b/src/sage/numerical/mip.pyx index 436387d7eaf..e08467e4db1 100644 --- a/src/sage/numerical/mip.pyx +++ b/src/sage/numerical/mip.pyx @@ -224,14 +224,14 @@ AUTHORS: - Risan (2012/02): added extension for exact computation """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2012 Nathann Cohen # # Distributed under the terms of the GNU General Public License (GPL) # as published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** from __future__ import print_function from copy import copy @@ -241,6 +241,7 @@ from sage.structure.element import is_Matrix from sage.misc.cachefunc import cached_method from sage.misc.superseded import deprecation + cdef class MixedIntegerLinearProgram(SageObject): r""" The ``MixedIntegerLinearProgram`` class is the link between Sage, linear @@ -1420,7 +1421,7 @@ cdef class MixedIntegerLinearProgram(SageObject): values for the corresponding variables :: sage: x_sol = p.get_values(x) - sage: x_sol.keys() + sage: sorted(x_sol.keys()) [3, 5] Obviously, it also works with variables of higher dimension::