Plot not robust with respect to Inf values

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

Plot not robust with respect to Inf values

by gOS :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Attempting to pass Inf or NaN to plot results in interestingly different results, and there's a bug somewhere in it.

plot(NaN,NaN) results in
error: plot: expecting first argument to be asex handle ... etc

plot(Inf,Inf) results in
line 15: undefined variable: Inf

gnuplot> plot "-" using ($1):($2) axes x1y1 title "" with lines ...

I'd assume that there is some sort of failure on all graphics packages. As Inf and NaN can appear in matrices, shouldn't plot be able to identify when its passed data it shouldn't be passed?

I view this as a bug. Matlab simply returns a blank plot while not crashing, if this isn't possible in Octave for each back end it probably needs to be handled.

Even getting an error from Octave instead of gnuplot would be good enough for me, currently operations procede if Inf is present so there is no way to catch on the issue besides checking every value in the matrix before plotting.

Plot not robust with respect to Inf values

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On  6-Aug-2008, gOS wrote:

|
| Attempting to pass Inf or NaN to plot results in interestingly different
| results, and there's a bug somewhere in it.
|
| plot(NaN,NaN) results in
| error: plot: expecting first argument to be asex handle ... etc
|
| plot(Inf,Inf) results in
| line 15: undefined variable: Inf
|
| gnuplot> plot "-" using ($1):($2) axes x1y1 title "" with lines ...
|
| I'd assume that there is some sort of failure on all graphics packages. As
| Inf and NaN can appear in matrices, shouldn't plot be able to identify when
| its passed data it shouldn't be passed?
|
| I view this as a bug. Matlab simply returns a blank plot while not crashing,
| if this isn't possible in Octave for each back end it probably needs to be
| handled.
|
| Even getting an error from Octave instead of gnuplot would be good enough
| for me, currently operations procede if Inf is present so there is no way to
| catch on the issue besides checking every value in the matrix before
| plotting.

Please try the following change.

jwe


# HG changeset patch
# User John W. Eaton <jwe@...>
# Date 1219262234 14400
# Node ID 24701aa75ecbe5f64da30b756890888a858ef029
# Parent  faf0abc5fd515423c7b95083b03260bdfcc6f777
scope fixes for anonymous and inline functions that appear inside subfunctions

diff --git a/src/ov-fcn-inline.cc b/src/ov-fcn-inline.cc
--- a/src/ov-fcn-inline.cc
+++ b/src/ov-fcn-inline.cc
@@ -91,7 +91,20 @@
   octave_user_function *uf = fcn.user_function_value ();
 
   if (uf)
-    uf->stash_parent_fcn_scope (octave_call_stack::current_scope ());
+    {
+      octave_function *curr_fcn = octave_call_stack::current ();
+
+      if (curr_fcn)
+ {
+  symbol_table::scope_id parent_scope
+    = curr_fcn->parent_fcn_scope ();
+
+  if (parent_scope < 0)
+    parent_scope = curr_fcn->scope ();
+
+  uf->stash_parent_fcn_scope (parent_scope);
+ }
+    }
  }
     }
 
diff --git a/src/pt-fcn-handle.cc b/src/pt-fcn-handle.cc
--- a/src/pt-fcn-handle.cc
+++ b/src/pt-fcn-handle.cc
@@ -114,7 +114,13 @@
   if (curr_fcn)
     {
       uf->stash_parent_fcn_name (curr_fcn->name ());
-      uf->stash_parent_fcn_scope (curr_fcn->scope ());
+
+      symbol_table::scope_id parent_scope = curr_fcn->parent_fcn_scope ();
+
+      if (parent_scope < 0)
+ parent_scope = curr_fcn->scope ();
+
+      uf->stash_parent_fcn_scope (parent_scope);
     }
 
   uf->mark_as_inline_function ();

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave

Plot not robust with respect to Inf values

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 21-Aug-2008, John W. Eaton wrote:

| On  6-Aug-2008, gOS wrote:
|
| |
| | Attempting to pass Inf or NaN to plot results in interestingly different
| | results, and there's a bug somewhere in it.
| |
| | plot(NaN,NaN) results in
| | error: plot: expecting first argument to be asex handle ... etc
| |
| | plot(Inf,Inf) results in
| | line 15: undefined variable: Inf
| |
| | gnuplot> plot "-" using ($1):($2) axes x1y1 title "" with lines ...
| |
| | I'd assume that there is some sort of failure on all graphics packages. As
| | Inf and NaN can appear in matrices, shouldn't plot be able to identify when
| | its passed data it shouldn't be passed?
| |
| | I view this as a bug. Matlab simply returns a blank plot while not crashing,
| | if this isn't possible in Octave for each back end it probably needs to be
| | handled.
| |
| | Even getting an error from Octave instead of gnuplot would be good enough
| | for me, currently operations procede if Inf is present so there is no way to
| | catch on the issue besides checking every value in the matrix before
| | plotting.
|
| Please try the following change.
|
| jwe

Sorry, that was the wrong changeset file.  The correct one is
attached below.

jwe


# HG changeset patch
# User John W. Eaton <jwe@...>
# Date 1219346938 14400
# Node ID 2f7ff06c0c7b0f28ea726b304c8a5afdc7788ccd
# Parent  d54f113aa9839a33022065acc0d0250b53bb0dea
__go_draw_axes__.m (__gnuplot_write_data__): write "Inf Inf\n" if all data pairs contain NaN values

diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,9 @@
+2008-08-21  John W. Eaton  <jwe@...>
+
+ * plot/__go_draw_axes__.m: Fix test for have_data.
+ (__gnuplot_write_data__): Write "Inf Inf\n" if all data pairs
+ contain NaN values.
+
 2008-08-21  Thomas Treichl  <Thomas.Treichl@...>
 
  * optimization/sqp.m: Increase test script tolerance.
diff --git a/scripts/plot/__go_draw_axes__.m b/scripts/plot/__go_draw_axes__.m
--- a/scripts/plot/__go_draw_axes__.m
+++ b/scripts/plot/__go_draw_axes__.m
@@ -1021,7 +1021,7 @@
       fputs (plot_stream, "unset hidden3d;\n");
     endif
 
-    have_data = (! (isempty (data) || any (cellfun (@isempty, data))));
+    have_data = (! (isempty (data) || all (cellfun (@isempty, data))));
 
     if (isempty (xlim))
       return;
@@ -1461,15 +1461,19 @@
       n = columns (data);
       have_nans = true;
       num_nan_elts = numel (nan_elts);
-      k = 1;
-      for i = 1:n
- if (have_nans && i == nan_elts(k))
-  fputs (plot_stream, "\n");
-  have_nans = ++k <= num_nan_elts;
- else
-  fprintf (plot_stream, fmt, data(:,i));
- endif
-      endfor
+      if (num_nan_elts == n)
+ fputs (plot_stream, "Inf Inf\n");
+      else
+ k = 1;
+ for i = 1:n
+  if (have_nans && i == nan_elts(k))
+    fputs (plot_stream, "\n");
+    have_nans = ++k <= num_nan_elts;
+  else
+    fprintf (plot_stream, fmt, data(:,i));
+  endif
+ endfor
+      endif
     endif
   elseif (nd == 3)
     ## FIXME -- handle NaNs here too?
diff --git a/scripts/plot/print.m b/scripts/plot/print.m
--- a/scripts/plot/print.m
+++ b/scripts/plot/print.m
@@ -423,7 +423,7 @@
     endif
 
     if (! isempty (convertname))
-      command = sprintf ("convert '%s' '%s'", name, convertname);
+      command = sprintf ("convert '%s' '%s'", name, convertname)
       [errcode, output] = system (command);
       unlink (name);
       if (errcode)

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave

Re: Plot not robust with respect to Inf values

by Jaroslav Hajek-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Aug 21, 2008 at 9:30 PM, John W. Eaton <jwe@...> wrote:

