def test_modify_view_component(matrix_type, mapping_name):
    adata = ad.AnnData(
        np.zeros((10, 10)),
        **{mapping_name: dict(m=matrix_type(asarray(sparse.random(10, 10))))},
    )
    init_hash = joblib.hash(adata)

    subset = adata[:5, :][:, :5]
    assert subset.is_view
    m = getattr(subset, mapping_name)["m"]
    m[0, 0] = 100
    assert not subset.is_view
    assert getattr(subset, mapping_name)["m"][0, 0] == 100

    assert init_hash == joblib.hash(adata)
def image_thumbnail(filename):
    filepath = os.path.join(app.config.get('UPLOAD_FOLDER'), filename)
    im = Image.open(filepath)
    w, h = im.size

    if w > h:
        im.thumbnail((106, 106*h/w))
    else:
        im.thumbnail((106*w/h, 106))

    im.save(os.path.join(app.config.get('UPLOAD_FOLDER'), 
        os.path.splitext(filename)[0] + '_thumbnail' + os.path.splitext(filename)[1]))