Skip to content

Fix discrete-state validation regressions - #5400

Merged
FlorianPfaff merged 1 commit into
mainfrom
chatgpt/fix-discrete-state-validation
Aug 23, 2026
Merged

Fix discrete-state validation regressions#5400
FlorianPfaff merged 1 commit into
mainfrom
chatgpt/fix-discrete-state-validation

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

Fix two correctness regressions in src/pyrecest/filters/discrete_state.py that are already covered by regression tests on main:

  • reject NaN and +inf log-emission values in scaled_emissions, while preserving -np.inf as zero likelihood mass;
  • restore strict positive-integer validation for sticky_mode_transition_matrix / mode_transition_matrix, including rejection of booleans, floats, vector-valued arrays, and timedeltas while accepting NumPy integer scalars.

Why this matters

NaN and +inf were silently mapped to zero mass because all non-finite emissions shared the same handling path. This can hide upstream numerical failures and change inference results without an exception.

The mode-count validation was previously fixed in #4812 but was lost when the discrete-state implementation was later consolidated into discrete_state.py, leaving the regression tests behind.

Validation

Focused validation against the existing regression cases passes locally for:

  • tests/filters/test_discrete_state_nonfinite_emissions.py
  • tests/filters/test_discrete_state_mode_count_validation.py

The patch changes only one source file (11 additions, 2 deletions).

@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) August 23, 2026 06:00
@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 4.28s
✅ JSON prettier 7 0 0 0 0.36s
✅ JSON v8r 7 0 0 3.39s
✅ MARKDOWN markdownlint 68 0 0 0 1.26s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.45s
✅ PYTHON black 2009 23 0 0 37.16s
✅ PYTHON isort 2009 39 0 0 1.67s
✅ REPOSITORY betterleaks yes no no 0.67s
✅ REPOSITORY checkov yes no no 22.97s
✅ REPOSITORY git_diff yes no no 0.09s
✅ REPOSITORY secretlint yes no no 57.47s
✅ REPOSITORY syft yes no no 1.64s
✅ REPOSITORY trivy-sbom yes no no 1.46s
✅ YAML prettier 11 0 0 0 0.37s
✅ YAML v8r 11 0 0 11.98s
✅ YAML yamllint 11 0 0 0.6s

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 e78aaec into main Aug 23, 2026
14 of 24 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