def vector_norm(data, axis=None, out=None):
data = numpy.array(data, dtype=numpy.float64, copy=True)<EOL>if out is None:<EOL><INDENT>if data.ndim == <NUM_LIT:1>:<EOL><INDENT>return math.sqrt(numpy.dot(data, data))<EOL><DEDENT>data *= data<EOL>out = numpy.atleast_1d(numpy.sum(data, axis=axis))<EOL>numpy.sqrt(out, out)<EOL>return out<EOL><DEDENT>else:<EOL><INDENT>data *= data<EOL>numpy.sum(data, axis=axis, out=out)<EOL>numpy.sqrt(out, out)<EOL><DEDENT>
Return length, i.e. Euclidean norm, of ndarray along axis.

    >>> v = numpy.random.random(3)
    >>> n = vector_norm(v)
    >>> numpy.allclose(n, numpy.linalg.norm(v))
    True
    >>> v = numpy.random.rand(6, 5, 3)
    >>> n = vector_norm(v, axis=-1)
    >>> numpy.allclose(n, numpy.sqrt(numpy.sum(v*v, axis=2)))
    True
    >>> n = vector_norm(v, axis=1)
    >>> numpy.allclose(n, numpy.sqrt(numpy.sum(v*v, axis=1)))
    True
    >>> v = numpy.random.rand(5, 4, 3)
    >>> n = numpy.empty((5, 3))
    >>> vector_norm(v, axis=1, out=n)
    >>> numpy.allclose(n, numpy.sqrt(numpy.sum(v*v, axis=1)))
    True
    >>> vector_norm([])
    0.0
    >>> vector_norm([1])
    1.0