Bug introduced in 10.0 and fixed in 11.0.0

Dataset is new in 10.0

Note: In order to reproduce the bug, the symbol Dataset may need to be evaluated (to load its definitions) before defining toDataset.

My little function, from pre-10.2 ,to turn a headed table into a Dataset.

toDataset[table_List] := 
  Dataset@(Association /@ (Function[r, Thread[First[r] -> #] & /@ Rest[r]]@table));

In 10.2, ??toDataset shows something very odd indeed (after a big barf of messages).

Mathematica graphics

It appears to be something related to the head Dataset being on the RHS.

  • $\begingroup$ That is the example, the function definition itself is broken. Its not an application of that function that breaks, its defining the function that breaks. $\endgroup$
    – Ymareth
    Jul 24 '15 at 17:12
  • $\begingroup$ Yes, I've just tested on another machine and its fine. I jumped the gun. I may have a corrupt install. Thanks for checking. Except that was 10.1... doh! $\endgroup$
    – Ymareth
    Jul 24 '15 at 17:16
  • $\begingroup$ Tried on 10.2 on a different machine. When I do ??toDataset I get a spew of TextForm messages and a definition as above. Are you sure your running this on 10.2? Its fine on 10.1. $\endgroup$
    – Ymareth
    Jul 24 '15 at 17:19
  • $\begingroup$ I really didn't get it at first. Now I understand. I edited the question a bit for clarity. $\endgroup$
    – Szabolcs
    Jul 24 '15 at 17:34
  • $\begingroup$ Sorry for confusing things with 10.1. That is its full glory (gorey?). $\endgroup$
    – Ymareth
    Jul 24 '15 at 17:35

The problem appears to be due to a v10.2 bug in the Dataset visualization code that generates the box form of a dataset. It is not correctly distinguishing between Dataset being used as a constructor function and Dataset being used as the head of a constructed dataset. It assumes the latter case unconditionally, giving the exhibited messages for the former case.

As a work-around, we can temporarily block the errant definitions while we inspect toDataset:

Block[{Dataset}, Information[toDataset]]

information screenshot

The defect appears to be a subtle interaction bug between Information and Dataset since expressions like the following do not exhibit the bug:




The problem is more general than within the context of Information. Both of the following expressions also generate many warning messages:

Unevaluated @ Dataset @ (* ...expr from question... *)

Defer @ Dataset @ (* ...expr from question... *)

Furthermore, there appears to be an evaluation leak involved:

Unevaluated @ Dataset[Print["leak!"]]

evaluation leak screenshot

Defer @ Dataset[Print["leak!"]]

evaluation leak screenshot

This behaviour is very much like what happens with Graphics objects. The front-end attempts to render them in output cells, which implies evaluation:


Graphics leak screenshot

We might just have to live with this behaviour in both cases (although a way to turn it off would be useful, just as the debugger allows for graphics).

  • $\begingroup$ Basically, evaluation control structures like Defer and Unevaluated don't apply to typesetting. Notice that Defer @ Dataset[Print["leak!"]]; doesn't leak. $\endgroup$
    – Stefan R
    Jul 24 '15 at 21:18
  • 2
    $\begingroup$ @StefanR Indeed, that was my point about the similarity to Graphics. In fact, Dataset is a little better than Graphics in that it only renders when it is the outermost head. That is why the original problem is surprising: a Dataset is being rendered even though it appears in a non-top-level context, namely the right-hand-side of a definition. This is potentially dangerous, and a regression from v10.1. $\endgroup$
    – WReach
    Jul 24 '15 at 21:21
  • 1
    $\begingroup$ I have filed an internal report to get this looked into. $\endgroup$
    – Stefan R
    Jul 24 '15 at 21:22
  • $\begingroup$ @StefanR You have an incoming "feedback" email from me as well, CASE:3391689 :) With more details coming. $\endgroup$
    – WReach
    Jul 24 '15 at 21:23

A work around seems to be to not have Dataset as the first Head encountered...


So the first Head the parser sees is Apply and not Dataset.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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