def METHOD_NAME(m, condition):
    """Halves all items in the diagonal of the given SciPy sparse matrix in
    coo mode *if* and *only if* the given condition is True.
    Returns the row, column and data arrays.
    """
    data_array = m.data
    if condition:
        # We can't do data_array[m.row == m.col] /= 2 here because we would be
        # modifying the array in-place and the end user wouldn't like if we
        # messed with their matrix. So we make a copy.
        data_array = data_array.copy()
        idxs, = (m.row == m.col).nonzero()
        for i in idxs:
            data_array[i] /= 2
    return m.row, m.col, data_array