|
From: Philipp K. J. <ja...@ie...> - 2009-11-02 06:19:07
|
> >
> > 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)
>
|
|
From: Philipp K. J. <ja...@ie...> - 2009-11-02 16:06:19
|
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)".
|
|
From: Ethan M. <merritt@u.washington.edu> - 2009-11-02 16:57:38
|
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
|