Skip to content

Commit 336f15b

Browse files
committed
Consistent defaults for variable_keys/names in calibration_ecdf with test quantiles
1 parent 3803327 commit 336f15b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

bayesflow/diagnostics/plots/calibration_ecdf.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,21 @@ def calibration_ecdf(
153153
test_quantities_estimates[key] = np.reshape(flat_tq_estimates, (num_conditions, num_samples, 1))
154154

155155
# Add custom test quantities to variable keys and names for plotting
156-
variable_keys = list(test_quantities.keys()) + variable_keys
157-
variable_names = list(test_quantities.keys()) + variable_names
156+
# keys and names are set to the test_quantities dict keys
157+
test_quantities_names = list(test_quantities.keys())
158+
159+
# By default all keys in estimates are selected
160+
if variable_keys is None:
161+
variable_keys = list(estimates.keys())
162+
163+
# If variable_names are present, concatenate them to the test_quantities_names
164+
if isinstance(variable_names, list):
165+
variable_names = test_quantities_names + variable_names
166+
# If variable_names are None, they will stay None here and are subsequently inferred.
167+
168+
# After the defaults are handled, we simply concatenate the keys
169+
# for test quantities and regular variables.
170+
variable_keys = test_quantities_names + variable_keys
158171

159172
# Prepend test quantities to draws
160173
estimates = test_quantities_estimates | estimates

0 commit comments

Comments
 (0)