#NEWLINE# def mean( self , axis = None ) : #NEWLINE# #INDENT# '\n        Average the matrix over the given axis. If the axis is None,\n        average over both rows and columns, returning a scalar.\n        :param axis: 0, 1, or None\n        :return: Matrix instance or double, if axis is None\n        ' #NEWLINE# if ( axis is None ) : #NEWLINE# #INDENT# return self . matrix . mean ( axis ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( axis == 0 ) : #NEWLINE# #INDENT# return self . _new_instance ( self . matrix . mean ( axis ) , row2word = [ '' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( axis == 1 ) : #NEWLINE# #INDENT# return self . _new_instance ( self . matrix . mean ( axis ) , col2word = [ '' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'Axis can only be None, 1, or 0' )