From 663c5066b21226215b729f0e32e6e2d7f97fc24d Mon Sep 17 00:00:00 2001 From: John Kerl Date: Thu, 9 Jan 2025 15:13:48 -0500 Subject: [PATCH 1/3] [c++] Show which coordinate is out of range in `fastercsx` --- libtiledbsoma/src/utils/fastercsx.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/libtiledbsoma/src/utils/fastercsx.h b/libtiledbsoma/src/utils/fastercsx.h index ba42bf8ba8..a79547043b 100644 --- a/libtiledbsoma/src/utils/fastercsx.h +++ b/libtiledbsoma/src/utils/fastercsx.h @@ -198,8 +198,13 @@ void count_rows_( auto row = Ai_view[n]; if ((row < 0) || (static_cast>(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]++; } } @@ -221,8 +226,10 @@ void count_rows_( auto row = Ai_view[n]; if ((row < 0) || (static_cast>(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]++; } } @@ -268,9 +275,10 @@ void compress_coo_inner_left_( const auto dest = Bp[row]; if ((Aj_[n] < 0) || (static_cast>(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]++; @@ -302,8 +310,10 @@ void compress_coo_inner_right_( const auto dest = Bp[row]; if ((Aj_[n] < 0) || (static_cast>(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]; From 0bcf02b9dc634fce9ad8a847fd8d3f61687d2dfa Mon Sep 17 00:00:00 2001 From: John Kerl Date: Thu, 9 Jan 2025 15:29:00 -0500 Subject: [PATCH 2/3] code-review feedback --- libtiledbsoma/src/utils/fastercsx.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libtiledbsoma/src/utils/fastercsx.h b/libtiledbsoma/src/utils/fastercsx.h index a79547043b..f519cd1567 100644 --- a/libtiledbsoma/src/utils/fastercsx.h +++ b/libtiledbsoma/src/utils/fastercsx.h @@ -200,7 +200,7 @@ void count_rows_( (static_cast>(row) >= n_row)) [[unlikely]] { throw std::out_of_range(std::format( - "Coordinate {} out of range {}.", + "First coordinate {} out of range {}.", row, 0, n_row)); @@ -228,7 +228,7 @@ void count_rows_( (static_cast>(row) >= n_row)) [[unlikely]] { throw std::out_of_range(std::format( - "Coordinate {} out of range {}.", row, 0, n_row)); + "First coordinate {} out of range {}.", row, 0, n_row)); } Bp[row]++; } @@ -277,7 +277,7 @@ void compress_coo_inner_left_( (static_cast>(Aj_[n]) >= n_col)) [[unlikely]] { throw std::out_of_range(std::format( - "Coordinate {} out of range {}.", Aj_[n], 0, n_col)); + "Second coordinate {} out of range {}.", Aj_[n], 0, n_col)); } Bj[dest] = Aj_[n]; Bd[dest] = Ad_[n]; @@ -312,7 +312,7 @@ void compress_coo_inner_right_( (static_cast>(Aj_[n]) >= n_col)) [[unlikely]] { throw std::out_of_range(std::format( - "Coordinate {} out of range {}.", Aj_[n], 0, n_col)); + "Second coordinate {} out of range {}.", Aj_[n], 0, n_col)); } Bj[dest] = Aj_[n]; From 1d3377377087e4a2f2fb19286ca1b75fdeeae5f7 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Thu, 9 Jan 2025 15:32:03 -0500 Subject: [PATCH 3/3] more --- libtiledbsoma/src/utils/fastercsx.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libtiledbsoma/src/utils/fastercsx.h b/libtiledbsoma/src/utils/fastercsx.h index f519cd1567..50b9e3cce8 100644 --- a/libtiledbsoma/src/utils/fastercsx.h +++ b/libtiledbsoma/src/utils/fastercsx.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include