Skip to content

Refactored ks_twosample to take in two slices instead of a mutable owned Vec<f64>#406

Open
AshrafIbrahim03 wants to merge 4 commits into
statrs-dev:mainfrom
AshrafIbrahim03:main
Open

Refactored ks_twosample to take in two slices instead of a mutable owned Vec<f64>#406
AshrafIbrahim03 wants to merge 4 commits into
statrs-dev:mainfrom
AshrafIbrahim03:main

Conversation

@AshrafIbrahim03

Copy link
Copy Markdown

Through some discussion in #405 , it seemed like refactoring ks_twosample was needed. Basically just changed the function signature from:

pub fn ks_twosample(
    mut data1: Vec<f64>,
    mut data2: Vec<f64>,
    method: KSTwoSampleAlternativeMethod,
    nan_policy: NaNPolicy,
) -> Result<(f64, f64), KSTestError>

to

pub fn ks_twosample(
    data1: &[f64],
    data2: &[f64],
    method: KSTwoSampleAlternativeMethod,
    nan_policy: NaNPolicy,
) -> Result<(f64, f64), KSTestError>

This is more in line with what's in other files in the same folder.

@day01

day01 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

@AshrafIbrahim03 did you verify tests with all targets n features?

@AshrafIbrahim03

Copy link
Copy Markdown
Author

I did not. I just reread through the contributing section of the README to see if it details how to run those, but I don't see it. How can I do that?

@day01

day01 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

probably you find out:
cargo test

Thanks, the call sites compile now. I checked the latest commit but three KS tests still fail. currently order is wrong. are you sure it should be like that? may you add some context to Pr ?

@AshrafIbrahim03

Copy link
Copy Markdown
Author

Yes, just saw the last three tests fail, pushing a fix for it now!

Some more context: basically we were talking about a contribution I could make in #405 , and it seemed like changing the ks sampling function to take a &[f64] instead of a mut Vec<f64> would be more in line with the other files, anderson_darling and chi_square.

I also noticed the ks one sample function that I should probably bundle in this PR too!

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