_ndarray_assoc(arr, k, v) duplicates arr to a writeable array, sets arr2[k]=v, returns arr2

def _ndarray_assoc(arr, k, v):
    '_ndarray_assoc(arr, k, v) duplicates arr to a writeable array, sets arr2[k]=v, returns arr2'
    arr = np.array(arr)
    arr[k] = v
    arr.setflags(write=False)
    return arr