> On 21-Aug-2008, John W. Eaton wrote:
>
> | On  6-Aug-2008, gOS wrote:
> |
> | |
> | | Attempting to pass Inf or NaN to plot results in interestingly different
> | | results, and there's a bug somewhere in it.
> | |
> | | plot(NaN,NaN) results in
> | | error: plot: expecting first argument to be asex handle ... etc
> | |
> | | plot(Inf,Inf) results in
> | | line 15: undefined variable: Inf
> | |
> | | gnuplot> plot "-" using ($1):($2) axes x1y1 title "" with lines ...
> | |
> | | I'd assume that there is some sort of failure on all graphics packages. As
> | | Inf and NaN can appear in matrices, shouldn't plot be able to identify when
> | | its passed data it shouldn't be passed?
> | |
> | | I view this as a bug. Matlab simply returns a blank plot while not crashing,
> | | if this isn't possible in Octave for each back end it probably needs to be
> | | handled.
> | |
> | | Even getting an error from Octave instead of gnuplot would be good enough
> | | for me, currently operations procede if Inf is present so there is no way to
> | | catch on the issue besides checking every value in the matrix before
> | | plotting.
> |
> | Please try the following change.
> |
> | jwe
>
> Sorry, that was the wrong changeset file.  The correct one is
> attached below.
>
> jwe
>
>
> # HG changeset patch
> # User John W. Eaton <jwe@...>
> # Date 1219346938 14400
> # Node ID 2f7ff06c0c7b0f28ea726b304c8a5afdc7788ccd
> # Parent  d54f113aa9839a33022065acc0d0250b53bb0dea
> __go_draw_axes__.m (__gnuplot_write_data__): write "Inf Inf\n" if all data pairs contain NaN values
>
> diff --git a/scripts/ChangeLog b/scripts/ChangeLog
> --- a/scripts/ChangeLog
> +++ b/scripts/ChangeLog
> @@ -1,3 +1,9 @@
> +2008-08-21  John W. Eaton  <jwe@...>
> +
> +       * plot/__go_draw_axes__.m: Fix test for have_data.
> +       (__gnuplot_write_data__): Write "Inf Inf\n" if all data pairs
> +       contain NaN values.
> +
>  2008-08-21  Thomas Treichl  <Thomas.Treichl@...>
>
>        * optimization/sqp.m: Increase test script tolerance.
> diff --git a/scripts/plot/__go_draw_axes__.m b/scripts/plot/__go_draw_axes__.m
> --- a/scripts/plot/__go_draw_axes__.m
> +++ b/scripts/plot/__go_draw_axes__.m
> @@ -1021,7 +1021,7 @@
>       fputs (plot_stream, "unset hidden3d;\n");
>     endif
>
> -    have_data = (! (isempty (data) || any (cellfun (@isempty, data))));
> +    have_data = (! (isempty (data) || all (cellfun (@isempty, data))));
>
>     if (isempty (xlim))
>       return;
> @@ -1461,15 +1461,19 @@
>       n = columns (data);
>       have_nans = true;
>       num_nan_elts = numel (nan_elts);
> -      k = 1;
> -      for i = 1:n
> -       if (have_nans && i == nan_elts(k))
> -         fputs (plot_stream, "\n");
> -         have_nans = ++k <= num_nan_elts;
> -       else
> -         fprintf (plot_stream, fmt, data(:,i));
> -       endif
> -      endfor
> +      if (num_nan_elts == n)
> +       fputs (plot_stream, "Inf Inf\n");
> +      else
> +       k = 1;
> +       for i = 1:n
> +         if (have_nans && i == nan_elts(k))
> +           fputs (plot_stream, "\n");
> +           have_nans = ++k <= num_nan_elts;
> +         else
> +           fprintf (plot_stream, fmt, data(:,i));
> +         endif
> +       endfor
> +      endif
>     endif
>   elseif (nd == 3)
>     ## FIXME -- handle NaNs here too?
> diff --git a/scripts/plot/print.m b/scripts/plot/print.m
> --- a/scripts/plot/print.m
> +++ b/scripts/plot/print.m
> @@ -423,7 +423,7 @@
>     endif
>
>     if (! isempty (convertname))
> -      command = sprintf ("convert '%s' '%s'", name, convertname);
> +      command = sprintf ("convert '%s' '%s'", name, convertname)
>       [errcode, output] = system (command);
>       unlink (name);
>       if (errcode)
>
> _______________________________________________
> Bug-octave mailing list
> Bug-octave@...
> https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave
>
>

I transplanted this changeset without the removed semicolon in
print.m. John, please fix it if it was a mistake; otherwise, let me
know and I'll fix it.

regards

--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave

Re: Plot not robust with respect to Inf values

by Jaroslav Hajek-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Aug 24, 2008 at 7:43 AM, Jaroslav Hajek <highegg@...> wrote:

