#261 max() fails on nan

critical
closed-fixed
nobody
core (120)
5
2013-11-12
2011-03-22
No

Are nans supposed to be treated as BADs (and be ignored)? Or as invalidators (and be always max)? Either way, max() currently gets it wrong:

$ a= pdl(5)
$b = asin(1.1)
$c = pdl($b,$b,$a,$b,$b)
p $c->max
$c = pdl(2,$b,$a,$b,$b)
p $c->max

prints "nan 5".

Discussion

  • Chris Marshall

    Chris Marshall - 2011-03-22

    It looks like we're inconsistent because the search for
    the maximum value is initialized by the first value.
    I think the result in both your cases should be 5. The
    wikipedia discussion re NaN suggests the same is the
    typical usage---although the other approach is sometimes
    used. I assume that the other projection operations have
    the same issues?

     
  • Chris Marshall

    Chris Marshall - 2011-03-22

    I took a quick look at the code and it appears the behavior in
    question has been in for >5 years. It could be a bit tricky to
    sort out correctly so lets add this to Known_problems for
    PDL-2.4.8 and, perhaps, add some TODO {} tests to remind
    us of the issue.

     
  • Chris Marshall

    Chris Marshall - 2011-03-22
    • status: open --> open-later
     
  • Chris Marshall

    Chris Marshall - 2011-10-03
    • priority: 5 --> 6
     
  • Chris Marshall

    Chris Marshall - 2011-12-22

    This will be addressed following the PDL-2.4.10 release.

     
  • Chris Marshall

    Chris Marshall - 2011-12-22
    • priority: 6 --> 5
     
  • Craig DeForest

    Craig DeForest - 2013-11-12

    Fixed in git master. Now:
    - NaNs are properly ignored regardless of location
    - max/min of empty PDLs returns BAD if possible, or (NaN if possible, or (0))
    - Extended empties are treated correctly (e.g. $a=zeroes(3,0,2)->maximum yields a 0x2 empty); this is handled properly by the threading engine.

     
    Last edit: Craig DeForest 2013-11-12
  • Craig DeForest

    Craig DeForest - 2013-11-12
    • status: open-later --> closed-fixed
    • Group: --> critical
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks