message: mask-based assignment
diff: @@ -484,6 +484,10 @@ py::class_<Array> bind(py::module &m, const char *name) {
  if constexpr (IsDynamic)
  cl.def("resize", [](Array &a, size_t size) { a.resize(size); });
  + cl.def("__setitem__", [](Array &a, const Mask &m, const Array &b) {
  + a[m] = b;
  + });
  +
  if constexpr (!IsDynamic || array_depth_v<Array> > 1) {
  cl.def("__setitem__", [](Array &a, size_t index, const Value &b) {
  if (index >= Array::Size)
  @@ -726,13 +730,12 @@ py::class_<Array> bind(py::module &m, const char *name) {
  }
  if constexpr (IsDiff) {
  - m.def("detach", [](const Array &a) { return eval(detach(a)); });
  - m.def("reattach", [](Array &a, Array &b) { reattach(a, b); });
  - }
  -
  - if constexpr (IsFloat && is_diff_array_v<Array>) {
  using Detached = decltype(eval(detach(std::declval<Array&>())));
  + m.def("detach", [](const Array &a) -> Detached { return detach(a); });
  +
  + if constexpr (IsFloat) {
  + m.def("reattach", [](Array &a, Array &b) { reattach(a, b); });
  m.def("requires_gradient",
  [](const Array &a) { return requires_gradient(a); },
  "array"_a);
  @@ -759,6 +762,7 @@ py::class_<Array> bind(py::module &m, const char *name) {
  "array"_a, "free_graph"_a = true);
  }
  }
  + }
  if constexpr (IsDiff) {
  using BaseType = expr_t<decltype(detach(std::declval<Array&>()))>;
  @@ -820,6 +824,9 @@ py::class_<Matrix> bind_matrix(py::module &m, const char *name) {
  throw py::index_error();
  a.coeff(index.second, index.first) = value;
  })
  + .def("__setitem__", [](Matrix &a, const mask_t<Value> &m, const Matrix &b) {
  + a[m] = b;
  + })
  .def_static("identity", [](size_t size) { return identity<Matrix>(size); }, "size"_a = 1)
  .def_static("zero", [](size_t size) { return zero<Matrix>(size); }, "size"_a = 1);
  