-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Closed
Labels
33 - QuestionQuestion about NumPy usage or developmentQuestion about NumPy usage or development57 - Close?Issues which may be closable unless discussion continuedIssues which may be closable unless discussion continued
Description
np.log1p
is a great function but not having alternatives with different bases (like log2 and log10) is very limiting. I wonder if it'd be possible to add other functions like log2_1p
and log10_1p
(and possibly exp2_m1
and exp10_m1
).
I played around with some numba-based solutions such as this one based on the original implementation in numpy:
@vectorize([float64(int32),
float64(int64),
float32(float32),
float64(float64)])
def log10_1p(x):
if np.isinf(x) and x > 0:
return x
u = 1. + x
d = u - 1.
if d == 0:
return x
return np.log10(u) * x / d
it seems to be working well (see https://nbviewer.ipython.org/gist/gokceneraslan/2744cfeda702fb9b9e48d0216427372c for some results) but having a numpy-native function would be really great.
PS: Can anybody explain why there is a * x / d
in the end? Maybe @khinsen can shed some light.
Metadata
Metadata
Assignees
Labels
33 - QuestionQuestion about NumPy usage or developmentQuestion about NumPy usage or development57 - Close?Issues which may be closable unless discussion continuedIssues which may be closable unless discussion continued