def clear_info(info):
    """Clean up contents of info dictionary for better use.

    Keys to be removed are ``args``, ``kwargs`` and any non-scalar numpy or
    gnumpy arrays. Numpy scalars are converted to floats.

    Examples
    --------

    >>> import numpy as np
    >>> info = {'args': None, 'foo': np.zeros(3), 'bar': np.array(1),
    ...         'loss': 1.}
    >>> cleared = clear_info(info)
    >>> cleared == {'bar': 1.0, 'loss': 1.0}
    True
    """
    items = info.iteritems()
    items = ((k, float(v.reshape((1,))[0]) if is_array(v) and v.size == 1 else v)
             for k, v in items)
    items = ((k, v) for k, v in items if not is_array(v))
    items = ((k, v) for k, v in items if k not in ('args', 'kwargs'))

    return dict(items)
dataset/ETHPy150Open BRML/climin/climin/util.py/clear_info/original