Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge branch 'public/20548' into 7.2.rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric Chapoton committed May 8, 2016
2 parents abc779b + ca3d653 commit 46fe07f
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 87 deletions.
3 changes: 2 additions & 1 deletion src/sage/numerical/backends/cvxopt_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ AUTHORS:
# (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************
from __future__ import print_function

from sage.numerical.mip import MIPSolverException
from cvxopt import solvers
Expand Down Expand Up @@ -788,7 +789,7 @@ cdef class CVXOPTBackend(GenericBackend):
sage: p.problem_name()
''
sage: p.problem_name("There once was a french fry")
sage: print p.problem_name()
sage: print(p.problem_name())
There once was a french fry
"""
if name == NULL:
Expand Down
3 changes: 2 additions & 1 deletion src/sage/numerical/backends/cvxopt_sdp_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ AUTHORS:
# (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************
from __future__ import print_function

from sage.numerical.sdp import SDPSolverException
from sage.matrix.all import Matrix
Expand Down Expand Up @@ -593,7 +594,7 @@ cdef class CVXOPTSDPBackend(GenericSDPBackend):
sage: from sage.numerical.backends.generic_sdp_backend import get_solver
sage: p = get_solver(solver = "CVXOPT")
sage: p.problem_name("There once was a french fry")
sage: print p.problem_name()
sage: print(p.problem_name())
There once was a french fry
"""
if name == NULL:
Expand Down
8 changes: 4 additions & 4 deletions src/sage/numerical/backends/glpk_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ AUTHORS:
# (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************

from __future__ import print_function

from sage.ext.memory_allocator cimport MemoryAllocator
from sage.numerical.mip import MIPSolverException
Expand Down Expand Up @@ -338,7 +338,7 @@ cdef class GLPKBackend(GenericBackend):
sage: from sage.numerical.backends.generic_backend import get_solver
sage: p = get_solver(solver = "GLPK")
sage: p.problem_name("There once was a french fry")
sage: print p.problem_name()
sage: print(p.problem_name())
There once was a french fry
"""
cdef char * n
Expand Down Expand Up @@ -2287,8 +2287,8 @@ cdef class GLPKBackend(GenericBackend):
if res == 0:
with open(fname) as f:
for line in f:
print line,
print
print(line, end=" ")
print("\n")

return res

Expand Down
43 changes: 22 additions & 21 deletions src/sage/numerical/backends/glpk_graph_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Classes and methods
# (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************
from __future__ import print_function

from sage.libs.glpk.constants cimport *
from sage.libs.glpk.graph cimport *
Expand Down Expand Up @@ -583,8 +584,8 @@ cdef class GLPKGraphBackend(object):
sage: gbe.vertices()
['A', 'B']
sage: for ed in gbe.edges():
... print ed[0], ed[1], ed[2]['cap'], ed[2]['cost'], ed[2]['low']
A B 10.0 5.0 0.0
....: print((ed[0], ed[1], ed[2]['cap'], ed[2]['cost'], ed[2]['low']))
('A', 'B', 10.0, 5.0, 0.0)
sage: gbe.add_edge("B", "C", {"low":0.0, "cap":10.0, "cost":'5'})
Traceback (most recent call last):
...
Expand Down Expand Up @@ -637,20 +638,20 @@ cdef class GLPKGraphBackend(object):
sage: edges.append(("B", "C"))
sage: gbe.add_edges(edges)
sage: for ed in gbe.edges():
... print ed[0], ed[1], ed[2]['cap'], ed[2]['cost'], ed[2]['low']
A B 10.0 5.0 0.0
B C 0.0 0.0 0.0
....: print((ed[0], ed[1], ed[2]['cap'], ed[2]['cost'], ed[2]['low']))
('A', 'B', 10.0, 5.0, 0.0)
('B', 'C', 0.0, 0.0, 0.0)
sage: edges = [("C", "D", {"low":0.0, "cap":10.0, "cost":5})]
sage: edges.append(("C", "E", 5))
sage: gbe.add_edges(edges)
Traceback (most recent call last):
...
TypeError: Argument 'params' has incorrect type ...
sage: for ed in gbe.edges():
... print ed[0], ed[1], ed[2]['cap'], ed[2]['cost'], ed[2]['low']
A B 10.0 5.0 0.0
B C 0.0 0.0 0.0
C D 10.0 5.0 0.0
....: print((ed[0], ed[1], ed[2]['cap'], ed[2]['cost'], ed[2]['low']))
('A', 'B', 10.0, 5.0, 0.0)
('B', 'C', 0.0, 0.0, 0.0)
('C', 'D', 10.0, 5.0, 0.0)
"""
for ed in edges:
self.add_edge(*ed)
Expand Down Expand Up @@ -742,8 +743,8 @@ cdef class GLPKGraphBackend(object):
sage: edges = [("A", "B"), ("A", "C"), ("B", "C")]
sage: gbe.add_edges(edges)
sage: ed = gbe.get_edge("A", "B")
sage: print ed[0], ed[1], ed[2]['x']
A B 0.0
sage: ed[0], ed[1], ed[2]['x']
('A', 'B', 0.0)
sage: gbe.get_edge("A", "F") is None
True
"""
Expand Down Expand Up @@ -782,9 +783,9 @@ cdef class GLPKGraphBackend(object):
sage: edges.append(("B", "C"))
sage: gbe.add_edges(edges)
sage: for ed in gbe.edges():
... print ed[0], ed[1], ed[2]['cost']
A B 5.0
B C 0.0
....: print((ed[0], ed[1], ed[2]['cost']))
('A', 'B', 5.0)
('B', 'C', 0.0)
"""

