def _asarray_validated(a, check_finite=True, sparse_ok=False, objects_ok=False, mask_ok=False, as_inexact=False):
 if (not sparse_ok):
  import scipy.sparse
  if scipy.sparse.issparse(a):
   msg = 'Sparse matrices are not supported by this function. Perhaps one of the scipy.sparse.linalg functions would work instead.'
   raise ValueError(msg)
 if (not mask_ok):
  if np.ma.isMaskedArray(a):
   raise ValueError('masked arrays are not supported')
 toarray = (np.asarray_chkfinite if check_finite else np.asarray)
 a = toarray(a)
 if (not objects_ok):
  if (a.dtype is np.dtype('O')):
   raise ValueError('object arrays are not supported')
 if as_inexact:
  if (not np.issubdtype(a.dtype, np.inexact)):
   a = toarray(a, dtype=np.float_)
 return a

def _asarray_validated ( a , check_finite = True , sparse_ok = False , objects_ok = False , mask_ok = False , as_inexact = False ) : if ( not sparse_ok ) : import scipy . sparse if scipy . sparse . issparse ( a ) : msg = 'Sparse matrices are not supported by this function. Perhaps one of the scipy.sparse.linalg functions would work instead.' raise ValueError ( msg ) if ( not mask_ok ) : if np . ma . isMaskedArray ( a ) : raise ValueError ( 'masked arrays are not supported' ) toarray = ( np . asarray_chkfinite if check_finite else np . asarray ) a = toarray ( a ) if ( not objects_ok ) : if ( a . dtype is np . dtype ( 'O' ) ) : raise ValueError ( 'object arrays are not supported' ) if as_inexact : if ( not np . issubdtype ( a . dtype , np . inexact ) ) : a = toarray ( a , dtype = np . float_ ) return a
helper function for scipy argument validation .