@@ -10,6 +10,14 @@ Controls depth of tree printing globally for Convex.jl
1010"""
1111const MAXDEPTH = Ref (3 )
1212
13+ """
14+ const MAXWIDTH = Ref(15)
15+
16+ Controls width of tree printing globally for Convex.jl
17+ """
18+ const MAXWIDTH= Ref (15 )
19+
20+
1321"""
1422 show_id(io::IO, x::Union{AbstractExpr, Constraint}; digits = 3)
1523
@@ -115,7 +123,7 @@ without the final newline. Used for `show` methods which
115123invoke `print_tree`.
116124"""
117125function print_tree_rstrip (io:: IO , x)
118- str = sprint (TreePrint. print_tree, x, MAXDEPTH[])
126+ str = sprint (TreePrint. print_tree, x, MAXDEPTH[], MAXWIDTH[] )
119127 print (io, rstrip (str))
120128end
121129
@@ -134,7 +142,7 @@ struct ConstraintRoot
134142 constraint:: Constraint
135143end
136144
137- TreePrint. print_tree (io:: IO , c:: Constraint , maxdepth = 5 ) = TreePrint. print_tree (io, ConstraintRoot (c), maxdepth )
145+ TreePrint. print_tree (io:: IO , c:: Constraint , args ... ; kwargs ... ) = TreePrint. print_tree (io, ConstraintRoot (c), args ... ; kwargs ... )
138146AbstractTrees. children (c:: ConstraintRoot ) = AbstractTrees. children (c. constraint)
139147AbstractTrees. printnode (io:: IO , c:: ConstraintRoot ) = AbstractTrees. printnode (io, c. constraint)
140148
@@ -143,7 +151,7 @@ show(io::IO, c::Constraint) = print_tree_rstrip(io, c)
143151struct ExprRoot
144152 expr:: AbstractExpr
145153end
146- TreePrint. print_tree (io:: IO , e:: AbstractExpr , maxdepth = 5 ) = TreePrint. print_tree (io, ExprRoot (e), maxdepth )
154+ TreePrint. print_tree (io:: IO , e:: AbstractExpr , args ... ; kwargs ... ) = TreePrint. print_tree (io, ExprRoot (e), args ... ; kwargs ... )
147155AbstractTrees. children (e:: ExprRoot ) = AbstractTrees. children (e. expr)
148156AbstractTrees. printnode (io:: IO , e:: ExprRoot ) = AbstractTrees. printnode (io, e. expr)
149157
@@ -167,15 +175,15 @@ AbstractTrees.children(p::ProblemConstraintsRoot) = p.constraints
167175AbstractTrees. printnode (io:: IO , p:: ProblemConstraintsRoot ) = print (io, " subject to" )
168176
169177
170- function TreePrint. print_tree (io:: IO , p:: Problem , maxdepth = 5 )
171- TreePrint. print_tree (io, ProblemObjectiveRoot (p. head, p. objective), maxdepth )
178+ function TreePrint. print_tree (io:: IO , p:: Problem , args ... ; kwargs ... )
179+ TreePrint. print_tree (io, ProblemObjectiveRoot (p. head, p. objective), args ... ; kwargs ... )
172180 if ! (isempty (p. constraints))
173- TreePrint. print_tree (io, ProblemConstraintsRoot (p. constraints), maxdepth )
181+ TreePrint. print_tree (io, ProblemConstraintsRoot (p. constraints), args ... ; kwargs ... )
174182 end
175183end
176184
177185function show (io:: IO , p:: Problem )
178- TreePrint. print_tree (io, p, MAXDEPTH[])
186+ TreePrint. print_tree (io, p, MAXDEPTH[], MAXWIDTH[] )
179187 print (io, " \n current status: $(p. status) " )
180188 if p. status == " solved"
181189 print (io, " with optimal value of $(round (p. optval, digits= 4 )) " )
0 commit comments