Skip to content

Add interactive extension#203

Merged
bvenn merged 7 commits intodeveloperfrom
interactive
May 30, 2022
Merged

Add interactive extension#203
bvenn merged 7 commits intodeveloperfrom
interactive

Conversation

@kMutagene
Copy link
Copy Markdown
Member

@kMutagene kMutagene commented May 25, 2022

This PR adds a formatting extension for .NET interactive, providing a formatter for the Matrix<'T> type as a POC, tightly oriented on my work for the Deedle.Interactive extension (fslaborg/Deedle#547). When both are merged, we will have a nice consistent display across both libs.

It completely overhauls the formatting for matrices as well, replacing the current StructuredFormatDisplay and making the FSI printer obsolete.

While i have confidence in it, pls do not merge before i added tests 😆

An example notebook can be seen here.

Notebook screenshot:

image

FSI screenshot:

image

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 25, 2022

Codecov Report

Merging #203 (8bdf0d2) into developer (63dd3b1) will increase coverage by 2.00%.
The diff coverage is 90.10%.

@@              Coverage Diff              @@
##           developer     #203      +/-   ##
=============================================
+ Coverage      29.49%   31.50%   +2.00%     
=============================================
  Files            123      124       +1     
  Lines          11610    11644      +34     
  Branches        2036     1784     -252     
=============================================
+ Hits            3424     3668     +244     
+ Misses          7649     7535     -114     
+ Partials         537      441      -96     
Impacted Files Coverage Δ
tests/FSharp.Stats.Tests/Main.fs 0.00% <0.00%> (ø)
tests/FSharp.Stats.Tests/Testing.fs 100.00% <ø> (+2.31%) ⬆️
tests/FSharp.Stats.Tests/TestExtensions.fs 84.00% <76.92%> (-9.34%) ⬇️
src/FSharp.Stats/AlgTypes.fs 28.61% <89.10%> (+6.00%) ⬆️
src/FSharp.Stats/Common/Common.fs 92.00% <92.00%> (ø)
tests/FSharp.Stats.Tests/Formatting.fs 100.00% <100.00%> (ø)
src/FSharp.Stats/List.fs 0.00% <0.00%> (-7.28%) ⬇️
src/FSharp.Stats/GlobalAssociations.fs 56.25% <0.00%> (-6.25%) ⬇️
src/FSharp.Stats/SpecialFunctions/Gamma.fs 58.02% <0.00%> (-2.47%) ⬇️
src/FSharp.Stats/Integration/Differentiation.fs 29.03% <0.00%> (-2.01%) ⬇️
... and 80 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 63dd3b1...8bdf0d2. Read the comment docs.

@kMutagene kMutagene marked this pull request as ready for review May 27, 2022 12:57
@kMutagene kMutagene requested a review from bvenn May 27, 2022 12:57
Comment on lines +27 to +29
"data": {
"text/html": [
"<div><div><strong>Restore sources</strong><ul><li><span> C:/Users/schne/source/repos/fslaborg/FSharp.Stats/pkg</span></li></ul></div><div></div><div><strong>Installed Packages</strong><ul><li><span>FSharp.Stats, 0.0.0-dev</span></li><li><span>FSharp.Stats.Interactive, 0.0.0-dev</span></li></ul></div></div>"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want the cell outputs to be preserved?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes- i thought it would be nice that you can directly see the output when looking at the sample notebook on github

Comment thread src/FSharp.Stats.Interactive/test.ipynb Outdated
"\n",
"The version of the package is always `0.0.0-dev`.\n",
"\n",
"To rre-run the build/repack you have to restart the notebook kernel, otherwise we cannot remove the referenced local nuget package."
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo rre-run

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

| :? System.Double as f ->
match f with
| f when f <= -10000. -> sprintf "%.2g" f
| f when f < 0. -> sprintf "%.2f" f
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -0,0 +1,86 @@
module FormattingTests
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are nans and infinities printed properly?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added tests for both individual formatting and a matrix containing mixed values of all cases.

Comment thread src/FSharp.Stats.Interactive/test.ipynb Outdated
"data": {
"text/html": [
"<div><div><strong>Restore sources</strong><ul><li><span> C:/Users/schne/source/repos/fslaborg/FSharp.Stats/pkg</span></li></ul></div><div></div><div><strong>Installed Packages</strong><ul><li><span>FSharp.Stats, 0.0.0-dev</span></li><li><span>FSharp.Stats.Interactive, 0.0.0-dev</span></li></ul></div></div>"
"<div><div><strong>Restore sources</strong><ul><li><span> C:/Users/schne/source/repos/fslaborg/FSharp.Stats/pkg</span></li></ul></div><div></div><div><strong>Installed Packages</strong><ul><li><span>FSharp.Stats, 0.0.1-dev</span></li><li><span>FSharp.Stats.Interactive, 0.0.1-dev</span></li></ul></div></div>"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In L11 you wrote "The version of the package is always 0.0.0-dev.", but here you changed it to 0.0.1-dev. Is that intended?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@bvenn bvenn merged commit 5133c86 into developer May 30, 2022
@bvenn bvenn deleted the interactive branch May 30, 2022 08:31
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

Successfully merging this pull request may close these issues.

3 participants