Skip to content

Accept strided inputs in Numba-backed features - #60

Draft
AHMETHAKANBEZIR1 wants to merge 1 commit into
raphaelvallat:masterfrom
AHMETHAKANBEZIR1:fix/strided-numba-inputs
Draft

AHMETHAKANBEZIR1 wants to merge 1 commit into
raphaelvallat:masterfrom
AHMETHAKANBEZIR1:fix/strided-numba-inputs

Conversation

@AHMETHAKANBEZIR1

Copy link
Copy Markdown

sample_entropy, higuchi_fd and detrended_fluctuation reject valid noncontiguous float64 arrays because their Numba kernels have C-contiguous signatures. A common downsampling view, np.random.default_rng(42).normal(size=200)[::2], raises TypeError: No matching definition ... array(float64, 1d, A) in all three functions, although copying the same samples works.

Make the array contiguous at the three Numba call boundaries. Contiguous inputs are reused, while strided views get a copy; the numerical algorithms, float64 conversion and sample-entropy KDTree routes are retained. This groups the three occurrences of the same layout-contract bug in one fix.

Validation on Windows CPU, Python 3.12.14:

  • 50 regression cases cover positive/negative strides, column views, contiguous controls, float32/64 conversion, writable/read-only inputs, and both sample-entropy KDTree routes. Unmodified master 6843920: 18 fail and 32 controls pass. Fixed: all 50 pass, with exact equality to contiguous copies and unchanged source samples/writeability.
  • Full suite: 84 passed with NumPy 2.5.4, and 84 passed with NumPy 1.26.4 (Numba 0.68.0, SciPy 1.17.1, scikit-learn 1.9.1).
  • Full Ruff lint/format and whitespace checks passed.

Other operating systems, doctests and performance benchmarks were not run.

AI disclosure: OpenAI Codex autonomously investigated and implemented the patch/tests, wrote the description and ran the reported checks. No independent human pre-submission review has been performed.

@raphaelvallat

Copy link
Copy Markdown
Owner

Thank you for your contribution!

AntroPy now has guidelines for pull requests, including specific steps for AI-assisted PRs: #61

Before I review this PR, could you please go through those steps and update the PR accordingly? In particular: state the user-impact rating (P1-P3) with a short justification, start the description with a summary in your own words, report the exact AI model used (if any), and run an AI review and post a summary of it as a comment. Thanks!

@AHMETHAKANBEZIR1
AHMETHAKANBEZIR1 marked this pull request as draft October 24, 2026 12:27

This branch has not been deployed

No deployments
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.

2 participants