[docs]defget_matrix_type(mat:Union[np.ndarray,sp.spmatrix],non_zero:bool=False):"""Get an internal matrix state. Args: mat: An input numpy or scipy matrix. non_zero: Whether to filter zero value. Defaults to False. Raises: Exception: TypeNotSupported, when the matrix type is not supported. Returns: An internal matrix representation object. """ifisinstance(mat,np.ndarray):returnNops(mat,non_zero=non_zero)ifisinstance(mat,sp.spmatrix):returnSops(mat,non_zero=non_zero)# TODO: zarr, xarray, idk what else, pandas df/sparsedf ?raiseTypeError(f"mat is neither a numpy nor sparse matrix. provided {type(mat)}")