Skip to content

Commit 8f02a3a

Browse files
fix typo in docstring, use fixed-length np array to collect log_gammas instead of appending to an empty list
1 parent 441dc4c commit 8f02a3a

File tree

1 file changed

+5
-4
lines changed
  • bayesflow/diagnostics/metrics

1 file changed

+5
-4
lines changed

bayesflow/diagnostics/metrics/sbc.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def log_gamma(
5252
- "values" : float or np.ndarray
5353
The log gamma values per variable
5454
- "metric_name" : str
55-
The name of the metric ("Log Gamme").
55+
The name of the metric ("Log Gamma").
5656
- "variable_names" : str
5757
The (inferred) variable names.
5858
"""
@@ -74,13 +74,14 @@ def log_gamma(
7474
null_quantile = np.quantile(null_distribution, quantile)
7575

7676
# compute log gamma for each parameter
77-
log_gammas = []
77+
log_gammas = np.empty(ranks.shape[-1])
78+
7879
for i in range(ranks.shape[-1]):
7980
gamma = gamma_discrepancy(ranks[:, i], num_post_draws=num_post_draws)
80-
log_gammas.append(np.log(gamma / null_quantile))
81+
log_gammas[i] = np.log(gamma / null_quantile)
8182

8283
output = {
83-
"values": np.array(log_gammas),
84+
"values": log_gammas,
8485
"metric_name": "Log Gamma",
8586
"variable_names": samples["estimates"].variable_names,
8687
}

0 commit comments

Comments
 (0)