JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.54k stars 5.47k forks source link

Hide LATEX markup in REPL help output #35936

Open cormullion opened 4 years ago

cormullion commented 4 years ago

I don't think naked LATEX code should be displayed when you ask for help in the REPL.

help?> imhist
search: imhist

  edges, count = imhist(img, nbins)
  edges, count = imhist(img, nbins, minval, maxval)
  edges, count = imhist(img, edges)

  Generates a histogram for the image over nbins spread between (minval, maxval]. Color images are
  automatically converted to grayscale.

  ...

  Details
  ≡≡≡≡≡≡≡≡≡

  One can consider a histogram as a piecewise-constant model of a probability density function f [1].
  Suppose that f has support on some interval I = [a,b]. Let m be an integer and a = a_1 < a_2 < \ldots <
  a_m < a_{m+1} = b a sequence of real numbers. Construct a sequence of intervals

I_1 = [a_1,a_2], I_2 = (a_2, a_3], \ldots, I_{m} = (a_m,a_{m+1}]

  which partition I into subsets I_j (j = 1, \ldots, m) on which f is constant. These subsets satisfy I_i
  \cap I_j = \emptyset, \forall i \neq j, and are commonly referred to as bins. Together they encompass the
  entire range of data values such that \sum_j |I_j | = | I |. Each bin has width w_j = |I_j| = a_{j+1} -
  a_j and height h_j which is the constant probability density over the region of the bin. Integrating the
  constant probability density over the width of the bin w_j yields a probability mass of \pi_j = h_j w_j
  for the bin.

  For a sample x_1, x_2, \ldots, x_N, let

n_j = \sum_{n = 1}^{N}\mathbf{1}_{(I_j)}(x_n),
\quad \text{where} \quad
\mathbf{1}_{(I_j)}(x) =
\begin{cases}
 1 & \text{if} x \in I_j,\\
 0 & \text{otherwise},
\end{cases},

  represents the number of samples falling into the interval I_j. An estimate for the probability mass of
  the jth bin is given by the relative frequency \hat{\pi} = \frac{n_j}{N}, and the histogram estimator of
  the probability density function is defined as

\begin{aligned}
\hat{f}_n(x)  & = \sum_{j = 1}^{m}\frac{n_j}{Nw_j} \mathbf{1}_{(I_j)}(x) \\
& = \sum_{j = 1}^{m}\frac{\hat{\pi}_j}{w_j} \mathbf{1}_{(I_j)}(x) \\
& = \sum_{j = 1}^{m}\hat{h}_j \mathbf{1}_{(I_j)}(x).
\end{aligned}

  The function \hat{f}_n(x) is a genuine density estimator because \hat{f}_n(x)  \ge 0 and

\begin{aligned}
\int_{-\infty}^{\infty}\hat{f}_n(x) \operatorname{d}x & = \sum_{j=1}^{m} \frac{n_j}{Nw_j} w_j \\
& = 1.
\end{aligned}
...
fredrikekre commented 4 years ago

Just filtering it out would look more confusing though, no?

cormullion commented 4 years ago

Yes, that would also be hard to read... :) I don't think there's an easy solution but it's not good for the user experience... :)

JeffBezanson commented 4 years ago

I guess it would be cool if we could at least replace some characters, like render \in as , but that only goes so far of course.

jebej commented 4 years ago

Does the Katex engine support UTF8 math symbols? If so we could do a find-replace to replace the commands in the docstrings with the actual symbol.

SebastianM-C commented 4 years ago

Does the Katex engine support UTF8 math symbols? If so we could do a find-replace to replace the commands in the docstrings with the actual symbol.

Yes, it does.