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

nteract doesnt interpret formulae #5

Open
sonulohani opened this issue Mar 30, 2020 · 9 comments
Open

nteract doesnt interpret formulae #5

sonulohani opened this issue Mar 30, 2020 · 9 comments
Assignees

Comments

@sonulohani
Copy link

Application or Package Used
VS code

Describe the bug
The section $y^{pred}= \text{[0 if y_score < 0.5 else 1]}$ didn't get interpreted properly in VSCode however I can see this properly interpreted in the Jupyter notebook in the browser.
Please visit this link for more info:- VSCode Python Extension bug

To Reproduce
Steps to reproduce the behavior:

  1. Go to VSCode
  2. Create ipynb file
  3. Put this code in the markdown section
<pre>
<font color='red'><b>A.</b></font> Compute performance metrics for the given data <strong>5_a.csv</strong>
   <b>Note 1:</b> in this data you can see number of positive points >> number of negatives points
   <b>Note 2:</b> use pandas or numpy to read the data from <b>5_a.csv</b>
   <b>Note 3:</b> you need to derive the class labels from given score</pre> $y^{pred}= \text{[0 if y_score < 0.5 else 1]}$

<pre>
<ol>
<li> Compute Confusion Matrix </li>
<li> Compute F1 Score </li>
<li> Compute AUC Score, you need to compute different thresholds and for each threshold compute tpr,fpr and then use               numpy.trapz(tpr_array, fpr_array) <a href='https://stackoverflow.com/q/53603376/4084039'>https://stackoverflow.com/q/53603376/4084039</a>, <a href='https://stackoverflow.com/a/39678975/4084039'>https://stackoverflow.com/a/39678975/4084039</a> Note: it should be numpy.trapz(tpr_array, fpr_array) not numpy.trapz(fpr_array, tpr_array)</li>
<li> Compute Accuracy Score </li>
</ol>
</pre>
  1. See formulae is printed as code instead of showing it as formulae.

Expected behavior
In the Jupyter notebook, I can see the formulae is interpreted properly.

Screenshots
VS Code Screenshot
VS Code Screenshot

Jupyter notebook Screenshot
Jupyter notebook Screenshot

Desktop (please complete the following information):

  • OS: Windows
  • Editor: VS Code
  • Version: 1.43.2
@captainsafia
Copy link
Member

Thanks for opening this issue, @sonulohani!

Indeed, MathJax rendering has been a cumbersome bug for a few months now. My immediate notes on the problem:

  • The @nteract/mathjax package works fine independently.
  • When @nteract/mathjax is used within @nteract/markdown, the math rendering is finnicky.
  • Math rendering is also finicky in cell outputs.

Tagging this issue as new-contributor-friendly since it is localized enough to require a small change.

Do you mind sharing the notebook you used in the examples above for verification?

@sonulohani
Copy link
Author

Here is the python notebook which you can use to check

bug.zip

@sonulohani
Copy link
Author

@captainsafia Are you guys working on the fix. The bug nteract/nteract#2924 you closed was opened 2 years back.

@captainsafia
Copy link
Member

The issue referenced above isn't an exact duplicate of this one but is kept as a reference.

To clarify, rendering of math works using the @nteract/mathjax package as seen below:

Screen Shot 2020-04-27 at 5 12 22 PM

The new seems to after LaTeX within markdown files or anywhere where the @nteract/mathjax library is used.

We did some work a couple of years ago to introduce the MathJax library. This regression is separate from the issues above (but perhaps related).

nteract is volunteer-based so there's not time to address everything on the backlog but we'll let you know once this makes it onto one of the monthly release milestones. Thanks for your patience!

@willingc
Copy link
Member

willingc commented May 9, 2020

@sonulohani I was able to get the formula in your example to render in a markdown cell by placing the formula on a new line.

Screen Shot 2020-05-09 at 3 16 07 AM

@captainsafia I think this may be more about how the markdown rendering works than a MathJax issue. Markdown is expecting a blank line in order to render the formula.

@captainsafia
Copy link
Member

Migrating this issue to the markdown repo since the issue resides there.

Interesting observation, @willingc! Our markdown renderer is currently configured to support both inline and block math (ref).

This analysis might mean that there is a bug in the function that parses inline math blocks (ref).

@captainsafia captainsafia transferred this issue from nteract/nteract May 12, 2020
@sonulohani
Copy link
Author

@sonulohani I was able to get the formula in your example to render in a markdown cell by placing the formula on a new line.

Screen Shot 2020-05-09 at 3 16 07 AM

@captainsafia I think this may be more about how the markdown rendering works than a MathJax issue. Markdown is expecting a blank line in order to render the formula.

If the example works in Jupyter notebook regardless of adding new line or not, then it should work with nteract also. Anyway thanks for your findings. This will help devs to fix the issue more sooner.

@sonulohani
Copy link
Author

sonulohani commented Jun 2, 2020

Here is another ipynb markdown for testing:-

test.zip

@ramantehlan
Copy link
Member

ramantehlan commented Jun 8, 2020

Thank you, @willingc, for the observation. After creating multiple use cases for how the formula can be used and testing it here, I found that the regex we are using is working.

However, It doesn't work when the formula is inside HTML tags and when it is in the new line with space at the beginning. The same is demonstrated below.

nteract

markldown-test

It works in the jupyter notebook and jupyter lab, but when it's in the new line with space at the beginning, it doesn't work for it either.

Jupyter notebook.

jupyter-test

I will look into over the weekend.

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

No branches or pull requests

4 participants