Opened 9 years ago

Closed 9 years ago

#12462 closed defect (invalid)

max((5,NaN)) != max((NaN,5))

Reported by: schilly Owned by: burcin
Priority: major Milestone: sage-5.0
Component: symbolics Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by schilly)

With NaN as the first item in the sequence or list, it returns NaN.

sage: max((5,NaN))
sage: max((NaN,5))       

I think this is either a problem how NaN is defined in the symbolics framework, or how python's max works. Also, same holds true for min and probably similar operators …

Change History (2)

comment:1 Changed 9 years ago by schilly

  • Description modified (diff)
  • Summary changed from max((5,6,NaN)) != max((NaN,5,6)) to max((5,NaN)) != max((NaN,5))

comment:2 Changed 9 years ago by was

  • Resolution set to invalid
  • Status changed from new to closed

I think this should be closed as invalid. In pure Python (nothing to do with sage), we have:

$ python
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> nan = float('nan')
>>> max(5.0, nan)
>>> max(nan, 5.0)
>>> 5.0 > nan
>>> 5.0 < nan

This is a consequence of how Python's max is defined, and how IEEE defined comparison with nan. Read about that here:

See also for a discussion if *precisely* this exact issue in Python.

Again, I say close this as invalid. If anybody does anything to change Sage here, they will just make things incompatible with Python, which is a bad, bad idea. Python has already made this design choice, and we have to live with it.

Note: See TracTickets for help on using tickets.