#NEWLINE# def tvar( a , limits = None , inclusive = ( True , True ) , axis = 0 , ddof = 1 ) : #NEWLINE# #INDENT# '\n    Compute the trimmed variance\n\n    This function computes the sample variance of an array of values,\n    while ignoring values which are outside of given `limits`.\n\n    Parameters\n    ----------\n    a : array_like\n        Array of values.\n    limits : None or (lower limit, upper limit), optional\n        Values in the input array less than the lower limit or greater than the\n        upper limit will be ignored. When limits is None, then all values are\n        used. Either of the limit values in the tuple can also be None\n        representing a half-open interval.  The default value is None.\n    inclusive : (bool, bool), optional\n        A tuple consisting of the (lower flag, upper flag).  These flags\n        determine whether values exactly equal to the lower or upper limits\n        are included.  The default value is (True, True).\n    axis : int or None, optional\n        Axis along which to operate. If None, compute over the\n        whole array. Default is zero.\n    ddof : int, optional\n        Delta degrees of freedom. Default is 1.\n\n    Returns\n    -------\n    tvar : float\n        Trimmed variance.\n\n    Notes\n    -----\n    For more details on `tvar`, see `stats.tvar`.\n\n    ' #NEWLINE# a = a . astype ( float ) . ravel ( ) #NEWLINE# if ( limits is None ) : #NEWLINE# #INDENT# n = ( ~ a . mask ) . sum ( ) #NEWLINE# return ( ( np . ma . var ( a ) * n ) / ( n - 1.0 ) ) #NEWLINE# #UNINDENT# am = _mask_to_limits ( a , limits = limits , inclusive = inclusive ) #NEWLINE# return np . ma . var ( am , axis = axis , ddof = ddof )