Fredrik Johansson <fredrik.johans...@gmail.com> added the comment:

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 ;-)

----------
nosy: +fredrikj

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to