This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author fredrikj
Recipients fredrikj, josh.r, lemburg, mark.dickinson, nagayev, rhettinger, stutzbach, tim.peters, zach.ware
Date 2019-03-08.20:48:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1552078134.11.0.399017636039.issue36228@roundup.psfhosted.org>
In-reply-to
Content
I can think of two reasons to extend floor() and ceil() to complex numbers, and they lead to different extensions.

The first is as a way to map complex numbers to nearby Gaussian integers by defining floor(z) = floor(z.real) + floor(z.imag)*1j, etc. Definition in mpmath borrowed from Mathematica. Conceivably handy for data quantization, or discrete plane geometry... but I honestly never used it myself and can't remember ever seeing it used.

The second is to extend piecewise analytic functions on R to piecewise holomorphic functions on C so that the real analytic segments extend to complex analytic neighborhoods, most easily achieved by defining floor(z) = floor(z.real). This one I've actually had use for (think complex step differentiation, contour integration), but it's a bit esoteric.

My opinion? If a Python user calls floor() and ceil() with a complex input, it's probably because of a bug in their code, and TypeError is appropriate. It's a one-line lambda to define your own complex extension if you really need it.

On the other hand: if it exists, someone will eventually find a way to use it for code golf ;-)
History
Date User Action Args
2019-03-08 20:48:54fredrikjsetrecipients: + fredrikj, lemburg, tim.peters, rhettinger, mark.dickinson, stutzbach, zach.ware, josh.r, nagayev
2019-03-08 20:48:54fredrikjsetmessageid: <1552078134.11.0.399017636039.issue36228@roundup.psfhosted.org>
2019-03-08 20:48:54fredrikjlinkissue36228 messages
2019-03-08 20:48:53fredrikjcreate