Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix boxArray getitem #151

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Base/BoxArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ void init_BoxArray(py::module &m) {
*/
.def("__getitem__",
[](const BoxArray& ba, const int i) {
const int ii = (i >= 0) ? i : AMREX_SPACEDIM + i;
if ((ii < 0) || (ii >= AMREX_SPACEDIM))
const int ii = (i >= 0) ? i : ba.size() + i;
if ((ii < 0) || (ii >= ba.size()))
throw py::index_error(
"Index must be between 0 and " +
std::to_string(AMREX_SPACEDIM));
std::to_string(ba.size()));
return ba[ii];
})

Expand Down
Loading