Message Boards Message Boards

0
|
5837 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Undocumented truncation of reals in displaying datasets

Posted 9 years ago

Accidently I stepped into the following feature: if you have real number in a dataset which are in the range 100000. or above the default displaying mode of the dataset seems to truncate the real numbers after 4 digits. In fact it is much easier to understand the issue by looking at a simple example:

randomData = RandomInteger[{490000, 500000}, 5];
data6 = Map[{#, N[#]} &, randomData];
data100 = 
 Dataset[Map[Association[Thread[{"Int", "Real"} -> #]] &, data6]]

Executing these lines results in a view similar like the following: Out[1]: display of Dataset

Obviously the integers in column 1 are displayed without truncation, but the corresponding reals are displayed truncated afetr 4 digits. I would not call this a bug, but rather an unexpected and undocumented feature. To be clear: the numbers in the dataset are not truncated which can be proofed by running Normal[Dataset]

POSTED BY: Michael Helmle
4 Replies

I stumbled on the same. It is indeed a display thing. If you check the "Normal", the underlying value appears:

    Normal[data100]
    Equal@@@Map[IntegerPart,Normal[data100],{2}]
  {<|"Int" -> 499376, "Real" -> 499376.|>, <|"Int" -> 496899,   "Real" -> 496899.|>, <|"Int" -> 491584, 
  "Real" -> 491584.|>, <|"Int" -> 494629, 
  "Real" -> 494629.|>, <|"Int" -> 490165, "Real" -> 490165.|>}

{True, True, True, True, True}
POSTED BY: Olivier de Barsy
Posted 9 years ago

Hello Jesse, what I am trying to say is this (I am not a native English speaker, so excuse me if my description was not precise): if you look at column 1 and compare it to column 2 you see a different number -> 491612 vs. 491600. This is what I refered too as being "truncated". I am not aware that there is anywhere in the documentation a hint regarding the representation of Reals and that, although they are displayed with 6 digits left of the decinal point, they are in fact rounded to 4 vaild digits

POSTED BY: Michael Helmle

I see what you mean. That is indeed odd. (The correct terminology is rounding, but I probably should have paid closer attention to the output anyways.)

A Trace of the Dataset doesn't show any rounding going on, but I did notice that if you copy and paste the Dataset object, the Reals are represented as strings:

reals represented as strings

I think this issue may have something to do with the machine-number precision of the reals Dataset displays.

POSTED BY: Jesse Friedman

I tried your code, and the numbers don't seem to be truncated.

numbers not truncated

POSTED BY: Jesse Friedman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract