Re: df_readline() question

View: New views
3 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: df_readline() question

by Philipp K. Janert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> >
> > However, this is not how it seems to work. If there are
> > fields in the data file that cannot be transformed to double,
> > df_readline simply skips the line.
>
> That's certainly not true in general, or it wouldn't be able
> to handle files containing text fields.
> Also imageNaN.dem wouldn't provide the output it does.
>
> Simple test: feed it a file junk.dat:
>  1
>  2
>  junk
>  3
>  4
>
> gnuplot> plot 'junk.dat' with lp
>               ^
>          Bad data on line 3
> gnuplot>

Does plot do anything special here?

I have a situation (stolen from the fit function),
which basically says:

while( (i = readline(...)) != EOF ) {
        ...

And now I feed it your data file and it does NOT
return either DF_MISSING or DF_UNDEFINED!

So it strikes me as if it is not so much "more
complicated", but rather "more simple" cases
where it does the unexpected.

>
>
> But you could be right that there are more complicated cases where
> it unexpectedly fails to return a useful error indicator, or fails
> to return good values from a line that happens to contain a bad one.
>
> > I would have expected it
> > to return DF_MISSING or DF_UNDEFINED. But that's not
> > what I observe.
>
> From my personal TODO file:
>  - Sort out handling of junk/NaN/Inf in datafile.c
>    + using 1:2:3 and using ($1):($2):($3) should fill in all the legal
> values before returning an error code due to a single bad value

Based on your comment here, I just discovered that
if I enclose the columns in parens [that is using ($1):($2)]
rather than [using 1:2], then df_readline() DOES indeed
return DF_MISSING and DF_UNDEFINED.

Hm. I guess I knew this, although takes out of context like
this, it is surprising.

>    + new return code DF_INFINITY for Inf
>    + set datafile missing {"keyword"} {NaN} {Inf}
>      would explicitly treat NaN or Inf as a missing value, rather than a
> bad one + blank line should be distinguishable from a non-blank line
> containing junk + consistent treatement of NaN (always set point->type ==
> UNDEFINED)
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta

Parent Message unknown Re: df_readline() question

by Philipp K. Janert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Comments at the end.

On Sunday 01 November 2009 10:38:04 pm Ethan Merritt (sfeam) wrote:

> On Sunday 01 November 2009, Philipp K. Janert wrote:
> > > Simple test: feed it a file junk.dat:
> > >  1
> > >  2
> > >  junk
> > >  3
> > >  4
> > >
> > > gnuplot> plot 'junk.dat' with lp
> > >               ^
> > >          Bad data on line 3
> > > gnuplot>
> >
> > Does plot do anything special here?
> >
> > I have a situation (stolen from the fit function),
> > which basically says:
> >
> > while( (i = readline(...)) != EOF ) {
> > ...
> >
> > And now I feed it your data file and it does NOT
> > return either DF_MISSING or DF_UNDEFINED!
>
> No, it returns 0.  But that's not EOF, so it should
> be catchable.

No, it doesn't. It does not return anything for the
line that contains "junk", when run with "using 1".

It does return -2 (DF_UNDEFINED) for the line
with "junk", but only when run with "using ($1)".


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta

Re: df_readline() question

by Ethan Merritt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Monday 02 November 2009 08:06:04 Philipp K. Janert wrote:

>
> Comments at the end.
>
> On Sunday 01 November 2009 10:38:04 pm Ethan Merritt (sfeam) wrote:
> > On Sunday 01 November 2009, Philipp K. Janert wrote:
> > > > Simple test: feed it a file junk.dat:
> > > >  1
> > > >  2
> > > >  junk
> > > >  3
> > > >  4
> > > >
> > > > gnuplot> plot 'junk.dat' with lp
> > > >               ^
> > > >          Bad data on line 3
> > > > gnuplot>
> > >
> > > Does plot do anything special here?
> > >
> > > I have a situation (stolen from the fit function),
> > > which basically says:
> > >
> > > while( (i = readline(...)) != EOF ) {
> > > ...
> > >
> > > And now I feed it your data file and it does NOT
> > > return either DF_MISSING or DF_UNDEFINED!
> >
> > No, it returns 0.  But that's not EOF, so it should
> > be catchable.
>
> No, it doesn't. It does not return anything for the
> line that contains "junk", when run with "using 1".
>
> It does return -2 (DF_UNDEFINED) for the line
> with "junk", but only when run with "using ($1)".

Hence the entry on my TODO list that I quoted earlier.
You could evaluate the following simple-minded patch:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--- gnuplot/src/datafile.c 2009-10-10 11:43:30.000000000 -0700
+++ gnuplot-cvs/src/datafile.c 2009-11-02 08:53:58.000000000 -0800
@@ -1870,7 +1870,7 @@ df_readascii(double v[], int max)
  /* line bad only if user explicitly asked
  * for this column */
  if (df_no_use_specs)
-    line_okay = 0;
+    return DF_UNDEFINED;
  break;      /* return or ignore depending on line_okay */
     }
  }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5




--
Ethan A Merritt

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta