.is_all_nan() returns true for an all-finite array

Open Beginner friendly
#1,612 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
rust
Domain
data

Research direction

Start by locating the implementation of the .is_all_nan() entry point and reproduce the behavior with the Rust example in the issue. Confirm the expected results for all-finite, mixed, and all-NaN arrays, then add or update coverage so the method returns true only for an all-NaN array.

Written by the indexing model from the issue text.

Description

It seems like calling .is_all_nan returns true when all values are NOT nan, and false otherwise. The below code reproduces the error for me

use ndarray::Array2;

fn main() {
    let mut arr_one = Array2::from_elem((10, 10), 1.0f32);
    assert!(arr_one.is_all_nan()); // Response it true, but should be false

    arr_one[(3, 3)] = f32::NAN;
    assert!(!arr_one.is_all_nan()); // Response is false, which is correct

    let arr_nan = Array2::from_elem((10, 10), f32::NAN);
    assert!(!arr_nan.is_all_nan()); // Response is false, but it should be true
}
Dominant language
Rust
Stars
4.3k
Forks
391
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-ndarray/ndarray

All issues in rust-ndarray/ndarray

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.