diff --git a/src/nlp_expr.jl b/src/nlp_expr.jl index 05eee2d7c2f..fa075adccf3 100644 --- a/src/nlp_expr.jl +++ b/src/nlp_expr.jl @@ -156,8 +156,8 @@ function function_string(mime::MIME, x::GenericNonlinearExpr) if arg.head in _PREFIX_OPERATORS && length(arg.args) > 1 print(io, p_open) push!(stack, p_close) - l = ceil(TERM_LIMIT_FOR_PRINTING[] / 2) - r = floor(TERM_LIMIT_FOR_PRINTING[] / 2) + l = ceil(_TERM_LIMIT_FOR_PRINTING[] / 2) + r = floor(_TERM_LIMIT_FOR_PRINTING[] / 2) skip_indices = (1+l):(length(arg.args)-r) for i in length(arg.args):-1:1 if i in skip_indices diff --git a/src/print.jl b/src/print.jl index 11525632e27..5847ab3922b 100644 --- a/src/print.jl +++ b/src/print.jl @@ -606,22 +606,22 @@ function _term_string(coef, factor) end """ - const TERM_LIMIT_FOR_PRINTING = Ref{Int}(60) + const _TERM_LIMIT_FOR_PRINTING = Ref{Int}(60) A global constant used to control when terms are omitted when printing expressions. -Get and set this value using `TERM_LIMIT_FOR_PRINTING[]`. +Get and set this value using `_TERM_LIMIT_FOR_PRINTING[]`. ```julia -julia> TERM_LIMIT_FOR_PRINTING[] +julia> _TERM_LIMIT_FOR_PRINTING[] 60 -julia> TERM_LIMIT_FOR_PRINTING[] = 10 +julia> _TERM_LIMIT_FOR_PRINTING[] = 10 10 ``` """ -const TERM_LIMIT_FOR_PRINTING = Ref{Int}(60) +const _TERM_LIMIT_FOR_PRINTING = Ref{Int}(60) _terms_omitted(::MIME, n::Int) = "[[...$n terms omitted...]]" @@ -630,7 +630,7 @@ function _terms_omitted(::MIME"text/latex", n::Int) end function _terms_to_truncated_string(mode, terms) - m = TERM_LIMIT_FOR_PRINTING[] + m = _TERM_LIMIT_FOR_PRINTING[] if length(terms) <= 2 * m return join(terms) end diff --git a/test/test_print.jl b/test/test_print.jl index c55346a3122..e426e92dc87 100644 --- a/test/test_print.jl +++ b/test/test_print.jl @@ -977,13 +977,13 @@ function test_truncated_printing() "x_{30} + [[\\ldots\\text{940 terms omitted}\\ldots]] + x_{971}", function_string(MIME("text/latex"), y), ) - ret = TERM_LIMIT_FOR_PRINTING[] - TERM_LIMIT_FOR_PRINTING[] = 3 + ret = _TERM_LIMIT_FOR_PRINTING[] + _TERM_LIMIT_FOR_PRINTING[] = 3 @test function_string(MIME("text/plain"), y) == "x[1] + x[2] + [[...997 terms omitted...]] + x[1000]" @test function_string(MIME("text/latex"), y) == "x_{1} + x_{2} + [[\\ldots\\text{997 terms omitted}\\ldots]] + x_{1000}" - TERM_LIMIT_FOR_PRINTING[] = ret + _TERM_LIMIT_FOR_PRINTING[] = ret return end