Message337529
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 ;-) |
|
Date |
User |
Action |
Args |
2019-03-08 20:48:54 | fredrikj | set | recipients:
+ fredrikj, lemburg, tim.peters, rhettinger, mark.dickinson, stutzbach, zach.ware, josh.r, nagayev |
2019-03-08 20:48:54 | fredrikj | set | messageid: <1552078134.11.0.399017636039.issue36228@roundup.psfhosted.org> |
2019-03-08 20:48:54 | fredrikj | link | issue36228 messages |
2019-03-08 20:48:53 | fredrikj | create | |
|