cdef int i = 1
Expand Down Expand Up @@ -931,8 +932,8 @@ cdef class GLPKGraphBackend(object):
sage: gbe.add_edges(edges)
sage: gbe.delete_edge("A", "B")
sage: gbe.delete_edge("B", "C", {"low":0.0, "cap":10.0, "cost":20})
sage: print gbe.edges()[0][0], gbe.edges()[0][1], gbe.edges()[0][2]['cost']
B C 1.0
sage: gbe.edges()[0][0], gbe.edges()[0][1], gbe.edges()[0][2]['cost']
('B', 'C', 1.0)
"""

cdef int i = self._find_vertex(u)
Expand Down Expand Up @@ -1006,8 +1007,8 @@ cdef class GLPKGraphBackend(object):
sage: gbe.delete_edges(edges[1:])
sage: len(gbe.edges())
1
sage: print gbe.edges()[0][0], gbe.edges()[0][1], gbe.edges()[0][2]['cap']
A B 10.0
sage: gbe.edges()[0][0], gbe.edges()[0][1], gbe.edges()[0][2]['cap']
('A', 'B', 10.0)
"""

for edge in edges:
Expand Down Expand Up @@ -1157,7 +1158,7 @@ cdef class GLPKGraphBackend(object):
sage: gbe.mincost_okalg()
1020.0
sage: for ed in gbe.edges():
... print ed[0], "->", ed[1], ed[2]["x"]
....: print("{} -> {} {}".format(ed[0], ed[1], ed[2]["x"]))
0 -> 6 0.0
0 -> 5 25.0
0 -> 4 10.0
Expand Down Expand Up @@ -1339,8 +1340,8 @@ cdef class GLPKGraphBackend(object):
sage: gbe.cpp()
7.0
sage: v = gbe.get_vertex('1')
sage: print 1, v["rhs"], v["es"], v["ls"] # abs tol 1e-6
1 1.0 0.0 2.0
sage: 1, v["rhs"], v["es"], v["ls"] # abs tol 1e-6
(1, 1.0, 0.0, 2.0)
"""

return glp_cpp(self.graph, 0, 2 * sizeof(double),
Expand Down
3 changes: 2 additions & 1 deletion src/sage/numerical/backends/interactivelp_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ AUTHORS:
# (at your option) any later version.
# http://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
Expand Down Expand Up @@ -839,7 +840,7 @@ cdef class InteractiveLPBackend:
sage: from sage.numerical.backends.generic_backend import get_solver
sage: p = get_solver(solver = "InteractiveLP")
sage: p.problem_name("There_once_was_a_french_fry")
sage: print p.problem_name()
sage: print(p.problem_name())
There_once_was_a_french_fry
"""
if name == NULL:
Expand Down
3 changes: 2 additions & 1 deletion src/sage/numerical/backends/ppl_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ AUTHORS:
# the License, or (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************
from __future__ import print_function

from sage.numerical.mip import MIPSolverException
from sage.libs.ppl import MIP_Problem, Variable, Variables_Set, Linear_Expression, Constraint, Generator
Expand Down Expand Up @@ -817,7 +818,7 @@ cdef class PPLBackend(GenericBackend):
sage: from sage.numerical.backends.generic_backend import get_solver
sage: p = get_solver(solver = "PPL")
sage: p.problem_name("There once was a french fry")
sage: print p.problem_name()
sage: print(p.problem_name())
There once was a french fry
"""
if name == NULL:
Expand Down
25 changes: 13 additions & 12 deletions src/sage/numerical/interactive_simplex_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,10 @@
# the License, or (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************
from __future__ import print_function


import operator, re
import operator
import re


from copy import copy
Expand Down Expand Up @@ -233,13 +234,13 @@ def _assemble_arrayl(lines, stretch=None):
sage: from sage.numerical.interactive_simplex_method \
....: import _assemble_arrayl
sage: lines = ["1 + 1", "2"]
sage: print _assemble_arrayl(lines)
sage: print(_assemble_arrayl(lines))
%notruncate
\begin{array}{l}
1 + 1\\
2
\end{array}
sage: print _assemble_arrayl(lines, 1.5)
sage: print(_assemble_arrayl(lines, 1.5))
%notruncate
\renewcommand{\arraystretch}{1.500000}
\begin{array}{l}
Expand Down Expand Up @@ -301,7 +302,7 @@ def _latex_product(coefficients, variables,
....: _latex_product
sage: var("x, y")
(x, y)
sage: print _latex_product([-1, 3], [x, y])
sage: print(_latex_product([-1, 3], [x, y]))
- \mspace{-6mu}&\mspace{-6mu} x \mspace{-6mu}&\mspace{-6mu} + \mspace{-6mu}&\mspace{-6mu} 3 y
"""
entries = []
Expand Down Expand Up @@ -755,7 +756,7 @@ def _latex_(self):
sage: b = (1000, 1500)
sage: c = (10, 5)
sage: P = InteractiveLPProblem(A, b, c, ["C", "B"], variable_type=">=")
sage: print P._latex_()
sage: print(P._latex_())
\begin{array}{l}
\begin{array}{lcrcrcl}
\max \mspace{-6mu}&\mspace{-6mu} \mspace{-6mu}&\mspace{-6mu} 10 C \mspace{-6mu}&\mspace{-6mu} + \mspace{-6mu}&\mspace{-6mu} 5 B \mspace{-6mu}&\mspace{-6mu} \mspace{-6mu}&\mspace{-6mu} \\
Expand Down Expand Up @@ -807,7 +808,7 @@ def _repr_(self):
sage: b = (1000, 1500)
sage: c = (10, 5)
sage: P = InteractiveLPProblem(A, b, c, ["C", "B"], variable_type=">=")
sage: print P._repr_()
sage: print(P._repr_())
LP problem (use typeset mode to see details)
"""
return "LP problem (use typeset mode to see details)"
Expand Down Expand Up @@ -2585,7 +2586,7 @@ def _html_(self):
sage: c = (10, 5)
sage: P = InteractiveLPProblemStandardForm(A, b, c)
sage: D = P.initial_dictionary()
sage: print D._html_()
sage: print(D._html_())
\begin{equation*}
...
\end{equation*}
Expand Down Expand Up @@ -2647,10 +2648,10 @@ def _repr_(self):
sage: c = (10, 5)
sage: P = InteractiveLPProblemStandardForm(A, b, c)
sage: D = P.initial_dictionary()
sage: print D._repr_()
sage: print(D._repr_())
LP problem dictionary (use typeset mode to see details)
sage: D = P.revised_dictionary()
sage: print D._repr_()
sage: print(D._repr_())
LP problem dictionary (use typeset mode to see details)
"""
return "LP problem dictionary (use typeset mode to see details)"
Expand Down Expand Up @@ -3496,7 +3497,7 @@ def _latex_(self):
sage: c = (10, 5)
sage: P = InteractiveLPProblemStandardForm(A, b, c)
sage: D = P.initial_dictionary()
sage: print D._latex_()
sage: print(D._latex_())
\renewcommand{\arraystretch}{1.5} %notruncate
\begin{array}{|rcrcrcr|}
\hline
Expand Down Expand Up @@ -4077,7 +4078,7 @@ def _latex_(self):
sage: D = P.revised_dictionary()
sage: D.enter(1)
sage: D.leave(3)
sage: print D._latex_()
sage: print(D._latex_())
%notruncate
\renewcommand{\arraystretch}{1.500000}
\begin{array}{l}
Expand Down
9 changes: 5 additions & 4 deletions src/sage/numerical/linear_functions.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ See :trac:`12091`::
# (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************
from __future__ import print_function

from cpython.object cimport Py_EQ, Py_GE, Py_LE, Py_GT, Py_LT

Expand Down Expand Up @@ -818,7 +819,7 @@ cdef class LinearFunction(LinearFunctionOrConstraint):
sage: x = p.new_variable()
sage: f = 0.5 + 3/2*x[1] + 0.6*x[3]
sage: for id, coeff in f.iteritems():
....: print 'id =', id, ' coeff =', coeff
....: print('id = {} coeff = {}'.format(id, coeff))
id = 0 coeff = 3/2
id = 1 coeff = 3/5
id = -1 coeff = 1/2
Expand Down Expand Up @@ -1538,7 +1539,7 @@ cdef class LinearConstraint(LinearFunctionOrConstraint):
sage: list(ieq)
[1, x_0, x_1, 3, x_2]
sage: for term in ieq:
....: print term
....: print(term)
1
x_0
x_1
Expand All @@ -1564,7 +1565,7 @@ cdef class LinearConstraint(LinearFunctionOrConstraint):
sage: eqns = 1 == b[0] == b[2] == 3 == b[3]; eqns
1 == x_0 == x_1 == 3 == x_2
sage: for lhs, rhs in eqns.equations():
....: print str(lhs) + ' == ' + str(rhs)
....: print(str(lhs) + ' == ' + str(rhs))
1 == x_0
x_0 == x_1
x_1 == 3
Expand Down Expand Up @@ -1597,7 +1598,7 @@ cdef class LinearConstraint(LinearFunctionOrConstraint):
1 <= x_0 <= x_1 <= 3 <= x_2
sage: for lhs, rhs in ieq.inequalities():
....: print str(lhs) + ' <= ' + str(rhs)
....: print(str(lhs) + ' <= ' + str(rhs))
1 <= x_0
x_0 <= x_1
x_1 <= 3
Expand Down
Loading

0 comments on commit 46fe07f

Please sign in to comment.