Bug introduced in 11.0.1 or earlier and fixed in 11.1.0

Is this yet another annoying regression in v11 Dataset type handling? The display form seems to be a formatting bug:

The numerator and denominator of integer-magnitude Quantities appear string joined:

Dataset[<|"a" -> Quantity[12, "Seconds"],  "b" -> Quantity[34, "Seconds"]|>] // Query[All, UnitConvert[#, "Minutes"] &]

enter image description here

These should really be 1/5 and 17/30 minutes. Doesn't affect Association or real-valued magnitudes, ie these work:

Dataset[<|"a" -> Quantity[12, "Seconds"], 
    "b" -> Quantity[34, "Seconds"]|>] // Normal // 
 Query[All, UnitConvert[#, "Minutes"] &]


Dataset[<|"a" -> Quantity[12., "Seconds"], 
   "b" -> Quantity[34., "Seconds"]|>] // 
 Query[All, UnitConvert[#, "Minutes"] &]

gives 0.2 and 0.566667 min.

Is this resolved in 11.1 pre?

  • $\begingroup$ I can confirm that the bug has been fixed in MMA 11.1.0 $\endgroup$ – user58955 Mar 23 '17 at 17:52
  • $\begingroup$ @user58955, works, thanks for the update. $\endgroup$ – alancalvitti Mar 23 '17 at 21:56

I do not know if this defect is fixed in any prerelease builds of version 11.1, but I can offer a couple of work-arounds.

Diagnosis (current for version 11.0.1)

Here is a minimal reproduction of this bug:

Quantity[1/2, "Meters"] // Dataset

defect screenshot

Tracing reveals that the bug lies in the following function:

TypeSystem`NestedGrid`PackagePrivate`qbox[Quantity[1/2, "Meters"]]

(* RowBox[{"12", "\"m\""}] *)

... or alternatively another function which it invokes:

TypeSystem`NestedGrid`PackagePrivate`fixnum[FractionBox["1", "2"]]

(* "12" *)


We can revert to the old dataset styling which does not exhibit the problem:

Dataset`$UseNewDatasetFormatting = False;
Quantity[1/2, "Meters"] // Dataset

old styling

Or, we could apply an unsanctioned and unsupported patch to one of the errant functions. I chose to patch fixnum because it was simpler:

  DownValues @ TypeSystem`NestedGrid`PackagePrivate`fixnum
, HoldPattern[
  ] :>  TypeSystem`NestedGrid`PackagePrivate`e

... which yields:

Dataset`$UseNewDatasetFormatting = True;
Quantity[1/2, "Meters"] // Dataset

patched rendering

Dataset[<|"a"->Quantity[12,"Seconds"],"b"->Quantity[34,"Seconds"]|>] //

original expression result with patch


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.