Skip to content

Commit 6cfaec7

Browse files
committed
FIX: drop dead func call; move compute to where needed
1 parent 240b955 commit 6cfaec7

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ picard.egg-info/
2525
.tags
2626
tags
2727
.coverage
28-
python_picard.egg-info/
28+
python_picard.egg-info/
29+
30+
junit-results.xml

picard/_core_picard.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ def core_picard(X, density=Tanh(), ortho=False, extended=False, m=7,
8989
# Compute the relative gradient and the Hessian off-diagonal
9090
G = np.inner(psiY, Y) / T
9191
del psiY
92-
# Compute the squared signals
93-
Y_square = Y ** 2
9492
# Compute the kurtosis and update the gradient accordingly
9593
if extended:
9694
K = np.mean(psidY, axis=1) * np.diag(C)
@@ -115,10 +113,13 @@ def core_picard(X, density=Tanh(), ortho=False, extended=False, m=7,
115113
diag = psidY_mean[:, None] * np.ones(N)[None, :]
116114
h = 0.5 * (diag + diag.T - h_off[:, None] - h_off[None, :])
117115
h[h < lambda_min] = lambda_min
116+
del psidY
118117
else:
118+
# Compute the squared signals (only needed for this Hessian)
119+
Y_square = Y ** 2
119120
h = np.inner(psidY, Y_square) / T
120121
h = _regularize_hessian(h, h_off, lambda_min)
121-
del psidY, Y_square
122+
del psidY, Y_square
122123
# Project the gradient if ortho
123124
if ortho:
124125
G = (G - G.T) / 2

picard/densities.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def log_lik(self, Y):
4444
alpha = self.alpha # noqa
4545
if ne is None:
4646
absY = np.abs(Y)
47-
np.exp(-2. * alpha * absY)
4847
return absY + np.log1p(np.exp(-2. * alpha * absY)) / alpha
4948
return ne.evaluate('abs(Y) + log1p(exp(-2. * alpha * abs(Y))) / alpha')
5049

0 commit comments

Comments
 (0)