4
$\begingroup$

Currently I use Dataset to display an association in a nice to see way on the screen. However, only top level items are shown this way. And have to click on each item marked hidden ... to explicitly open it. But this now closes the main data that was showing before.

I am looking for a way to show all content in Association in nice way. Here is an example (this is a every reduced version of what I have. The actual association I use is much larger with embedded lists of associations in it)

data=<| "ode"->-x Sqrt[y[x]]+y'[x]==0,"ode_degree"->1,"original_ic"->{y[0]==1},
   "parsed_ic"->{},
   "sol_list"->{<|"sol"->y[x]->1/16 (x^4+4 x^2 c1+4 c1^2),"type"->"explicit",
   "is_singular"->False,"verified"->True|>,
    <|"sol"->y[x]->1/16 (x^4+4 x^2 c1),"type"->"explicit","is_singular"->False,
   "verified"->False|>}|>

Now I use

Dataset[data, MaxItems -> 20] (*100, 1000 no difference*)

Mathematica graphics

But there are more stuff in there. sol_list is list of associations. To see them I have to click on the {...} and now it shows as

Mathematica graphics

To close this and go back, I click on the little icon above it.

Is there a way to have everything open automatically and displayed on the screen regardless of how many items there are, so one does not have to keep clicking on each field to open it, even if an item itself is also an association inside an association?

I can use

Needs["GeneralUtilities`"]
data // PrettyForm

Mathematica graphics

But this is not as nice to see as the Dataset command.

I search FunctionRepository and found

 ResourceFunction["NiceGrid"][data]

Mathematica graphics

Which is OK but the sol_list which is list of associations is not formatted as Association. I also tried ResourceFunction["PrettyGrid"][data] but this does not work on Association.

Any idea for best way to display such an Association?

V 13.2.1 on windows

$\endgroup$

1 Answer 1

3
$\begingroup$
Dataset @ MapAt[Association, data, {"sol_list"}]

enter image description here

Alternatively,

Dataset[data][<|#, "sol_list" -> (Association[Slot["sol_list"]])|> &]

enter image description here

Also

datab = data;
datab["sol_list"] //= Association;

Dataset[datab]

enter image description here

See also: Dataset Interactive Control and Formatting

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.