JerryI / wolfram-js-frontend

Dynamic Notebook Environment for Wolfram Language written in Javascript
https://jerryi.github.io/wljs-docs/
GNU General Public License v3.0
321 stars 15 forks source link

Output of a list of one association holding several TimeSeries is too verbose #313

Open Hachann opened 15 hours ago

Hachann commented 15 hours ago

Hello guys,

If you run this command in WLJS you end up with a very verbose output and an "Too long to display" message :

{<|"a" -> TimeSeries[RandomVariate[NormalDistribution[],10]], "b" -> TimeSeries[RandomVariate[NormalDistribution[],10]], "c" -> TimeSeries[RandomVariate[NormalDistribution[],10]], "a" -> TimeSeries[RandomVariate[NormalDistribution[],10]], "d" -> TimeSeries[RandomVariate[NormalDistribution[],10]], "e" -> TimeSeries[RandomVariate[NormalDistribution[],10]], "f" -> TimeSeries[RandomVariate[NormalDistribution[],10]], "g" -> TimeSeries[RandomVariate[NormalDistribution[],10]], "h" -> TimeSeries[RandomVariate[NormalDistribution[],10]], "i" -> TimeSeries[RandomVariate[NormalDistribution[],10]] |>}

If you run it in Mathematica, it outputs a short list of TimeSeries objects in an Association, which is not that long :

image

JerryI commented 14 hours ago

It is always a compromise, if you need a richer output or less laggy editor. If you don't plan to edit an output expression, one can just set $OutputCharactersLimit

PS: Each TimeSeries is relatively bulky if not converted to a reference

TimeSeries[(*VB[*) TemporalData[TimeSeries, {{{0.7647544974027236, -1.015909360329452, 0.5598542156401776, -0.6551330799058341, -0.3947288060191851, 0.751023188977947, -0.46004671067041963, 0.231171253434899, -0.5016082704018837, -0.013690246200312003}}, {{0, 9, 1}}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, ValueDimensions -> 1}}, False, 14.1] (*,*)(*"1:eJytVE1Lw0AQjVYFpSIoIniKxaMHg1SoN8UWC9VKU3p2292Uhf1iP1qD+N+dTZRqNU2LvUwmM5N5780MORvKXrIZBIE5APOs5YRigrvKUilMUvGJUzB38rUlNX+51RqJMcGx4xzpFMLJxtfHLS2FbQo8oNo6xPLEFpgHybA5BoeOpOgTruKUDyU7j67rjfpVju7rOtTYubesh2fRk9O/Ck++cfvk1LaEDyiZxjuQ61NObsK8dg9ME1MrdZb2rS9nPXuOkXjXOwThtCtYmoX72pFyKF8ZWlkM1FgKyFTBiRUSMEreIcn8NEp57EPuHlkUKkmFNQXKfSxaTvpvRpUF2yrll4OMHUO6gNvPmf97MYeQ6zqrnA0xnIIwcNYL7iFaAXZ51R7okViEYTMLZD9JsS7ZRx6RCsodD6kYaQLS7Zp1x/AMyqlUs1YGccWoGBdw8Hzfam1hiVaSIf/zqV1E7yuyyoq2fecJyJ15H9e9OpE="*)(*]VB*)]
JerryI commented 14 hours ago

After a certain limit those boxes will be converted to references and and an output will be shown, since the data will no long be inside a notebook cell

{<|"a" -> TimeSeries[RandomVariate[NormalDistribution[],200]], "b" -> TimeSeries[RandomVariate[NormalDistribution[],200]], "c" -> TimeSeries[RandomVariate[NormalDistribution[],200]], "a" -> TimeSeries[RandomVariate[NormalDistribution[],200]], "d" -> TimeSeries[RandomVariate[NormalDistribution[],200]], "e" -> TimeSeries[RandomVariate[NormalDistribution[],200]], "f" -> TimeSeries[RandomVariate[NormalDistribution[],200]], "g" -> TimeSeries[RandomVariate[NormalDistribution[],200]], "h" -> TimeSeries[RandomVariate[NormalDistribution[],200]]|>}

Screenshot 2024-11-29 at 11 32 31

Hachann commented 12 hours ago

Thank you for your kind answer.

I understand that editing the output is a plus over Mathematica notebook, but if more people are like me, then I think some users do not need this feature, especially if they are regular Mathematica user. The output is what is mostly desired, and we struggle to write the best input possible to compute the desired outcome.

Maybe offer the possibility in Preferences to make the output editable or not ? So that makes it trivial : if not enabled, the output should be approximately the same as in Mathematica ?

JerryI commented 12 hours ago

Thank you for your kind answer.

I understand that editing the output is a plus over Mathematica notebook, but if more people are like me, then I think some users do not need this feature, especially if they are regular Mathematica user. The output is what is mostly desired, and we struggle to write the best input possible to compute the desired outcome.

Maybe offer the possibility in Preferences to make the output editable or not ? So that makes it trivial : if not enabled, the output should be approximately the same as in Mathematica ?

In principle it does not matter, if the output is editable or not, the rendering is a problem, which can hang the whole notebook for seconds or minutes. And it is dangerous for UX.

Mathematica does it in a tricky way, it is a sort of a preview until you click on the output cell and then it is converted to a normal one. We could try to do it in a similar way instead of showing "output is too long". However it is question how to trim it properly or transform to have less impart on the editor.

For now I can suggest to make an option in the preferences which globally overrides the maximum output length, so one can set it once to your preferred value.

JerryI commented 10 hours ago

Added in this commit

Screenshot 2024-11-29 at 15 18 49

JerryI commented 10 hours ago

I would keep this as an enhancement issue, since most troubles comes from the way, how wljs-editor handles such widgets with inline data.

We rely heavily on recursive RegExp to find and hide the data from such objects like TimeSeries, which at some symbols combination involves a lot of backtracking. The editor itself can handle much more characters, however at some particular cases the parser struggles more, therefore we set a "safe" limit of 5000, which was tested on relatively slow machines from 2013.

However, those things can be improved, I am sure.