8000 Fix covariance byte-order conversion when sampling by ktz03 · Pull Request #219 · pykalman/pykalman · GitHub
[go: up one dir, main page]

Skip to content

Fix covariance byte-order conversion when sampling - #219

Open
ktz03 wants to merge 1 commit into
pykalman:mainfrom
ktz03:ai-pr/fix-sampling-byteorder
Open

ktz03 wants to merge 1 commit into
pykalman:mainfrom
ktz03:ai-pr/fix-sampling-byteorder

Conversation

@ktz03
@ktz03 ktz03 commented Oct 13, 2026
Copy link
Copy Markdown

Sampling from a model with non-native byte-order transition or observation covariance silently changes the covariance values. For example, a positive-definite float64 covariance converted to >f8 produces nearly zero noise on a little-endian machine, although its values and the sampling seed are unchanged.

Normalize covariance byte order with a value-preserving dtype conversion. The shared helper works with NumPy 1 and 2 and avoids copying arrays whose byte order is already correct. Add public sample() regressions for transition and observation covariance in all six filter classes, using both float32 and float64.

Validation on Windows with Python 3.12.14:

  • NumPy 1.26.4 / SciPy 1.17.1 and NumPy 2.5.4 / SciPy 1.18.1: pytest -q pykalman/tests pykalman/sqrt/tests — 65 passed, with 5 existing warnings in each environment.
  • All 24 new regression cases fail on the unmodified base in both environments and pass with the fix.
  • Public sampling controls for contiguous, read-only, and strided covariance inputs — 72 cases passed in each environment, with input values and storage properties unchanged.
  • python pykalman/_nopytest_tests.py, Ruff 0.8.0 checks and formatting, and git diff --cached --check 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

0