Skip to content

Commit

Permalink
Fix DeprecationWarning with np.squeeze()
Browse files Browse the repository at this point in the history
DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
  • Loading branch information
woctezuma committed Apr 29, 2024
1 parent 3c58047 commit 9a3b0b2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions compute_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,15 @@ def choose_x0(data_vec):
res = minimize(fun=function_to_minimize, x0=choose_x0(vec), method="Nelder-Mead")

optimal_parameters = [res.x]
alpha = np.squeeze(optimal_parameters[0])

try:
optimal_power = log10(optimal_parameters[0])
optimal_power = log10(alpha)
if verbose:
print("alpha = 10^%.2f" % optimal_power)
except ValueError:
if verbose:
print("alpha = %.2f" % optimal_parameters[0])
print("alpha = %.2f" % alpha)

return optimal_parameters

Expand Down

0 comments on commit 9a3b0b2

Please sign in to comment.