You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/04/26 12:34:07 UTC

[GitHub] [arrow-rs] alamb opened a new issue #101: min and max aggregate kernels are inconsistent for floating point types.

alamb opened a new issue #101:
URL: https://github.com/apache/arrow-rs/issues/101


   *Note*: migrated from original JIRA: https://issues.apache.org/jira/browse/ARROW-9975
   
   The aggregation kernels min and max yield inconsistent results if there are NaN values in the arrays.
   
   Related issue: [https://github.com/ritchie46/polars/issues/71]
   {code:c++}
           use arrow::{
               datatypes::Float64Type,
               compute::kernels::aggregate::min,
               array::{
                   PrimitiveBuilder
               }
           };
           let mut builder_1 = PrimitiveBuilder::<Float64Type>::new(2);
           builder_1.append_value(1.0).unwrap();
           builder_1.append_value(f64::NAN).unwrap();
           let array_1 = builder_1.finish();
   
           let mut builder_2 = PrimitiveBuilder::<Float64Type>::new(2);
           builder_2.append_value(f64::NAN).unwrap();
           builder_2.append_value(1.0).unwrap();
           let array_2 = builder_2.finish();
    
           // expect both nan, or both 1.0
           assert_eq!(min(&array_1), min(&array_2));
   {code}
   Outputs:
   {code:bash}
   Left:  Some(1.0)
   Right: Some(NaN)
   <Click to see difference>
   
   thread 'frame::ser::csv::test::test_' panicked at 'assertion failed: `(left == right)`
     left: `Some(1.0)`,
    right: `Some(NaN)`', polars/src/frame/ser/csv.rs:328:9
   stack backtrace:
      0: rust_begin_unwind
                at /rustc/73dc675b9437c2a51a975a9f58cc66f05463c351/library/std/src/panicking.rs:483
      1: std::panicking::begin_panic_fmt
                at /rustc/73dc675b9437c2a51a975a9f58cc66f05463c351/library/std/src/panicking.rs:437
      2: polars::frame::ser::csv::test::test_
                at ./src/frame/ser/csv.rs:328
      3: polars::frame::ser::csv::test::test_::{{closure}}
                at ./src/frame/ser/csv.rs:310
      4: core::ops::function::FnOnce::call_once
                at /home/ritchie46/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227
      5: core::ops::function::FnOnce::call_once
                at /rustc/73dc675b9437c2a51a975a9f58cc66f05463c351/library/core/src/ops/function.rs:227
   note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
   
   error: test failed, to rerun pass '-p polars --lib'
   {code}


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-rs] alamb closed issue #101: min and max aggregate kernels are inconsistent for floating point types.

Posted by GitBox <gi...@apache.org>.
alamb closed issue #101:
URL: https://github.com/apache/arrow-rs/issues/101


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-rs] HaoYang670 edited a comment on issue #101: min and max aggregate kernels are inconsistent for floating point types.

Posted by GitBox <gi...@apache.org>.
HaoYang670 edited a comment on issue #101:
URL: https://github.com/apache/arrow-rs/issues/101#issuecomment-1046508881


   Could we close this issue, as `NaN` has been considered to be greater than non-NaN values?
   ```rust
   pub fn min<T>(array: &PrimitiveArray<T>) -> Option<T::Native>
   where
       T: ArrowNumericType,
       T::Native: ArrowNativeType,
   {
       min_max_helper(array, |a, b| (is_nan(*a) & !is_nan(*b)) || a > b)
   }
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-rs] HaoYang670 commented on issue #101: min and max aggregate kernels are inconsistent for floating point types.

Posted by GitBox <gi...@apache.org>.
HaoYang670 commented on issue #101:
URL: https://github.com/apache/arrow-rs/issues/101#issuecomment-1046508881


   Could we close this issue, as we can pass this test now ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-rs] alamb commented on issue #101: min and max aggregate kernels are inconsistent for floating point types.

Posted by GitBox <gi...@apache.org>.
alamb commented on issue #101:
URL: https://github.com/apache/arrow-rs/issues/101#issuecomment-1054619612


   I think so. Thank you @HaoYang670 
   
   Just to be sure, I tried the reproducer from the original ticket https://issues.apache.org/jira/browse/ARROW-9975
   
   ```rust
   use arrow::{
       datatypes::Float64Type,
       compute::kernels::aggregate::min,
       array::{
           PrimitiveBuilder
       }
   };
   
   pub fn main() {
       let mut builder_1 = PrimitiveBuilder::<Float64Type>::new(2);
       builder_1.append_value(1.0).unwrap();
       builder_1.append_value(f64::NAN).unwrap();
       let array_1 = builder_1.finish();
   
       let mut builder_2 = PrimitiveBuilder::<Float64Type>::new(2);
       builder_2.append_value(f64::NAN).unwrap();
       builder_2.append_value(1.0).unwrap();
       let array_2 = builder_2.finish();
   
       // expect both nan, or both 1.0
       assert_eq!(min(&array_1), min(&array_2));
       println!("done!");
   }
   ```
   
   And it prints out:
   ```shell
   -*- mode: compilation; default-directory: "~/Software/rust_arrow_playground/" -*-
   Compilation started at Mon Feb 28 15:09:19
   
   cd ~/Software/rust_arrow_playground/ && cargo run
      Compiling rust_arrow_playground v0.1.0 (/Users/alamb/Software/rust_arrow_playground)
       Finished dev [unoptimized + debuginfo] target(s) in 0.72s
        Running `target/debug/rust_arrow_playground`
   done!
   
   Compilation finished at Mon Feb 28 15:09:20
   
   ```
   
   cc @jorgecarleitao  and @ritchie46 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org