Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quantile may panic #39

Closed
asmyers opened this issue Mar 30, 2021 · 2 comments
Closed

quantile may panic #39

asmyers opened this issue Mar 30, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@asmyers
Copy link

asmyers commented Mar 30, 2021

#![feature(drain_filter)]

#[macro_use]
extern crate peroxide;
use peroxide::fuga::*;
use peroxide::statistics::*;

use std::{env, ops::Index};

fn main() -> Result<(), Box<dyn Error>> {
    let data = vec![0f64; 7592];
    let q = quantile(&data, QType::Type1);
    println!("{:?}", q);
    Ok(())
}

Panics with the following:

   Running `target\debug\o2ring.exe C:\Users\asm19\OneDrive\zettlekasten\o2ring\2021-03-28.csv`
thread 'main' panicked at 'index out of bounds: the len is 7592 but the index is 7592', C:\Users\asm19\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\slice\mod.rs:566:36
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597\/library\std\src\panicking.rs:493
   1: core::panicking::panic_fmt
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597\/library\core\src\panicking.rs:92
   2: core::panicking::panic_bounds_check
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597\/library\core\src\panicking.rs:69
   3: core::slice::{{impl}}::swap<f64>
             at C:\Users\asm19\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\slice\mod.rs:566
   4: order_stat::floyd_rivest::select_<f64,closure-0>
             at C:\Users\asm19\.cargo\registry\src\github.com-1ecc6299db9ec823\order-stat-0.1.3\src\floyd_rivest.rs:37
   5: order_stat::floyd_rivest::select_<f64,closure-0>
             at C:\Users\asm19\.cargo\registry\src\github.com-1ecc6299db9ec823\order-stat-0.1.3\src\floyd_rivest.rs:32
   6: order_stat::floyd_rivest::select<f64,closure-0>
             at C:\Users\asm19\.cargo\registry\src\github.com-1ecc6299db9ec823\order-stat-0.1.3\src\floyd_rivest.rs:8
   7: order_stat::kth_by<f64,closure-0>
             at C:\Users\asm19\.cargo\registry\src\github.com-1ecc6299db9ec823\order-stat-0.1.3\src\lib.rs:192
   8: peroxide::statistics::stat::quantile_mut
             at C:\Users\asm19\.cargo\registry\src\github.com-1ecc6299db9ec823\peroxide-0.30.5\src\statistics\stat.rs:504
   9: peroxide::statistics::stat::{{impl}}::quantiles
             at C:\Users\asm19\.cargo\registry\src\github.com-1ecc6299db9ec823\peroxide-0.30.5\src\statistics\stat.rs:485
  10: peroxide::statistics::stat::quantile
             at C:\Users\asm19\.cargo\registry\src\github.com-1ecc6299db9ec823\peroxide-0.30.5\src\statistics\stat.rs:527
  11: o2ring::main
             at .\src\main.rs:12
  12: core::ops::function::FnOnce::call_once<fn() -> core::result::Result<tuple<>, alloc::boxed::Box<Error, alloc::alloc::Global>>,tuple<>>
             at C:\Users\asm19\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:227
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@Axect Axect added the bug Something isn't working label Mar 31, 2021
Axect added a commit that referenced this issue Mar 31, 2021
* Fix a bug in `quantile`
@Axect
Copy link
Owner

Axect commented Mar 31, 2021

Thank you so much!
I didn't consider that case. (k >= l)
Now, I fix bugs in quantile_mut, quantile, quantiles and publish Ver 0.30.6.
Thank you once again for your great contribution! 👍

@asmyers
Copy link
Author

asmyers commented Mar 31, 2021

Awesome, works for me now! Thank you!

@asmyers asmyers closed this as completed Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants