def asscalar(a):
try:<EOL><INDENT>return a.item()<EOL><DEDENT>except AttributeError:<EOL><INDENT>return np.asarray(a).item()<EOL><DEDENT>
Convert single-item lists and numpy arrays to scalars. Does
    not care about the type of the elements (i.e., will work fine on
    strings, etc.)

    https://github.com/numpy/numpy/issues/4701
    https://github.com/numpy/numpy/pull/5126