Skip to content

Validate stickiness inputs for mode transition matrices - #5463

Merged
FlorianPfaff merged 2 commits into
mainfrom
fix-sticky-transition-stickiness-validation
Aug 30, 2026
Merged

Validate stickiness inputs for mode transition matrices#5463
FlorianPfaff merged 2 commits into
mainfrom
fix-sticky-transition-stickiness-validation

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

Fix the public sticky_mode_transition_matrix input contract so malformed stickiness values fail deterministically instead of being silently coerced or leaking NumPy-specific exceptions.

Bug

The compatibility wrapper validates n_modes but previously passed stickiness through unchanged. Consequently:

  • True / False were silently accepted as probabilities 1.0 / 0.0.
  • strings, complex values, and non-scalar arrays could fail with incidental TypeError / ambiguous-truth-value errors from NumPy rather than the documented ValueError contract.

Fix

  • Require stickiness to be a finite real scalar in [0, 1].
  • Explicitly reject booleans, text, complex values, and non-scalar arrays.
  • Continue accepting ordinary Python/NumPy real scalars and 0-D real arrays.
  • Add regression tests for both invalid and valid scalar inputs.

The branch is based directly on current main and changes only the discrete-state compatibility validator and its focused regression tests.

@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Max errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 7.67s
✅ JSON prettier 7 0 0 0 0.71s
✅ JSON v8r 7 0 0 4.78s
✅ MARKDOWN markdownlint 68 0 0 0 1.95s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.4s
✅ PYTHON black 2036 1 0 0 66.64s
✅ PYTHON isort 2036 5 0 0 3.0s
✅ REPOSITORY betterleaks yes no no 1.37s
✅ REPOSITORY checkov yes no no 34.03s
✅ REPOSITORY git_diff yes no no 0.27s
✅ REPOSITORY secretlint yes no no 107.24s
✅ REPOSITORY syft yes no no 3.56s
✅ REPOSITORY trivy-sbom yes no no 3.04s
✅ YAML prettier 11 0 0 0 0.88s
✅ YAML v8r 11 0 0 18.14s
✅ YAML yamllint 11 0 0 1.04s

Notices

⚠️ Your configuration references items that have been removed from MegaLinter and are ignored: MAKEFILE_CHECKMAKE. See Removed linters to find their replacements.

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@10.0.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_BETTERLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

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

@FlorianPfaff
FlorianPfaff merged commit e841056 into main Aug 30, 2026
26 checks passed
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