Skip to content

Commit

Permalink
[c++] Show which coordinate is out of range in fastercsx
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Jan 9, 2025
1 parent 824f648 commit 663c506
Showing 1 changed file with 19 additions and 9 deletions.
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(
"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]] {
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]] {
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

0 comments on commit 663c506

Please sign in to comment.