Skip to content

Commit

Permalink
Trac #27342: py3: some tiny fixes in numerical folder
Browse files Browse the repository at this point in the history
URL: https://trac.sagemath.org/27342
Reported by: chapoton
Ticket author(s): Frédéric Chapoton
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager authored and vbraun committed Feb 26, 2019
2 parents d526ff1 + ba61c9e commit ce983fe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
11 changes: 6 additions & 5 deletions src/sage/numerical/backends/interactivelp_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@ AUTHORS:
"""

#*****************************************************************************
# ****************************************************************************
# Copyright (C) 2010 Nathann Cohen <[email protected]>
# Copyright (C) 2016 Matthias Koeppe <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# 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
from sage.numerical.interactive_simplex_method import InteractiveLPProblem, default_variable_name
from sage.modules.all import vector
from copy import copy


cdef class InteractiveLPBackend:
"""
MIP Backend that works with :class:`InteractiveLPProblem`.
Expand Down Expand Up @@ -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
"""
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/sage/numerical/linear_functions.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint):

cpdef iteritems(self):
"""
Iterate over the index, coefficient pairs
Iterate over the index, coefficient pairs.
OUTPUT:
Expand All @@ -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()

Expand Down
9 changes: 5 additions & 4 deletions src/sage/numerical/mip.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ AUTHORS:
- Risan (2012/02): added extension for exact computation
"""

#*****************************************************************************
# ****************************************************************************
# Copyright (C) 2012 Nathann Cohen <[email protected]>
#
# 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
Expand All @@ -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
Expand Down Expand Up @@ -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::
Expand Down

0 comments on commit ce983fe

Please sign in to comment.