Skip to content

Commit eb7625e

Browse files
Longkang(Loka) Liclaude
andcommitted
Style: use for-loop to match MATLAB original for gradient computation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 70beef4 commit eb7625e

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

causallearn/utils/ScoreUtils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -504,12 +504,12 @@ def gpr_multi_new(logtheta=None, covfunc=None, x=None, y=None, xstar=None, nargo
504504
# Only compute gradient for the last hyperparameter (noise variance).
505505
# Kernel widths are fixed per the paper (Huang et al., 2018, Sec 4.2.2):
506506
# "the kernel widths of variables are fixed in order to work on fixed RKHSs"
507-
i = len(out2) - 1
508-
temp = list(covfunc.copy())
509-
temp.append(logtheta)
510-
temp.append(x)
511-
temp.append(i)
512-
out2[i] = np.sum(np.multiply(W, feval(temp))) / 2
507+
for i in range(len(out2) - 1, len(out2)):
508+
temp = list(covfunc.copy())
509+
temp.append(logtheta)
510+
temp.append(x)
511+
temp.append(i)
512+
out2[i] = np.sum(np.multiply(W, feval(temp))) / 2
513513
else: # ... otherwise compute (marginal) test predictions ...
514514
temp = list(covfunc.copy())
515515
temp.append(logtheta)

0 commit comments

Comments
 (0)