def countnans(X, weights=None, axis=None, dtype=None, keepdims=False):
 if (not sp.issparse(X)):
  X = np.asanyarray(X)
  isnan = np.isnan(X)
  if ((weights is not None) and (weights.shape == X.shape)):
   isnan = (isnan * weights)
  counts = isnan.sum(axis=axis, dtype=dtype, keepdims=keepdims)
  if ((weights is not None) and (weights.shape != X.shape)):
   counts = (counts * weights)
 else:
  if (any(((attr is not None) for attr in [axis, dtype])) or (keepdims is not False)):
   raise ValueError('Arguments axis, dtype and keepdimsare not yet supported on sparse data!')
  counts = _count_nans_per_row_sparse(X, weights)
 return counts

def countnans ( X , weights = None , axis = None , dtype = None , keepdims = False ) : if ( not sp . issparse ( X ) ) : X = np . asanyarray ( X ) isnan = np . isnan ( X ) if ( ( weights is not None ) and ( weights . shape == X . shape ) ) : isnan = ( isnan * weights ) counts = isnan . sum ( axis = axis , dtype = dtype , keepdims = keepdims ) if ( ( weights is not None ) and ( weights . shape != X . shape ) ) : counts = ( counts * weights ) else : if ( any ( ( ( attr is not None ) for attr in [ axis , dtype ] ) ) or ( keepdims is not False ) ) : raise ValueError ( 'Arguments axis, dtype and keepdimsare not yet supported on sparse data!' ) counts = _count_nans_per_row_sparse ( X , weights ) return counts
count the undefined elements in arr along given axis .