Menu

#1519 "set link" errormessage and wrong inverse detection

closed-fixed
nobody
None
5
2015-03-23
2014-11-28
No

The new "set link" command gives a very confusing error message when the linking functions do not contain the right independent variable:

set link y2 via 10**(x) inv log10(x) 
   internal error : type neither INT or CMPLX

This here even gives a different error:

# set xr[1:10]; set yr[1:10] # doesn't matter
set link y2 via log10(x) inv 10**x  
     unknown type in magnitude()

And sometimes a wrong inverse does not give an error at all:

set link x2 via 10**x inv log(x)                    # OK, error
    warning: could not confirm linked axis inverse mapping function
    min: -10 inv(via(min)): -23.0259  max: 10 inv(via(max)): 23.0259

set link x2 via 1-exp(-10**x) inv log10(-log(1-x))  # correct, no error 
set link x2 via 1-exp(-10**x) inv log10(-log(2-x))  # should give an error

Could it be this is because the wrong inverse function returns a complex value?

print log10(-log(1-(1-exp(-10**.4))))  
0.4
print log10(-log(2-(1-exp(-10**.4))))  
{-1.10794444658882, 1.36437635384184}

Discussion

  • Ethan Merritt

    Ethan Merritt - 2014-11-30

    I agree that better error messages for errors in the variable name would be nice. At the time I think I couldn't figure out how to do that, but I'm sure it's possible somehow.

    As to the rest...
    The tests for validity of the inverse function are pretty minimal, and could probably be improved. Your test case is really pushing it :-)

    1) Only the endpoints of the range are tested. Nonsense values in between would go undetected.

    2) Both inv log10(-log(1-x)) and inv log10(-log(2-x)) are "incorrect" in the sense that unless you limit the x range to less than 1 or less than 2 respectively. In a sense you can say that's "because the inverse returns a complex value". It happens that the implementation of log(x) is extended to handle complex values, other functions would return NaN if the x value goes out of range.

    3) The test compares absolute values. I cannot quite recall why, but I think the idea was to forgive pairs like (x**2) | sqrt(x) that are correct except for sign. Having said that, I think the fabs is in the wrong place so it really is a bug. I need to stare at it harder.

    So yeah, probably a complex return should be treated as NaN and therefore fail the sanity check. Also maybe the fabs() should be moved or maybe a 2nd one is needed.

    I suppose we could check not just the endpoints but every sampled value, although the sampling itself would have no meaning for data plots.

     
    • Karl Ratzsch

      Karl Ratzsch - 2014-11-30

      I think was OK if your example pair (x**2) | sqrt(x) threw a warning (as it does now, but that´s probably because of the bug).

      set link x2 via x**2 inv sqrt(x)
           warning: could not confirm linked axis inverse mapping function
          min: -10 inv(via(min)): 10  max: 10 inv(via(max)): 10
      

      Whoever sets up such a linkage knows it´s only partly right. I´d be rather confused to not get a warning.

      For such case there could be a "nowarn" option. It might be annoying to get cautioned at every replot. Also in case i don´t need the inverse and am too lazy to derive it.

       

      Last edit: Karl Ratzsch 2014-11-30
  • Ethan Merritt

    Ethan Merritt - 2014-12-03
    • status: open --> closed-fixed
     
  • Ethan Merritt

    Ethan Merritt - 2014-12-03

    cvs source for 5.1 now adds an error test for correct dummy variable use in "set link". This probably should go in 5.0 also but I haven't done that yet.

     
  • Karl Ratzsch

    Karl Ratzsch - 2015-02-03

    There is still something weird in both 5.0 and 5.1:

    If no explicit yrange is set, then the test (min == inv(via(min))) is always done for -10 (resp. 10 for max), regardless of the actual yrange in the present plot (as shown by "show yr").

    set xr [-2:0.99]
    plot x
    set link y via 1-exp(-10**y) inv log10(-log(1-y))  
    ## warning: could not confirm linked axis inverse mapping function
    ## min: -10 inv(via(min)): -10  max: 10 inv(via(max)): -10
    set yr [-2:0.99]     # no warning any more
    

    This is somewhat annoying, because it gives a warning on every replot

    And the maximum test returns the value from the minimum test if inv(via(max)) is not defined. I don´t think this could lead to an error, but it´s definitely odd.

    set yr [-2:1.7]     
    ## warning: could not confirm linked axis inverse mapping function
    ## min: -2 inv(via(min)): -2  max: 1.7 inv(via(max)): -2
    
     
  • Ethan Merritt

    Ethan Merritt - 2015-02-03

    default range:
    The default range is [-10:10] pretty much everywhere in gnuplot.
    Checking the range used in a previous plot would be possible, but why would you assume that the range will be the same as before? What if there was no previous plot? Even in the case of "replot", the data being plotted may have changed or there may have been an error or ...

    report of NaN:
    Yeah, that looks like a bug.

     
  • Karl Ratzsch

    Karl Ratzsch - 2015-02-03

    OK, let me change the example a bit:

    set yr [*:*]
    set link y via 1-exp(-10**y) inv log10(-log(1-y))  
    plot "datafile" us .....
    

    The axes are only generated after the data is read in, so the autoranged minimum/maximum is already known, and could be used to check the linkage.

    Does that make sense?

    Perhaps the test could additionally be skipped on "set link" (only there) if the respective axis is autoranging.

     

Log in to post a comment.