Skip to content

Commit cfed918

Browse files
committed
fix zero_size array issues
1 parent 3b8ad60 commit cfed918

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

preliz/distributions/logitnormal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def rvs(self, size=None, random_state=None):
134134

135135
def _fit_moments(self, mean, sigma):
136136
mu = logit(mean)
137-
sigma = np.diff((mean - sigma * 3, mean + sigma * 3))
137+
sigma = np.diff((mean - sigma * 3, mean + sigma * 3)).squeeze()
138138
self._update(mu, sigma)
139139

140140
def _fit_mle(self, sample):

preliz/internal/optimization.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,16 @@ def fpf(theta):
224224
return (xi(theta) * (1 + ratio**2) - 2) ** 0.5
225225

226226
def func(theta):
227-
return np.abs(fpf(theta) - theta)
227+
theta0 = theta[0]
228+
return abs(fpf(theta0) - theta0)
228229

229-
theta = minimize(func, x0=fpf(1), bounds=[(0, None)]).x
230+
theta0 = float(fpf(1.0))
231+
theta = minimize(func, x0=np.array([theta0]), bounds=[(0, None)]).x.item()
230232
xi_theta = xi(theta)
231233
sigma = std_dev / xi_theta**0.5
232234
nu = (mean**2 + (xi_theta - 2) * sigma**2) ** 0.5
233235

234-
return nu, sigma
236+
return float(nu), float(sigma)
235237

236238

237239
def optimize_ml(dist, sample):

0 commit comments

Comments
 (0)