-
-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Base.show(model) calling print on Jupyter #957
Comments
If something is annoying, we're likely to accept a PR fixing it. |
Ref #1180 |
This is going to take some refactoring, because the issue is that we have a mix of In the REPL, Lines 152 to 161 in a171d75
but in IJulia/Documenter, ending a cell with Lines 195 to 197 in a171d75
but calling Lines 192 to 194 in a171d75
To bring some sanity, I'd propose
The only breaking change for this from a user-perspective is that models in IJulia would show a summary by default, and you'd have to use Proof-of-conceptstruct Model end
function _print_summary(io::IO, model::Model)
print(io, "model summary")
end
function _print_model(io::IO, model::Model)
print(io, "full model")
end
function _print_latex(io::IO, model::Model)
print(io, "\$\$\\min Model + latex\$\$")
end
Base.show(io::IO, model::Model) = _print_summary(io, model)
struct LaTeXModel{T}
model::T
end
function Base.show(io::IO, model::LaTeXModel)
return print(io, sprint(_print_latex, model.model))
end
function Base.show(io::IO, ::MIME"text/latex", model::LaTeXModel)
_print_latex(io, model.model)
end
function Base.print(io::IO, model::Model; latex::Bool = false)
if latex
return LaTeXModel(model)
else
_print_model(io, model)
end
end
Base.print(model::Model; latex::Bool = false) = print(stdout, model; latex=latex) Output from IJuliaOutput from the REPL |
Hello
Whenever a model is defined in Jupyter, the output is the full printout of the model, which can be annoying (many many lines of output). Is this the intended behavior?.
regards
Braulio
The text was updated successfully, but these errors were encountered: