Skip to content

Fix datasample to support k=0 empty array returns - #474

Merged
pr0m1th3as merged 1 commit into
gnu-octave:mainfrom
Sonu0305:fix-datasample
Sep 8, 2026
Merged

Fix datasample to support k=0 empty array returns#474
pr0m1th3as merged 1 commit into
gnu-octave:mainfrom
Sonu0305:fix-datasample

Conversation

@Sonu0305

@Sonu0305 Sonu0305 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

In MATLAB, calling datasample(data, 0) returns an empty array that preserves the non-sampled dimensions of the input data (e.g., datasample(zeros(0,3), 0) returns a 0x3 array). In Octave, passing k=0 throws a validation error: k must be a positive integer scalar. So this is fixed now via this pr.

@pr0m1th3as
pr0m1th3as merged commit 0c5e30b into gnu-octave:main Sep 8, 2026
@Sonu0305
Sonu0305 deleted the fix-datasample branch September 8, 2026 18:21
pr0m1th3as added a commit that referenced this pull request Sep 8, 2026
…ts (#474).

  The preallocation for weighted sampling without replacement is a column,
  as it already is with replacement.

  Two tests cover k = 0 with weights, one per replacement mode.  The four
  error tests for K match the full message.
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