Skip to content

Conversation

@agmangas
Copy link
Member

@agmangas agmangas commented Feb 10, 2026

Summary

  • The risk assessment professional output could fail when indicator arrays contained non-finite values that reached histogram generation.
  • This change filters indicator arrays to finite values before computing histogram bins and summary statistics, and returns an explicit empty-distribution payload when no finite values are available.

Changes

  • src/relife_financial/services/risk_assessment.py: Updated professional chart_metadata generation to use np.isfinite(...) filtering and avoid histogram/percentile operations on invalid arrays.
  • src/relife_financial/services/risk_assessment.py: Added fallback chart metadata for no-finite-data cases (empty bins, numeric default statistics, and informational note).

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the professional risk assessment response generation by preventing non-finite simulation values (NaN/Inf) from breaking chart distribution calculations, and by returning an explicit empty-distribution payload when no finite values exist.

Changes:

  • Filters indicator arrays to finite values before computing histogram bins and summary statistics in professional chart_metadata.
  • Adds an explicit fallback chart_metadata payload (empty bins + defaulted stats + note) when an indicator has no finite simulation values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@agmangas agmangas merged commit b971e9e into main Feb 11, 2026
2 checks passed
@agmangas agmangas deleted the fix/risk-assessment-nan-histogram-crash branch February 11, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant