def hmean(a, axis=<NUM_LIT:0>, dtype=None):
if not isinstance(a, np.ndarray):<EOL><INDENT>a = np.array(a, dtype=dtype)<EOL><DEDENT>if np.all(a > <NUM_LIT:0>):  <EOL><INDENT>if isinstance(a, np.ma.MaskedArray):<EOL><INDENT>size = a.count(axis)<EOL><DEDENT>else:<EOL><INDENT>if axis is None:<EOL><INDENT>a = a.ravel()<EOL>size = a.shape[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>size = a.shape[axis]<EOL><DEDENT><DEDENT>return size / np.sum(<NUM_LIT:1.0>/a, axis=axis, dtype=dtype)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>
Calculates the harmonic mean along the specified axis.

That is:  n / (1/x1 + 1/x2 + ... + 1/xn)

Parameters
----------
a : array_like
    Input array, masked array or object that can be converted to an array.
axis : int, optional, default axis=0
    Axis along which the harmonic mean is computed.
dtype : dtype, optional
    Type of the returned array and of the accumulator in which the
    elements are summed. If `dtype` is not specified, it defaults to the
    dtype of `a`, unless `a` has an integer `dtype` with a precision less
    than that of the default platform integer. In that case, the default
    platform integer is used.

Returns
-------
hmean : ndarray
    see `dtype` parameter above

See Also
--------
numpy.mean : Arithmetic average
numpy.average : Weighted average
gmean : Geometric mean

Notes
-----
The harmonic mean is computed over a single dimension of the input
array, axis=0 by default, or all values in the array if axis=None.
float64 intermediate and return values are used for integer inputs.

Use masked arrays to ignore any non-finite values in the input or that
arise in the calculations such as Not a Number and infinity.