#NEWLINE# def apply( self , func ) : #NEWLINE# #INDENT# "\n        Apply function func element-wise on numpy.ndarray of non-zero values.\n        Using numpy or scipy functions are recommended.\n\n        Example:\n\n        sparsemat = scipy.sparse.coo_matrix(np.array([[1,2,3],[4,5,6],[7,8,9]]))\n        mat = Matrix(sparsemat, ['one', 'two', 'three'], ['four', 'five', 'six'])\n        mat.apply(np.log)\n                four                five                six\n        one     0.0                 0.6931471805599453  1.0986122886681098\n        two     1.3862943611198906  1.6094379124341003  1.791759469228055\n        three   1.9459101490553132  2.0794415416798357  2.1972245773362196\n\n        :param func: Function to apply.\n        :return: Matrix instance with applied function\n        " #NEWLINE# self . matrix . eliminate_zeros ( ) #NEWLINE# mat = self . matrix . tocoo ( ) #NEWLINE# mat . data = func ( mat . data ) #NEWLINE# return self . _new_instance ( mat )