question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Latex not rendering in html, stdout output (such as plots, widgets, etc) for Python and Julia notebooks

See original GitHub issue

How are you mainly using the Jupyter extension?

  • Notebooks (.ipynb)
  • Interactive Window and or Cell Scripts (ex. .py files with #%%)
  • Both

What happened?

I wrote ?rand (for example) in a Julia notebook cell and executed the cell. The output of the cell was very difficult to read, as it appears to be unrendered LaTeX with strange coloring:

\begin{verbatim} rand([rng=GLOBAL_RNG], [S], [dims…]) \end{verbatim} Pick a random element or array of random elements from the set of values specified by \texttt{S}; \texttt{S} can be \begin{itemize} \item an indexable collection (for example \texttt{1:9} or \texttt{(‘x’, “y”, 😒)}),

What flavor of VS Code are you using?

Stable

Jupyter Extension Version

v2021.8.2041215044

Jupyter logs

\begin{verbatim}
rand([rng=GLOBAL_RNG], [S], [dims...])
\end{verbatim}
Pick a random element or array of random elements from the set of values specified by \texttt{S}; \texttt{S} can be
\begin{itemize}
\item an indexable collection (for example \texttt{1:9} or \texttt{('x', "y", :z)}),


\item an \texttt{AbstractDict} or \texttt{AbstractSet} object,


\item a string (considered as a collection of characters), or


\item a type: the set of values to pick from is then equivalent to \texttt{typemin(S):typemax(S)} for integers (this is not applicable to \href{@ref}{\texttt{BigInt}}), to $[0, 1)$ for floating point numbers and to $[0, 1)+i[0, 1)$ for complex floating point numbers;

\end{itemize}
\texttt{S} defaults to \href{@ref}{\texttt{Float64}}. When only one argument is passed besides the optional \texttt{rng} and is a \texttt{Tuple}, it is interpreted as a collection of values (\texttt{S}) and not as \texttt{dims}.
\begin{quote}
\textbf{compat}

Julia 1.1

Support for \texttt{S} as a tuple requires at least Julia 1.1.

\end{quote}
\section{Examples}
\begin{verbatim}
julia> rand(Int, 2)
2-element Array{Int64,1}:
 1339893410598768192
 1575814717733606317

julia> using Random

julia> rand(MersenneTwister(0), Dict(1=>2, 3=>4))
1=>2

julia> rand((2, 3))
3

julia> rand(Float64, (2, 3))
2×3 Array{Float64,2}:
 0.999717  0.0143835  0.540787
 0.696556  0.783855   0.938235
\end{verbatim}
\begin{quote}
\textbf{note}

Note

The complexity of \texttt{rand(rng, s::Union\{AbstractDict,AbstractSet\})} is linear in the length of \texttt{s}, unless an optimized method with constant complexity is available, which is the case for \texttt{Dict}, \texttt{Set} and \texttt{BitSet}. For more than a few calls, use \texttt{rand(rng, collect(s))} instead, or either \texttt{rand(rng, Dict(s))} or \texttt{rand(rng, Set(s))} as appropriate.

\end{quote}
\rule{\textwidth}{1pt}
\begin{verbatim}
rand([rng::AbstractRNG,] s::Sampleable)
\end{verbatim}
Generate one sample for \texttt{s}.
\begin{verbatim}
rand([rng::AbstractRNG,] s::Sampleable, n::Int)
\end{verbatim}
Generate \texttt{n} samples from \texttt{s}. The form of the returned object depends on the variate form of \texttt{s}:
\begin{itemize}
\item When \texttt{s} is univariate, it returns a vector of length \texttt{n}.


\item When \texttt{s} is multivariate, it returns a matrix with \texttt{n} columns.


\item When \texttt{s} is matrix-variate, it returns an array, where each element is a sample matrix.

rand([rng::AbstractRNG,] s::Sampleable, dim1::Int, dim2::Int...)   rand([rng::AbstractRNG,] s::Sampleable, dims::Dims)

\end{itemize}
Generate an array of samples from \texttt{s} whose shape is determined by the given dimensions. \rule{\textwidth}{1pt}
\begin{verbatim}
rand(rng::AbstractRNG, d::UnivariateDistribution)
\end{verbatim}
Generate a scalar sample from \texttt{d}. The general fallback is \texttt{quantile(d, rand())}. \rule{\textwidth}{1pt}
\begin{verbatim}
rand(rng, d)
\end{verbatim}
Extract a sample from the p-Generalized Gaussian distribution 'd'. The sampling procedure is implemented from from [1]. [1] Gonzalez-Farias, G., Molina, J. A. D., \& Rodríguez-Dagnino, R. M. (2009). Efficiency of the approximated shape parameter estimator in the generalized Gaussian distribution. IEEE Transactions on Vehicular Technology, 58(8), 4214-4223. \rule{\textwidth}{1pt}
\begin{verbatim}
rand(::AbstractRNG, ::Distributions.AbstractMvNormal)
\end{verbatim}
Sample a random vector from the provided multi-variate normal distribution. \rule{\textwidth}{1pt}
\begin{verbatim}
rand(::AbstractRNG, ::Sampleable)
\end{verbatim}
Samples from the sampler and returns the result. \rule{\textwidth}{1pt}
\begin{verbatim}
rand(d::Union{UnivariateMixture, MultivariateMixture})
\end{verbatim}
Draw a sample from the mixture model \texttt{d}.
\begin{verbatim}
rand(d::Union{UnivariateMixture, MultivariateMixture}, n)
\end{verbatim}
Draw \texttt{n} samples from \texttt{d}.

What coding language are you working with?

Julia

VS Code Version?

1.60.1

Python Extension Version

No response

Python Version

No response

Anaconda Version

No response

What OS are you running on?

Mac

Running Jupyter locally or remotely?

Local

Code of Conduct

  • I agree to follow this project’s Code of Conduct

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:20 (15 by maintainers)

github_iconTop GitHub Comments

4reactions
rchiodocommented, Sep 27, 2021

This is something that Jupyter supports so it should be supported in VS code (otherwise people can’t open notebooks generated with Jupyter).

2reactions
rchiodocommented, Sep 15, 2021

Thanks for the bug. It looks like the output is not being converted by VS code to the latex form.

Jupyter shows this for me:

image

VS code shows this:

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Latex not rendering in html, stdout output (such as plots ...
This is something that Jupyter supports so it should be supported in VS code (otherwise people can't open notebooks generated with Jupyter).
Read more >
latex jupyter notebook it does not work - Stack Overflow
In the Jupyter Notebook, this magic only renders the subset of latex defined by MathJax here. You must run the cell to display...
Read more >
Jupyter Notebooks — Python productivity for Zynq (Pynq)
The Jupyter Notebook is an interactive computing environment that enables users to author notebook documents that include: Live code; Interactive widgets; Plots ......
Read more >
1 Jupyter / IPython notebook hints and tips
IPython uses MathJax to render LaTeX, as in $y=ax^2+bx+c$. ... The only problem is that HTML does not print very well, especially with...
Read more >
nbconvert Documentation - Read the Docs
Using nbconvert enables: • presentation of information in familiar formats, such as PDF. • publishing of research using LaTeX and opens the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found