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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interactive extension #203

Merged
merged 7 commits into from May 30, 2022
Merged

Add interactive extension #203

merged 7 commits into from May 30, 2022

Conversation

kMutagene
Copy link
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

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
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
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

"\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
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
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
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 @@
锘縨odule FormattingTests
Copy link
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
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.

@@ -26,7 +26,7 @@
{
"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
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
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.

None yet

3 participants