Skip to content

Commit

Permalink
DNM Revert "Replace removed itemset method (#72)"
Browse files Browse the repository at this point in the history
This reverts commit f1213df.
  • Loading branch information
EricCousineau-TRI committed Jul 8, 2024
1 parent 4bf328e commit a9494d3
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions include/pybind11/eigen/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,6 @@ eigen_array_cast(typename props::Type const &src, handle base = handle(), bool w
{(size_t) src.size()},
nullptr,
empty_base);
auto _m_arr = a.mutable_unchecked<object, 1>();

constexpr bool is_row = props::fixed_rows && props::rows == 1;
for (ssize_t i = 0; i < src.size(); ++i) {
const Scalar src_val = is_row ? src(0, i) : src(i, 0);
Expand All @@ -293,25 +291,21 @@ eigen_array_cast(typename props::Type const &src, handle base = handle(), bool w
if (!value_) {
return handle();
}

_m_arr[i] = value_;
a.attr("itemset")(i, value_);
}
} else {
a = array(npy_format_descriptor<Scalar>::dtype(),
{(size_t) src.rows(), (size_t) src.cols()},
nullptr,
empty_base);
auto _m_arr = a.mutable_unchecked<object, 2>();

for (ssize_t i = 0; i < src.rows(); ++i) {
for (ssize_t j = 0; j < src.cols(); ++j) {
auto value_ = reinterpret_steal<object>(
make_caster<Scalar>::cast(src(i, j), policy, empty_base));
if (!value_) {
return handle();
}

_m_arr(i,j) = value_;
a.attr("itemset")(i, j, value_);
}
}
}
Expand Down

0 comments on commit a9494d3

Please sign in to comment.