New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
float(CDF(1)) should return 1.0, not throw an error #8869
Comments
Attachment: complex-float.patch.gz |
comment:2
The patch needs to have commit message, and doctests need to be run. |
comment:3
See also http://groups.google.com/group/sage-devel/browse_thread/thread/75b8f85d22499ceb# (I don't like the use of Python conversion functions on Sage objects.) Why (only) suggest use of Is |
Author: Jason Grout |
comment:4
Ready for review. Leif's comment seems reasonable, so I added one (!) extra option in the error message. Passes tests on these two files. |
Reviewer: Karl-Dieter Crisman, Leif Leonhardy |
Attachment: trac_8869.patch.gz Based on 4.4.2, apply only this patch |
comment:5
Well, (And note that Nevertheless, I'll test it as soon as the "normal" 4.4.3.alpha0 ptestlong finishes on my Pentium 4, just wait a few hours... ;-) |
comment:6
I don't think we are trying to be contentious here. Yes, there are inconsistencies, but that is just to be expected (I would even say it follows from Arrow's Theorem). The point is to make it as natural to mathematicians as possible, and float(CDF(1)) certainly smells like 1.0 to me. int is a little different, but it seems to me that since Python isn't consistent anyways
we might as well make the best of it and let int be the "round closest to zero" function, in essence. And it's documented, and it's not the natural thing one would do (Integer(1.1) behaves as you would like). |
comment:7
The Python behavior could be "catched" by the preparser. There have recently been long discussions about Sage's "coercion model"... Applied Karl-Dieter's patch on 4.4.3.alpha0.
Positive review. |
comment:8
|
Changed keywords from none to CDF conversion, complex double |
Merged: sage-4.4.4.alpha0 |
Right now, we have the following behavior:
As robertwb and was voted (on #5400 comment:12 and on sage-devel), we should make float conversion succeed if the imaginary part is zero.
Component: basic arithmetic
Keywords: CDF conversion, complex double
Author: Jason Grout
Reviewer: Karl-Dieter Crisman, Leif Leonhardy
Merged: sage-4.4.4.alpha0
Issue created by migration from https://trac.sagemath.org/ticket/8869
The text was updated successfully, but these errors were encountered: