2
$\begingroup$

V 12.1 on windows.

I use Associations allot as input for my dsolve solver I am writing. I do not use Dataset, other than to format the list of ODE's I am testing on in a nice way.

I noticed Dataset displays things differently based on order of associations in the list. Since some associations have more keys than others (some has initial conditions for example, some do not), I'd like the display to always shows the key names as header at top. Here is a MWE to explain

ClearAll[x,y];
ode1 = <|"ode" -> y'[x] + y'[x]^2 == x, "y" -> y, "x" -> x, "ic" -> 1 == y[0]|>;
ode2 = <|"ode" -> y'[x] + x - Sin[x] == 0, "y" -> z, "x" -> x|>;
ode3 = <|"ode" -> y'[x]^2 + x - Sin[x] == 0, "y" -> y, "x" -> x|>;
Dataset[{ode1, ode2, ode3}]

enter image description here

But what I want is the following, where now ode2 is first one in list, the one which has less keys than the first one.

Dataset[{ode2, ode1, ode3}]

enter image description here

Is this how it supposed to work by design? If there a way to tell Dataset to always format its output as in the second case above regardless of order of associations in list? I looked at help, but not seeing something obvious so far. May be I need to use HeaderDisplayFunction ? (new in V 12.1)

$\endgroup$

1 Answer 1

2
$\begingroup$

Dataset uses heuristic algorithms to try to interpret what you "want". Unfortunately this means a small change in your input data, like adding one more column, can greatly affect what Dataset does. I've found this more a problem in smaller experimental cases, like going from 3 to 4 columns. Not so much in going from 100 to 101. Much of this in the Wolfram documentation---but not in the introductions with the Titanic data or the planet data. I've tried to use those as building blocks for my own work, only to be thwarted by the heuristics. Nonetheless, keep trying. There are many nice things about Dataset. Also beware, if you go down to one row, Dataset automatically "flips" things and displays the columns as rows. That can be very confusing at first.

$\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.