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

Incorrect passing of vectors that contain NA #392

Closed
vtraag opened this issue May 20, 2020 · 2 comments
Closed

Incorrect passing of vectors that contain NA #392

vtraag opened this issue May 20, 2020 · 2 comments

Comments

@vtraag
Copy link
Member

vtraag commented May 20, 2020

Vectors that contain an NA value are incorrectly passed to the C library. This appears in several places in types-R.def. The incorrect code is

if (!is.null(%I%) && any(!is.na(%I%))) { \
%I% <- as.numeric(%I%) \
} else { \
%I% <- NULL \
}

This means that the vector will be passed if there is at least one element that is not NA. What is intended is that the vector should be passed if not any element is NA, instead of any element not NA. In other words, this should be

if (!is.null(%I%) && !any(is.na(%I%))) { \
    %I% <- as.numeric(%I%) \
} else { \
    %I% <- NULL \
}
@szhorvat
Copy link
Member

Can this be closed @vtraag ?

@vtraag
Copy link
Member Author

vtraag commented Jan 19, 2022

Yes, indeed the original code was correct and NaNs should be correctly handled in the C core, as is further discussed in igraph/igraph#1560.

@vtraag vtraag closed this as completed Jan 19, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants