def test_set_obsm_key(adata):
    init_hash = joblib.hash(adata)

    orig_obsm_val = adata.obsm["o"].copy()
    subset_obsm = adata[:50]
    assert subset_obsm.is_view
    subset_obsm.obsm["o"] = np.ones((50, 20))
    assert not subset_obsm.is_view
    assert np.all(adata.obsm["o"] == orig_obsm_val)

    assert init_hash == joblib.hash(adata)
def update_model(model, disc_grads, gen_grads, disc_opt, gen_opt,
                 global_step, update_scale):
  """Update model with gradients."""

  disc_vars, gen_vars = model.get_variables()

  with tf.control_dependencies(gen_grads + disc_grads):
    disc_update_op = disc_opt.apply_gradients(
        zip(_scale_vars(update_scale, disc_grads),
            disc_vars))

    gen_update_op = gen_opt.apply_gradients(
        zip(_scale_vars(update_scale, gen_grads),
            gen_vars),
        global_step=global_step)

    update_op = tf.group([disc_update_op, gen_update_op])

  return update_op