Skip to content

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

Description

@sevberg

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions