#NEWLINE# def _asarray_validated( a , check_finite = True , sparse_ok = False , objects_ok = False , mask_ok = False , as_inexact = False ) : #NEWLINE# #INDENT# "\n    Helper function for scipy argument validation.\n\n    Many scipy linear algebra functions do support arbitrary array-like\n    input arguments.  Examples of commonly unsupported inputs include\n    matrices containing inf/nan, sparse matrix representations, and\n    matrices with complicated elements.\n\n    Parameters\n    ----------\n    a : array_like\n        The array-like input.\n    check_finite : bool, optional\n        Whether to check that the input matrices contain only finite numbers.\n        Disabling may give a performance gain, but may result in problems\n        (crashes, non-termination) if the inputs do contain infinities or NaNs.\n        Default: True\n    sparse_ok : bool, optional\n        True if scipy sparse matrices are allowed.\n    objects_ok : bool, optional\n        True if arrays with dype('O') are allowed.\n    mask_ok : bool, optional\n        True if masked arrays are allowed.\n    as_inexact : bool, optional\n        True to convert the input array to a np.inexact dtype.\n\n    Returns\n    -------\n    ret : ndarray\n        The converted validated array.\n\n    " #NEWLINE# if ( not sparse_ok ) : #NEWLINE# #INDENT# import scipy.sparse #NEWLINE# if scipy . sparse . issparse ( a ) : #NEWLINE# #INDENT# msg = 'Sparse matrices are not supported by this function. Perhaps one of the scipy.sparse.linalg functions would work instead.' #NEWLINE# raise ValueError ( msg ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not mask_ok ) : #NEWLINE# #INDENT# if np . ma . isMaskedArray ( a ) : #NEWLINE# #INDENT# raise ValueError ( 'masked arrays are not supported' ) #NEWLINE# #UNINDENT# #UNINDENT# toarray = ( np . asarray_chkfinite if check_finite else np . asarray ) #NEWLINE# a = toarray ( a ) #NEWLINE# if ( not objects_ok ) : #NEWLINE# #INDENT# if ( a . dtype is np . dtype ( 'O' ) ) : #NEWLINE# #INDENT# raise ValueError ( 'object arrays are not supported' ) #NEWLINE# #UNINDENT# #UNINDENT# if as_inexact : #NEWLINE# #INDENT# if ( not np . issubdtype ( a . dtype , np . inexact ) ) : #NEWLINE# #INDENT# a = toarray ( a , dtype = np . float_ ) #NEWLINE# #UNINDENT# #UNINDENT# return a