Skip to content

Validate piecewise numerical PDF outputs#3188

Open
FlorianPfaff wants to merge 2 commits into
mainfrom
fix-piecewise-pdf-scalar-validation
Open

Validate piecewise numerical PDF outputs#3188
FlorianPfaff wants to merge 2 commits into
mainfrom
fix-piecewise-pdf-scalar-validation

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

  • Validate each pdf_func value returned to PiecewiseConstantDistribution.calculate_parameters_numerically before passing it to SciPy quadrature.
  • Accept scalar and single-element outputs, but reject empty or multi-element outputs instead of silently using the first flattened value.
  • Reject non-finite numerical PDF outputs and add regression coverage for scalar, malformed, and non-finite returns.

Bug fixed

calculate_parameters_numerically() previously evaluated float(array(pdf_func(array([x]))).reshape(-1)[0]). If a caller supplied a malformed pdf_func that returned an empty vector, the error was obscure; if it returned multiple values for one integration point, the routine silently integrated only the first value and ignored the rest. That can produce misleading discretized weights from an invalid PDF contract.

Validation

  • Syntax-checked the modified source and test module with ast.parse locally.
  • Ran an isolated local harness for the new scalar-output validation behavior: scalar output integrates to uniform weights, empty/vector outputs raise ValueError, and NaN output raises ValueError.
  • Full repository pytest was not run locally because the sandbox cannot resolve github.com to clone/install the full repository dependency set.

@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 72.78s
✅ JSON prettier 7 0 0 0 1.05s
✅ JSON v8r 7 0 0 5.53s
✅ MARKDOWN markdownlint 68 0 0 0 1.74s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.91s
✅ PYTHON black 1036 38 0 0 65.8s
✅ PYTHON isort 1036 56 0 0 4.24s
✅ REPOSITORY checkov yes no no 51.02s
✅ REPOSITORY gitleaks yes no no 7.56s
✅ REPOSITORY git_diff yes no no 0.1s
✅ REPOSITORY secretlint yes no no 31.28s
✅ REPOSITORY syft yes no no 3.77s
✅ REPOSITORY trivy-sbom yes no no 11.55s
✅ REPOSITORY trufflehog yes no no 21.47s
✅ YAML prettier 11 0 0 0 0.92s
✅ YAML v8r 11 0 0 10.36s
✅ YAML yamllint 11 0 0 0.54s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.5.0 --custom-flavor-setup --custom-flavor-linters PYTHON_BLACK,PYTHON_ISORT,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GITLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

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