I think this is mostly unavoidable: cmath.log(z, 10) is a compound operation that does the equivalent of cmath.log(z) / cmath.log(10), while cmath.log10 is doing everything at once. If anything, this is a problem in how complex division is done: it's arguable that division by a complex number with zero imaginary part should be special-cased here. >>> inf = float('inf') >>> z = complex(-0.0, -inf) >>> cmath.log(10) (2.302585092994046+0j) >>> cmath.log(z) (inf-1.5707963267948966j) >>> cmath.log(z) / cmath.log(10) (inf+nanj) A simpler example just involving division: >>> complex(2.0, inf) / 2.0 # expect 1 + infj. (nan+infj)
One other option that doesn't involve changing the behaviour of complex division would be to special-case `cmath.log` in the case when the second argument is a float or an int.
Per: yes, that's true. I don't think changing either division or multiplication is the way forward for this issue, though; I'd rather implement the less invasive change where `cmath.log` special-cases the situation where its second argument is real and positive.
Closing as "won't fix". Two-argument log is already a rather unnatural beast to have in the cmath module, and I find it hard to imagine any real-world use-case caring about what happens for two-argument complex log applied to infinities or nans.
History
Date
User
Action
Args
2022-04-11 14:58:08
admin
set
github: 66734
2016-09-09 18:32:34
mark.dickinson
set
status: open -> closedresolution: wont fixmessages: + stage: resolved