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

[c++] Show which coordinate is out of range in fastercsx error messages #3539

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Changes from 1 commit
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
28 changes: 19 additions & 9 deletions libtiledbsoma/src/utils/fastercsx.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,13 @@ void count_rows_(
auto row = Ai_view[n];
if ((row < 0) ||
(static_cast<std::make_unsigned_t<COO_IDX>>(row) >=
n_row)) [[unlikely]]
throw std::out_of_range("Coordinate out of range.");
n_row)) [[unlikely]] {
throw std::out_of_range(std::format(
johnkerl marked this conversation as resolved.
Show resolved Hide resolved
"Coordinate {} out of range {}.",
row,
0,
n_row));
}
counts[row]++;
}
}
Expand All @@ -221,8 +226,10 @@ void count_rows_(
auto row = Ai_view[n];
if ((row < 0) ||
(static_cast<std::make_unsigned_t<COO_IDX>>(row) >= n_row))
[[unlikely]]
throw std::out_of_range("Coordinate out of range.");
[[unlikely]] {
johnkerl marked this conversation as resolved.
Show resolved Hide resolved
throw std::out_of_range(std::format(
"Coordinate {} out of range {}.", row, 0, n_row));
}
Bp[row]++;
}
}
Expand Down Expand Up @@ -268,9 +275,10 @@ void compress_coo_inner_left_(
const auto dest = Bp[row];
if ((Aj_[n] < 0) ||
(static_cast<std::make_unsigned_t<COO_IDX>>(Aj_[n]) >= n_col))
[[unlikely]]
throw std::out_of_range("Coordinate out of range.");

[[unlikely]] {
johnkerl marked this conversation as resolved.
Show resolved Hide resolved
throw std::out_of_range(std::format(
"Coordinate {} out of range {}.", Aj_[n], 0, n_col));
}
Bj[dest] = Aj_[n];
Bd[dest] = Ad_[n];
Bp[row]++;
Expand Down Expand Up @@ -302,8 +310,10 @@ void compress_coo_inner_right_(
const auto dest = Bp[row];
if ((Aj_[n] < 0) ||
(static_cast<std::make_unsigned_t<COO_IDX>>(Aj_[n]) >= n_col))
[[unlikely]]
throw std::out_of_range("Coordinate out of range.");
[[unlikely]] {
throw std::out_of_range(std::format(
"Coordinate {} out of range {}.", Aj_[n], 0, n_col));
}

Bj[dest] = Aj_[n];
Bd[dest] = Ad_[n];
Expand Down
Loading