Loading ...
Sorry, an error occurred while loading the content.

Re: [ploticus] possible bug in processdata w/ action: percent

Expand Messages
  • Stephen C. Grubb
    Mark, thanks for finding this problem. I have no clue as to why quoting seemed to be needed there, but I ll put your suggested fix into the next release.
    Message 1 of 2 , May 18, 2006
    • 0 Attachment
      Mark, thanks for finding this problem. I have no clue as to why quoting
      seemed to be needed there, but I'll put your suggested fix into the next
      release.

      Also, thanks for making this bug report very clear and easy to
      follow/comprehend.. I wish they were all like this.

      Steve



      On Sat, 22 Apr 2006, mhmh0023 wrote:

      > Hello Steve,
      >
      > I came across a possible bug in processdata with action "percent".
      > The results from processdata are enclosed with double quotes ("10",
      > instead of just 10), and this causes no data point to be plotted.
      > There is no such problem with action "accumulate".
      >
      > The sample script (tested with versions 2.30, 2.31, and 2.32),
      >
      > //
      > // test plot for processdata w/ percent
      > //
      >
      > #proc page
      > pagesize: 10 5
      >
      > #proc getdata
      > fieldnameheader: yes
      > #intrailer
      >
      > #proc processdata
      > action: percent
      > fields: Y
      > showresults: yes
      >
      > #proc areadef
      > rectangle: 1 1 9 4
      > xautorange: datafield=1
      > yautorange: datafield=2
      > xaxis.stubs: inc
      > xaxis.label: X
      > yaxis.label: Y
      > yaxis.stubs: inc
      >
      > #proc lineplot
      > xfield: 1
      > yfield: 2
      > linedetails: color=red style=2 width=0.7
      > legendlabel: X
      >
      > #proc legend
      > location: max-0.1 min+0.5
      >
      > #proc trailer
      > data:
      > X Y
      > 1 1
      > 2 1
      > 3 2
      > 4 2
      > 5 3
      > 6 3
      > 7 4
      > 8 4
      > 9 5
      > 10 5
      >
      > //----------------------- end of script ------------------
      >
      >
      > The output from ploticus versions 2.30, 2.31, and 2.32:
      >
      > // proc processdata results (action = percent)
      > [1]["3.33333" ]
      > [2]["3.33333" ]
      > [3]["6.66667" ]
      > [4]["6.66667" ]
      > [5]["10" ]
      > [6]["10" ]
      > [7]["13.3333" ]
      > [8]["13.3333" ]
      > [9]["16.6667" ]
      > [10]["16.6667" ]
      > pl proc areadef: error 5709: autorange: all data out of range
      >
      >
      > Due to the double quotes in the values of the 2nd field, no data
      > point is plotted.
      >
      > I found the source of the problem in the file "proc_processdata.c".
      > At lines 358 - 362 in "proc_processdata.c",
      >
      > if( k != nfld ) {
      > if( keepall ) out( da( i, j ) );
      > sprintf( outbuf, outfmt, (atof(da( i, j )) / accum[k]) * 100.0 );
      > out( outbuf );
      > }
      >
      >
      > "outfmt" is set at line 207, with
      >
      > sprintf( outfmt, "\"%s\" ", rformat );
      >
      > and this is the cause of the double quoted values. Line 360 is the
      > only place that uses "outfmt". I couldn't figure out why the double
      > quotes are needed. Maybe it's for other type of values.
      >
      > For action "accumulate", the corresponding sprintf command uses
      > "rformat" as the format string at line 391,
      >
      > sprintf( tok, rformat, accum[k] );
      >
      > Then I replace "outfmt" with "rformat" in line 360,
      >
      > sprintf( outbuf, rformat, (atof(da( i, j )) / accum[k]) * 100.0 );
      >
      > and this solves my problem. The output from sample using modified
      > ploticus is now correct.
      >
      > // proc processdata results (action = percent)
      > [1][3.33333]
      > [2][3.33333]
      > [3][6.66667]
      > [4][6.66667]
      > [5][10]
      > [6][10]
      > [7][13.3333]
      > [8][13.3333]
      > [9][16.6667]
      > [10][16.6667]
      >
      > Anyway, this could be a bug. Please check if you get a chance.
      > --
      > Mark
      >
      >
      >
      >
      >
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >


      Stephen C. Grubb scg@... x-6633
      Scientific Software Engineer, The Jackson Laboratory
      600 Main Street Bar Harbor, Maine 04609 USA
    Your message has been successfully submitted and would be delivered to recipients shortly.