Skip to content
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

Model not properly displayed in IJulia #2328

Closed
ShuhuaGao opened this issue Sep 11, 2020 · 2 comments
Closed

Model not properly displayed in IJulia #2328

ShuhuaGao opened this issue Sep 11, 2020 · 2 comments

Comments

@ShuhuaGao
Copy link

When we do not append a semicolon after an expression, it will be displayed automatically in both REPL and IJulia (i.e., Jupyter notebook). At the beginning of an optimization program, we usually define a model. Such a model can be properly displayed automatically in REPL but not in IJulia.

A minimal reproducible example in IJulia

Snipaste_2020-09-11_20-50-50

As we see above, the show and the display("text/plain", model) methods work well. However, the single argument display only shows incomplete information. Besides, the automatic display at the end of a cell does not work as expected.

In this discussion as well as the official documentation, it is recommended to override show to customize the behaviour of display. It is strange that show works well as above in IJulia but not display.

This issue may be related to issue #2293.

Version info

julia> versioninfo()
Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, ivybridge)

(@v1.5) pkg> st IJulia
Status `C:\Users\Gao Shuhua\.julia\environments\v1.5\Project.toml`
  [7073ff75] IJulia v1.21.2

(@v1.5) pkg> st JuMP
Status `C:\Users\Gao Shuhua\.julia\environments\v1.5\Project.toml`
  [4076af6c] JuMP v0.21.3
@blegat
Copy link
Member

blegat commented Sep 11, 2020

Besides, the automatic display at the end of a cell does not work as expected.

What do you mean by this?

In IJulia, the mime is text/latex so we show the model in LaTeX. Here there is no objective and no constraint so the output you see is expected

@ShuhuaGao
Copy link
Author

Thanks for your quick response.

What do you mean by this?

I mean that we simply run a cell in Jupyter notebook without calling a display function like print, show, or display explicitly. By default, IJulia will display the final result of the cell automatically (similar to REPL) if we did not terminate it with a semicolon.

I figured it out according to your reply. Here, it seems IJulia tries to display the model using display("text/latex", model). However, in the beginning, the feasibility and the subject to are both empty, and thus the display shown above is actually right. I thought that the display in IJulia was identical to that in REPL, which was my mistake. To get the same display like that in REPL, we should call display("text/plain", model) or show(model) manually, as demonstrated in the above figure.

Once we have optimized the model, the default display in IJulia is obviously right now.

Snipaste_2020-09-12_11-05-38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants