From 5a988d194381c0352503591417d76d96b812db16 Mon Sep 17 00:00:00 2001 From: Aramis <116808832+AramisDuf@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:10:41 -0700 Subject: [PATCH] Improve code readability --- src/spcqe/extrapolate_asymptotic.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/spcqe/extrapolate_asymptotic.py b/src/spcqe/extrapolate_asymptotic.py index 1849a53..37543c0 100644 --- a/src/spcqe/extrapolate_asymptotic.py +++ b/src/spcqe/extrapolate_asymptotic.py @@ -59,11 +59,10 @@ def safe_exp(exp_input): return exp_output def safe_log(log_input): - return np.where( - log_input <= 0, - -np.inf, # Return -inf for invalid log input - np.log(log_input) - ) + log_output = np.empty_like(log_input) + log_output[log_input <= 0] = -np.inf + log_output[log_input > 0] = np.log(log_input[log_input > 0]) + return log_output def plot_pdf(ax, transf, label):