Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/nbi/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,10 @@ def importance_reweight(self, x_obs, x, y):
log_weights = loglike + logprior - logproposal

bad = np.isnan(log_weights) + np.isinf(log_weights)
valid_weights = log_weights[~bad]
if len(valid_weights) == 0:
print("All log weights are NaN or Inf — skipping this round!")

Copilot AI Aug 7, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using print() for warnings is not ideal. Consider using the logging module or warnings.warn() for better control over diagnostic output and to follow Python best practices.

Suggested change
print("All log weights are NaN or Inf — skipping this round!")
warnings.warn("All log weights are NaN or Inf — skipping this round!")

Copilot uses AI. Check for mistakes.
return np.zeros_like(log_weights)
log_weights -= log_weights[~bad].max()

weights = np.exp(log_weights)
Expand Down