Opened 9 years ago
Last modified 8 years ago
#14088 new defect
Comparison of python and sage complex numbers
Reported by: | tscrim | Owned by: | tscrim |
---|---|---|---|
Priority: | major | Milestone: | sage-6.4 |
Component: | basic arithmetic | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
We have the following behavior:
sage: complex('inf') (inf+0j) sage: CC(oo) +infinity sage: complex('inf') < complex(0) # This is good --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-84-743f29f99a3c> in <module>() ----> 1 complex('inf') < complex(Integer(0)) TypeError: no ordering relation is defined for complex numbers sage: complex('inf') < float(0) # Still good --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-85-ec0c40060e5d> in <module>() ----> 1 complex('inf') < float(Integer(0)) TypeError: no ordering relation is defined for complex numbers # These are all not good sage: complex('inf') < 0 True sage: complex(oo) < RR(0) True sage: complex(oo) < RR(oo) False sage: complex(oo) < RR(-oo) True
We also have the comparison failures with sage's complex infinity:
sage: CC(oo) < 0 # This is okay False sage: CC(oo) > 0 True sage: CC(oo) > CC(2+5*i) True sage: CC(2+4*i) < CC(2+5*i) True sage: CC(2+6*i) < CC(2+5*i) False
I believe all comparisons in the complex number should raise a TypeError
to be consistent with python. The other alternative should be they always return False
.
There is also the related #11506.
Change History (4)
comment:1 Changed 9 years ago by
- Milestone changed from sage-5.11 to sage-5.12
comment:2 Changed 8 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:3 Changed 8 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:4 Changed 8 years ago by
- Milestone changed from sage-6.3 to sage-6.4
Note: See
TracTickets for help on using
tickets.