Skip to content

[MRG] ENH Allow handling nan during input validation #8074

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

Closed
wants to merge 1 commit into from

Conversation

raghavrv
Copy link
Member

This PR is a tiny part refactored out of #5974 and #7892 to keep the other PRs concise and easy to review...

This adds support for allowing nan (one of the common placeholders for missing values) in the data matrix, X, while still filtering out inf as a part of input validation done by the check_array, check_all_finite helpers...

@tguillemot @jnothman @amueller @glouppe @agramfort Reviews please :)

def any_not_isfinite(X): return np.isinf(X).any()
np_sum = np.nansum
else:
def any_not_isfinite(X): return not np.isfinite(X).all()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jnothman I fixed your comment in this PR...

@@ -138,6 +138,11 @@ def test_check_array():
X_nan[0, 0] = np.nan
assert_raises(ValueError, check_array, X_nan)
check_array(X_inf, force_all_finite=False) # no raise
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tests for force_all_finite=False, allow_nan=False

@raghavrv
Copy link
Member Author

raghavrv commented Dec 18, 2016

Arghh sorry for the noise. I think #7892 itself is representative and small enough breaking down may make it non-functional unit...

@raghavrv raghavrv closed this Dec 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant