diff --git a/include/pybind11/eigen/matrix.h b/include/pybind11/eigen/matrix.h index 5cf1f0a2a0..a62c542d51 100644 --- a/include/pybind11/eigen/matrix.h +++ b/include/pybind11/eigen/matrix.h @@ -317,7 +317,7 @@ struct type_caster::value>> { } // Allocate the new type, then build a numpy reference into it - value = Type(fits.rows, fits.cols); + value.resize(fits.rows, fits.cols); auto ref = reinterpret_steal(eigen_ref_array(value)); if (dims == 1) { ref = ref.squeeze();