def assert_all_finite(X):
 _assert_all_finite((X.data if sp.issparse(X) else X))

def assert_all_finite ( X ) : _assert_all_finite ( ( X . data if sp . issparse ( X ) else X ) )
throw a valueerror if x contains nan or infinity .