bugPSPP - Bugs: bug #45192, gtk3 / osx - histogram routine has...

 
 

bug #45192: gtk3 / osx - histogram routine has problems when rendering text.

Submitter:  Friedrich Beckmann <beckmanf>
Submitted:  Tue 26 May 2015 03:18:51 PM UTC
   
 
Category:  GTK3 Severity:  5 - Average
Status:  Fixed Assigned to:  None
Open/Closed:  Closed Release:  None
Effort:  0.00
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 14 Jun 2015 09:24:38 PM UTC, comment #8: 

I fixed the clipping.

Ben Pfaff <blp>
Group administrator
Sun 14 Jun 2015 09:10:33 PM UTC, comment #7: 

The biggest thing that stands out at me is that the curve isn't clipped by the axes but extends to the edge of the paper.  I'll see what it takes to fix that.

Ben Pfaff <blp>
Group administrator
Sun 07 Jun 2015 09:49:29 PM UTC, comment #6: 

I fixed this with the following commit:

http://git.savannah.gnu.org/cgit/pspp.git/commit/?h=gtk3&id=6b6ed1de7e41fe0683ec458bf8f455a159a2a653

This is a quite big change as the histogram x-axis ticking is changed from per bin to usual tick generation. I attached the "charts.sps" script which produces histograms and scatterplots showing the new visualization. "master.pdf" is generated with pspp 0.8.4 from macports on osx. "new.pdf" is the new visualization from the commit above in the gtk3 branch.

The pango markup is in the commit before.

http://git.savannah.gnu.org/cgit/pspp.git/commit/?h=gtk3&id=588b9791103a2aa7225f59a7b9490ed1da987adf

(file #34174, file #34175, file #34176)

Friedrich Beckmann <beckmanf>
Group Member
Sat 06 Jun 2015 07:00:54 PM UTC, comment #5: 

Am 02.06.2015 um 13:49 schrieb John Darrington <john@darrington.wattle.id.au>:

Regarding Fritz's change:

commit d5f9f3dea48e19a139827e9876385e0fa660cf38
Author: Friedrich Beckmann <friedrich.beckmann@hs-augsburg.de>
Date:   Mon Jun 1 00:20:01 2015 +0200

  histogram tick drawing - added format generation for optimum tick drawing
  Fixes bug #45192 which showed up in the gtk3 branch on MacOS.


Firstly, thanks very much for fixing this problem.


  It replaces the decimal_xxx computations with a routine that computes a
  formatting string and a scale factor for a given axis range and number of
  bins.

The problem seems to have been caused by a bug in the decimal_to_string function.
This change fixes the problem for histograms (by avoiding that function altogether)
however I am concerned that decimal_to_string remains buggy, and this function is
used elsewhere.

Would it be possible to use the same approach to avoid the decimal arithmetic
functions altogether?  

yes, I am looking for a replacement of the decimal_xxx functions. I think they are
used in the xr_scale tick generation today.


  In addition the width of the rendered labels is compared with the width
  of the bins in the display such that the labels will automatically
  switch between horizontal and 45 degree display.

I think there is an existing bug report about clashing labels in other charts.
We should do the same there to avoid this.

When doing the scale tick, I can look into that also.

There is the problem left, that the x-axis ticks will overwrite the axis label. In an
ideal world, the axis label would have another position depending size of the tick
names. But the chart rectangle is already drawn at xr_init time, so we cannot
escape further down...

Also, I see that the new function, chart_get_ticks_format returns a format like
1.2e+10 for scientific format.  I think a lot of pspp users will be unsatisfied
with this.  Can we change it to return a pango format string with proper superscripts.


I can try that. I have not looked into the pango format.

Friedrich Beckmann <beckmanf>
Group Member
Sun 31 May 2015 11:44:02 PM UTC, comment #4: 

I fixed this with commit

http://git.savannah.gnu.org/cgit/pspp.git/commit/?h=gtk3&id=f89d8a893f83ad0cb95819ca60e6f4a718f7d988

Attached are some example histogram plots showing the different value scenarios.

Friedrich

(file #34135)

Friedrich Beckmann <beckmanf>
Group Member
Fri 29 May 2015 09:17:52 PM UTC, comment #3: 

Hi John,

the size of long is 8 Bytes. The following printf

===========
      decimal_int_divide (&middle, 2);
      char *str = decimal_to_string (&middle);
      printf("%s: lower: %lf, upper: %lf, ordinate: "PR_ORD", mantissa: "PR_MANT", string: %s, size ord: %ld, size mant:%ld \n",
     _FUNCTION_,
     lower,
     upper,
     middle.ordinate,
     middle.mantissa,
     str,
     sizeof (ord_t),
     sizeof (mant_t));
#if 0
      draw_tick (cr, geom, SCALE_ABSCISSA, bins > 10,
========

gives the following output:

hist_draw_bar: lower: -78,500000, upper: -77,500000, ordinate: -78, mantissa: 0, string: -78, size ord: 8, size mant:8
hist_draw_bar: lower: 45,000000, upper: 47,000000, ordinate: 46, mantissa: 0, string: 46, size ord: 8, size mant:8
hist_draw_bar: lower: 47,000000, upper: 49,000000, ordinate: 48, mantissa: 0, string: 48, size ord: 8, size mant:8
hist_draw_bar: lower: 49,000000, upper: 51,000000, ordinate: 5, mantissa: 1, string: 50, size ord: 8, size mant:8
hist_draw_bar: lower: 51,000000, upper: 53,000000, ordinate: 52, mantissa: 0, string: 52, size ord: 8, size mant:8
hist_draw_bar: lower: 53,000000, upper: 55,000000, ordinate: 54, mantissa: 0, string: 54, size ord: 8, size mant:8
hist_draw_bar: lower: 55,000000, upper: 57,000000, ordinate: 55999999999999995, mantissa: -15, string: 55,999999999999995ns serif, size ord: 8, size mant:8
hist_draw_bar: lower: 57,000000, upper: 59,000000, ordinate: 57999999999999995, mantissa: -15, string: 57,999999999999995ns serif, size ord: 8, size mant:8
hist_draw_bar: lower: 59,000000, upper: 61,000000, ordinate: 6, mantissa: 1, string: 60, size ord: 8, size mant:8
hist_draw_bar: lower: 61,000000, upper: 63,000000, ordinate: 62, mantissa: 0, string: 62, size ord: 8, size mant:8
hist_draw_bar: lower: 63,000000, upper: 65,000000, ordinate: 64, mantissa: 0, string: 64, size ord: 8, size mant:8
hist_draw_bar: lower: 65,000000, upper: 67,000000, ordinate: 66, mantissa: 0, string: 66, size ord: 8, size mant:8
hist_draw_bar: lower: -91,500000, upper: -90,500000, ordinate: -905, mantissa: -1, string: -90,5, size ord: 8, size mant:8
hist_draw_bar: lower: -90,500000, upper: -89,500000, ordinate: -895, mantissa: -1, string: -89,5, size ord: 8, size mant:8
hist_draw_bar: lower: -89,500000, upper: -88,500000, ordinate: -885, mantissa: -1, string: -88,5, size ord: 8, size mant:8
hist_draw_bar: lower: -88,500000, upper: -87,500000, ordinate: -875, mantissa: -1, string: -87,5, size ord: 8, size mant:8

...

hist_draw_bar: lower: -83,500000, upper: -82,500000, ordinate: -825, mantissa: -1, string: -82,5, size ord: 8, size mant:8
hist_draw_bar: lower: -82,500000, upper: -81,500000, ordinate: -815, mantissa: -1, string: -81,5, size ord: 8, size mant:8
hist_draw_bar: lower: -81,500000, upper: -80,500000, ordinate: -805, mantissa: -1, string: -80,5, size ord: 8, size mant:8
hist_draw_bar: lower: -80,500000, upper: -79,500000, ordinate: -795, mantissa: -1, string: -79,5, size ord: 8, size mant:8
hist_draw_bar: lower: -79,500000, upper: -78,500000, ordinate: -785, mantissa: -1, string: -78,5, size ord: 8, size mant:8
hist_draw_bar: lower: -91,500000, upper: -90,500000, ordinate: -91, mantissa: 0, string: -91, size ord: 8, size mant:8
hist_draw_bar: lower: -90,500000, upper: -89,500000, ordinate: -9, mantissa: 1, string: -90, size ord: 8, size mant:8
hist_draw_bar: lower: -89,500000, upper: -88,500000, ordinate: -885, mantissa: -1, string: -88,5, size ord: 8, size mant:8
hist_draw_bar: lower: -88,500000, upper: -87,500000, ordinate: -875, mantissa: -1, string: -87,5, size ord: 8, size mant:8
hist_draw_bar: lower: -87,500000, upper: -86,500000, ordinate: -865, mantissa: -1, string: -86,5, size ord: 8, size mant:8
hist_draw_bar: lower: -86,500000, upper: -85,500000, ordinate: -855, mantissa: -1, string: -85,5, size ord: 8, size mant:8
hist_draw_bar: lower: -85,500000, upper: -84,500000, ordinate: -845, mantissa: -1, string: -84,5, size ord: 8, size mant:8
hist_draw_bar: lower: -84,500000, upper: -83,500000, ordinate: -835, mantissa: -1, string: -83,5, size ord: 8, size mant:8
hist_draw_bar: lower: -83,500000, upper: -82,500000, ordinate: -825, mantissa: -1, string: -82,5, size ord: 8, size mant:8
hist_draw_bar: lower: -82,500000, upper: -81,500000, ordinate: -815, mantissa: -1, string: -81,5, size ord: 8, size mant:8
hist_draw_bar: lower: -81,500000, upper: -80,500000, ordinate: -805, mantissa: -1, string: -80,5, size ord: 8, size mant:8
hist_draw_bar: lower: -80,500000, upper: -79,500000, ordinate: -795, mantissa: -1, string: -79,5, size ord: 8, size mant:8
hist_draw_bar: lower: -79,500000, upper: -78,500000, ordinate: -79, mantissa: 0, string: -79, size ord: 8, size mant:8
hist_draw_bar: lower: -78,500000, upper: -77,500000, ordinate: -78, mantissa: 0, string: -78, size ord: 8, size mant:8
hist_draw_bar: lower: -7,000000, upper: -5,000000, ordinate: -5999999999999995, mantissa: -15, string: -5,999999999999995!??, size ord: 8, size mant:8
hist_draw_bar: lower: -5,000000, upper: -3,000000, ordinate: -39999999999999995, mantissa: -16, string: -3,9999999999999995??, size ord: 8, size mant:8
hist_draw_bar: lower: -3,000000, upper: -1,000000, ordinate: -19999999999999995, mantissa: -16, string: -1,9999999999999995??, size ord: 8, size mant:8
hist_draw_bar: lower: -1,000000, upper: 1,000000, ordinate: -4, mantissa: -16, string: -0,0000000000000004??, size ord: 8, size mant:8
hist_draw_bar: lower: 1,000000, upper: 3,000000, ordinate: 19999999999999997, mantissa: -16, string: 1,9999999999999997?, size ord: 8, size mant:8
hist_draw_bar: lower: 3,000000, upper: 5,000000, ordinate: 40000000000000002, mantissa: -16, string: 4,0000000000000002?, size ord: 8, size mant:8
hist_draw_bar: lower: 5,000000, upper: 7,000000, ordinate: 6, mantissa: 0, string: 6, size ord: 8, size mant:8
hist_draw_bar: lower: 7,000000, upper: 9,000000, ordinate: 8, mantissa: 0, string: 8, size ord: 8, size mant:8
hist_draw_bar: lower: 9,000000, upper: 11,000000, ordinate: 1, mantissa: 1, string: 10, size ord: 8, size mant:8

You can see the strange characters in the string output.

Friedrich Beckmann <beckmanf>
Group Member
Fri 29 May 2015 12:58:23 PM UTC, comment #2: 

This implies that the function "decimal_to_string" is returning rubbish and is buggy.

Can you try to find out the value of "middle" which provokes this.

And do you know the size of long int on this machine?

Thanks for looking into this.

John Darrington <jmd>
Group administrator
Fri 29 May 2015 11:28:37 AM UTC, comment #1: 

With the following change, the test suite runs without errors:

diff --git a/src/output/charts/plot-hist-cairo.c b/src/output/charts/plot-hist-cairo.c
index 006b392..7e9e157 100644
With the following change, the test suite runs without failures:

--- a/src/output/charts/plot-hist-cairo.c
+++ b/src/output/charts/plot-hist-cairo.c
@@ -113,8 +113,10 @@ hist_draw_bar (cairo_t *cr, const struct xrchart_geometry *geom,
       decimal_add (&middle, &decupper);
       decimal_int_divide (&middle, 2);
       char *str = decimal_to_string (&middle);
+#if 0
       draw_tick (cr, geom, SCALE_ABSCISSA, bins > 10,
                 x_pos + width / 2.0, "%s", str);
+#endif
       free (str);
     }
 }

So it is related to the histogram label generation.

Friedrich Beckmann <beckmanf>
Group Member
Tue 26 May 2015 03:18:51 PM UTC, original submission:  

Jeremy tried the gtk3 build on osx and some tests failed. All failing tests use the histogram graphical output. I build on osx from git with macports and see the same problem. For me the tests:

   Subject: [GNU PSPP 0.8.4] testsuite: 497 1019 1022 failed

failed. When I run test 497 manually several times I see the following:

friedrismacbook:0497 fritz$ ls -la
total 104
drwxr-xr-x  6 fritz  staff    204 26 Mai 16:40 .
drwxr-xr-x  5 fritz  staff    170 26 Mai 16:40 ..
-rw-r--r--  1 fritz  staff    249 26 Mai 16:40 frequencies.sps
-rw-r--r--  1 fritz  staff  38207 26 Mai 16:41 pspp.pdf
-rwxr-xr-x  1 fritz  staff    317 26 Mai 16:40 run
-rw-r--r--  1 fritz  staff    749 26 Mai 16:40 testsuite.log
friedrismacbook:0497 fritz$ ../../../src/ui/terminal/pspp -O format=pdf frequencies.sps

(process:17870): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()

(process:17870): Pango-WARNING **: shaping failure, expect ugly output. shape-engine='BasicEngineCoreText', font='Helvetica Medium', text='-0,000000000000001\xff[\u007f\u007f'

(process:17870): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()

(process:17870): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()
friedrismacbook:0497 fritz$ ../../../src/ui/terminal/pspp -O format=pdf frequencies.sps

(process:17884): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()

(process:17884): Pango-WARNING **: shaping failure, expect ugly output. shape-engine='BasicEngineCoreText', font='Helvetica Medium', text='-0,000000000000001\xff\xff\xff\u007f'
friedrismacbook:0497 fritz$ ../../../src/ui/terminal/pspp -O format=pdf frequencies.sps

(process:17900): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()

(process:17900): Pango-WARNING **: shaping failure, expect ugly output. shape-engine='BasicEngineCoreText', font='Helvetica Medium', text='-0,000000000000001\u0005t\xff\u007f'

(process:17900): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()
friedrismacbook:0497 fritz$ ls -la

So there are some strange characters appended. And the pattern changes. Maybe this bug is related to bug #43469 which was due to implementation of cairo on osx. The current macports has cairo 1.14.2 which includes a patch for the text rendering on osx.

http://cgit.freedesktop.org/cairo/commit/?id=70cc8f250b5669e757b4f044571ba0f71e3dea9e

When I open the the sps file from test 1019 and reduce it to:

========

input program.
loop #i = 1 to 1000.
 compute x  = rv.normal (56, 3) + rv.uniform (1, 1).
 compute y  = rv.normal (6, 2) + rv.uniform (1, 2).
 compute A  = rv.uniform (-1, 1).
  compute A = (A > 0).
 end case.
end loop.
end file.
end input program.

examine x y
/plot = histogram.
===================

then I see the screen as shown in the attachment. The strange characters change when I resize the window. So I guess there is some memory issue here.



Friedrich Beckmann <beckmanf>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #34175:  new.pdf added by beckmanf (392KiB - application/pdf)
file #34176:  charts.sps added by beckmanf (1KiB - application/octet-stream)
file #34174:  master.pdf added by beckmanf (113KiB - application/pdf)
file #34135:  histplot.pdf added by beckmanf (396KiB - application/pdf)
file #34099:  histogram-on-osx.JPG added by beckmanf (113KiB - image/jpeg)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by blp (Posted a comment)
  • -email is unavailable- added by jmd (Posted a comment)
  • -email is unavailable- added by beckmanf (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 13 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-06-24 beckmanf StatusReady for Test/Review Fixed
        Open/ClosedOpen Closed
    2015-06-07 beckmanf Attached File- Added master.pdf, #34174
        Attached File- Added new.pdf, #34175
        Attached File- Added charts.sps, #34176
        StatusIn Progress Ready for Test/Review
    2015-06-06 beckmanf CategoryCompilation/Portability GTK3
        StatusFixed In Progress
        Open/ClosedClosed Open
    2015-05-31 beckmanf Attached File- Added histplot.pdf, #34135
        StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2015-05-26 beckmanf Attached File- Added histogram-on-osx.JPG, #34099

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code