> On Thu, Aug 21, 2008 at 9:30 PM, John W. Eaton <jwe@...> wrote:
>> On 21-Aug-2008, John W. Eaton wrote:
>>
>> | On  6-Aug-2008, gOS wrote:
>> |
>> | |
>> | | Attempting to pass Inf or NaN to plot results in interestingly different
>> | | results, and there's a bug somewhere in it.
>> | |
>> | | plot(NaN,NaN) results in
>> | | error: plot: expecting first argument to be asex handle ... etc
>> | |
>> | | plot(Inf,Inf) results in
>> | | line 15: undefined variable: Inf
>> | |
>> | | gnuplot> plot "-" using ($1):($2) axes x1y1 title "" with lines ...
>> | |
>> | | I'd assume that there is some sort of failure on all graphics packages. As
>> | | Inf and NaN can appear in matrices, shouldn't plot be able to identify when
>> | | its passed data it shouldn't be passed?
>> | |
>> | | I view this as a bug. Matlab simply returns a blank plot while not crashing,
>> | | if this isn't possible in Octave for each back end it probably needs to be
>> | | handled.
>> | |
>> | | Even getting an error from Octave instead of gnuplot would be good enough
>> | | for me, currently operations procede if Inf is present so there is no way to
>> | | catch on the issue besides checking every value in the matrix before
>> | | plotting.
>> |
>> | Please try the following change.
>> |
>> | jwe
>>
>> Sorry, that was the wrong changeset file.  The correct one is
>> attached below.
>>
>> jwe
>>
>>
>> # HG changeset patch
>> # User John W. Eaton <jwe@...>
>> # Date 1219346938 14400
>> # Node ID 2f7ff06c0c7b0f28ea726b304c8a5afdc7788ccd
>> # Parent  d54f113aa9839a33022065acc0d0250b53bb0dea
>> __go_draw_axes__.m (__gnuplot_write_data__): write "Inf Inf\n" if all data pairs contain NaN values
>>
>> diff --git a/scripts/ChangeLog b/scripts/ChangeLog
>> --- a/scripts/ChangeLog
>> +++ b/scripts/ChangeLog
>> @@ -1,3 +1,9 @@
>> +2008-08-21  John W. Eaton  <jwe@...>
>> +
>> +       * plot/__go_draw_axes__.m: Fix test for have_data.
>> +       (__gnuplot_write_data__): Write "Inf Inf\n" if all data pairs
>> +       contain NaN values.
>> +
>>  2008-08-21  Thomas Treichl  <Thomas.Treichl@...>
>>
>>        * optimization/sqp.m: Increase test script tolerance.
>> diff --git a/scripts/plot/__go_draw_axes__.m b/scripts/plot/__go_draw_axes__.m
>> --- a/scripts/plot/__go_draw_axes__.m
>> +++ b/scripts/plot/__go_draw_axes__.m
>> @@ -1021,7 +1021,7 @@
>>       fputs (plot_stream, "unset hidden3d;\n");
>>     endif
>>
>> -    have_data = (! (isempty (data) || any (cellfun (@isempty, data))));
>> +    have_data = (! (isempty (data) || all (cellfun (@isempty, data))));
>>
>>     if (isempty (xlim))
>>       return;
>> @@ -1461,15 +1461,19 @@
>>       n = columns (data);
>>       have_nans = true;
>>       num_nan_elts = numel (nan_elts);
>> -      k = 1;
>> -      for i = 1:n
>> -       if (have_nans && i == nan_elts(k))
>> -         fputs (plot_stream, "\n");
>> -         have_nans = ++k <= num_nan_elts;
>> -       else
>> -         fprintf (plot_stream, fmt, data(:,i));
>> -       endif
>> -      endfor
>> +      if (num_nan_elts == n)
>> +       fputs (plot_stream, "Inf Inf\n");
>> +      else
>> +       k = 1;
>> +       for i = 1:n
>> +         if (have_nans && i == nan_elts(k))
>> +           fputs (plot_stream, "\n");
>> +           have_nans = ++k <= num_nan_elts;
>> +         else
>> +           fprintf (plot_stream, fmt, data(:,i));
>> +         endif
>> +       endfor
>> +      endif
>>     endif
>>   elseif (nd == 3)
>>     ## FIXME -- handle NaNs here too?
>> diff --git a/scripts/plot/print.m b/scripts/plot/print.m
>> --- a/scripts/plot/print.m
>> +++ b/scripts/plot/print.m
>> @@ -423,7 +423,7 @@
>>     endif
>>
>>     if (! isempty (convertname))
>> -      command = sprintf ("convert '%s' '%s'", name, convertname);
>> +      command = sprintf ("convert '%s' '%s'", name, convertname)
>>       [errcode, output] = system (command);
>>       unlink (name);
>>       if (errcode)
>>
>> _______________________________________________
>> Bug-octave mailing list
>> Bug-octave@...
>> https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave
>>
>>
>
> I transplanted this changeset without the removed semicolon in
> print.m. John, please fix it if it was a mistake; otherwise, let me
> know and I'll fix it.
>
OK, I see this is fixed by the next changeset. Sorry for the noise.


--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave

Re: Plot not robust with respect to Inf values

by deivid :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


gOS wrote:
Attempting to pass Inf or NaN to plot results in interestingly different results, and there's a bug somewhere in it.

plot(NaN,NaN) results in
error: plot: expecting first argument to be asex handle ... etc

plot(Inf,Inf) results in
line 15: undefined variable: Inf

gnuplot> plot "-" using ($1):($2) axes x1y1 title "" with lines ...

I'd assume that there is some sort of failure on all graphics packages. As Inf and NaN can appear in matrices, shouldn't plot be able to identify when its passed data it shouldn't be passed?

I view this as a bug. Matlab simply returns a blank plot while not crashing, if this isn't possible in Octave for each back end it probably needs to be handled.

Even getting an error from Octave instead of gnuplot would be good enough for me, currently operations procede if Inf is present so there is no way to catch on the issue besides checking every value in the matrix before plotting.
Has this been fixed yet?