Skip to content

Commit

Permalink
FIX: [C++] Remove usage of nb::raw_doc
Browse files Browse the repository at this point in the history
  • Loading branch information
RUrlus committed Jun 13, 2024
1 parent 9ef5d92 commit fc4f3c7
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 148 deletions.
72 changes: 34 additions & 38 deletions src/sparse_dot_topn_core/src/sp_matmul_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,23 @@ void bind_sp_matmul(nb::module_& m) {
"B_data"_a.noconvert(),
"B_indptr"_a.noconvert(),
"B_indices"_a.noconvert(),
nb::raw_doc(
"Compute sparse dot product and keep top n.\n"
"\n"
"Args:\n"
" nrows (int): the number of rows in `A`\n"
" ncols (int): the number of columns in `B`\n"
" A_data (NDArray[int | float]): the non-zero elements of A\n"
" A_indptr (NDArray[int]): the row indices for `A_data`\n"
" A_indices (NDArray[int]): the column indices for `A_data`\n"
" B_data (NDArray[int | float]): the non-zero elements of B\n"
" B_indptr (NDArray[int]): the row indices for `B_data`\n"
" B_indices (NDArray[int]): the column indices for `B_data`\n"
"\n"
"Returns:\n"
" C_data (NDArray[int | float]): the non-zero elements of C\n"
" C_indptr (NDArray[int]): the row indices for `C_data`\n"
" C_indices (NDArray[int]): the column indices for `C_data`\n"
"\n"
)
("Compute sparse dot product and keep top n.\n"
"\n"
"Args:\n"
" nrows (int): the number of rows in `A`\n"
" ncols (int): the number of columns in `B`\n"
" A_data (NDArray[int | float]): the non-zero elements of A\n"
" A_indptr (NDArray[int]): the row indices for `A_data`\n"
" A_indices (NDArray[int]): the column indices for `A_data`\n"
" B_data (NDArray[int | float]): the non-zero elements of B\n"
" B_indptr (NDArray[int]): the row indices for `B_data`\n"
" B_indices (NDArray[int]): the column indices for `B_data`\n"
"\n"
"Returns:\n"
" C_data (NDArray[int | float]): the non-zero elements of C\n"
" C_indptr (NDArray[int]): the row indices for `C_data`\n"
" C_indices (NDArray[int]): the column indices for `C_data`\n"
"\n")
);
m.def(
"sp_matmul",
Expand Down Expand Up @@ -156,25 +154,23 @@ void bind_sp_matmul_mt(nb::module_& m) {
"B_data"_a.noconvert(),
"B_indptr"_a.noconvert(),
"B_indices"_a.noconvert(),
nb::raw_doc(
"Compute sparse dot product and keep top n.\n"
"\n"
"Args:\n"
" nrows (int): the number of rows in `A`\n"
" ncols (int): the number of columns in `B`\n"
" A_data (NDArray[int | float]): the non-zero elements of A\n"
" A_indptr (NDArray[int]): the row indices for `A_data`\n"
" A_indices (NDArray[int]): the column indices for `A_data`\n"
" B_data (NDArray[int | float]): the non-zero elements of B\n"
" B_indptr (NDArray[int]): the row indices for `B_data`\n"
" B_indices (NDArray[int]): the column indices for `B_data`\n"
"\n"
"Returns:\n"
" C_data (NDArray[int | float]): the non-zero elements of C\n"
" C_indptr (NDArray[int]): the row indices for `C_data`\n"
" C_indices (NDArray[int]): the column indices for `C_data`\n"
"\n"
)
("Compute sparse dot product and keep top n.\n"
"\n"
"Args:\n"
" nrows (int): the number of rows in `A`\n"
" ncols (int): the number of columns in `B`\n"
" A_data (NDArray[int | float]): the non-zero elements of A\n"
" A_indptr (NDArray[int]): the row indices for `A_data`\n"
" A_indices (NDArray[int]): the column indices for `A_data`\n"
" B_data (NDArray[int | float]): the non-zero elements of B\n"
" B_indptr (NDArray[int]): the row indices for `B_data`\n"
" B_indices (NDArray[int]): the column indices for `B_data`\n"
"\n"
"Returns:\n"
" C_data (NDArray[int | float]): the non-zero elements of C\n"
" C_indptr (NDArray[int]): the row indices for `C_data`\n"
" C_indices (NDArray[int]): the column indices for `C_data`\n"
"\n")
);
m.def(
"sp_matmul_mt",
Expand Down
168 changes: 80 additions & 88 deletions src/sparse_dot_topn_core/src/sp_matmul_topn_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,27 @@ void bind_sp_matmul_topn(nb::module_& m) {
"B_data"_a.noconvert(),
"B_indptr"_a.noconvert(),
"B_indices"_a.noconvert(),
nb::raw_doc(
"Compute sparse dot product and keep top n.\n"
"\n"
"Args:\n"
" top_n (int): the number of results to retain\n"
" nrows (int): the number of rows in `A`\n"
" ncols (int): the number of columns in `B`\n"
" density (float): the expected density of the result"
" considering `top_n`\n"
" threshold (float): only store values greater than\n"
" A_data (NDArray[int | float]): the non-zero elements of A\n"
" A_indptr (NDArray[int]): the row indices for `A_data`\n"
" A_indices (NDArray[int]): the column indices for `A_data`\n"
" B_data (NDArray[int | float]): the non-zero elements of B\n"
" B_indptr (NDArray[int]): the row indices for `B_data`\n"
" B_indices (NDArray[int]): the column indices for `B_data`\n"
"\n"
"Returns:\n"
" C_data (NDArray[int | float]): the non-zero elements of C\n"
" C_indptr (NDArray[int]): the row indices for `C_data`\n"
" C_indices (NDArray[int]): the column indices for `C_data`\n"
"\n"
)
("Compute sparse dot product and keep top n.\n"
"\n"
"Args:\n"
" top_n (int): the number of results to retain\n"
" nrows (int): the number of rows in `A`\n"
" ncols (int): the number of columns in `B`\n"
" density (float): the expected density of the result"
" considering `top_n`\n"
" threshold (float): only store values greater than\n"
" A_data (NDArray[int | float]): the non-zero elements of A\n"
" A_indptr (NDArray[int]): the row indices for `A_data`\n"
" A_indices (NDArray[int]): the column indices for `A_data`\n"
" B_data (NDArray[int | float]): the non-zero elements of B\n"
" B_indptr (NDArray[int]): the row indices for `B_data`\n"
" B_indices (NDArray[int]): the column indices for `B_data`\n"
"\n"
"Returns:\n"
" C_data (NDArray[int | float]): the non-zero elements of C\n"
" C_indptr (NDArray[int]): the row indices for `C_data`\n"
" C_indices (NDArray[int]): the column indices for `C_data`\n"
"\n")
);
m.def(
"sp_matmul_topn",
Expand Down Expand Up @@ -185,29 +183,27 @@ void bind_sp_matmul_topn_sorted(nb::module_& m) {
"B_data"_a.noconvert(),
"B_indptr"_a.noconvert(),
"B_indices"_a.noconvert(),
nb::raw_doc(
"Compute sparse dot product and keep top n.\n"
"\n"
"Args:\n"
" top_n (int): the number of results to retain\n"
" nrows (int): the number of rows in `A`\n"
" ncols (int): the number of columns in `B`\n"
" threshold (float): only store values greater than\n"
" density (float): the expected density of the result"
" considering `top_n`\n"
" A_data (NDArray[int | float]): the non-zero elements of A\n"
" A_indptr (NDArray[int]): the row indices for `A_data`\n"
" A_indices (NDArray[int]): the column indices for `A_data`\n"
" B_data (NDArray[int | float]): the non-zero elements of B\n"
" B_indptr (NDArray[int]): the row indices for `B_data`\n"
" B_indices (NDArray[int]): the column indices for `B_data`\n"
"\n"
"Returns:\n"
" C_data (NDArray[int | float]): the non-zero elements of C\n"
" C_indptr (NDArray[int]): the row indices for `C_data`\n"
" C_indices (NDArray[int]): the column indices for `C_data`\n"
"\n"
)
("Compute sparse dot product and keep top n.\n"
"\n"
"Args:\n"
" top_n (int): the number of results to retain\n"
" nrows (int): the number of rows in `A`\n"
" ncols (int): the number of columns in `B`\n"
" threshold (float): only store values greater than\n"
" density (float): the expected density of the result"
" considering `top_n`\n"
" A_data (NDArray[int | float]): the non-zero elements of A\n"
" A_indptr (NDArray[int]): the row indices for `A_data`\n"
" A_indices (NDArray[int]): the column indices for `A_data`\n"
" B_data (NDArray[int | float]): the non-zero elements of B\n"
" B_indptr (NDArray[int]): the row indices for `B_data`\n"
" B_indices (NDArray[int]): the column indices for `B_data`\n"
"\n"
"Returns:\n"
" C_data (NDArray[int | float]): the non-zero elements of C\n"
" C_indptr (NDArray[int]): the row indices for `C_data`\n"
" C_indices (NDArray[int]): the column indices for `C_data`\n"
"\n")
);
m.def(
"sp_matmul_topn_sorted",
Expand Down Expand Up @@ -332,27 +328,25 @@ void bind_sp_matmul_topn_mt(nb::module_& m) {
"B_data"_a.noconvert(),
"B_indptr"_a.noconvert(),
"B_indices"_a.noconvert(),
nb::raw_doc(
"Compute sparse dot product and keep top n.\n"
"\n"
"Args:\n"
" top_n (int): the number of results to retain\n"
" nrows (int): the number of rows in `A`\n"
" ncols (int): the number of columns in `B`\n"
" threshold (float): only store values greater than\n"
" A_data (NDArray[int | float]): the non-zero elements of A\n"
" A_indptr (NDArray[int]): the row indices for `A_data`\n"
" A_indices (NDArray[int]): the column indices for `A_data`\n"
" B_data (NDArray[int | float]): the non-zero elements of B\n"
" B_indptr (NDArray[int]): the row indices for `B_data`\n"
" B_indices (NDArray[int]): the column indices for `B_data`\n"
"\n"
"Returns:\n"
" C_data (NDArray[int | float]): the non-zero elements of C\n"
" C_indptr (NDArray[int]): the row indices for `C_data`\n"
" C_indices (NDArray[int]): the column indices for `C_data`\n"
"\n"
)
("Compute sparse dot product and keep top n.\n"
"\n"
"Args:\n"
" top_n (int): the number of results to retain\n"
" nrows (int): the number of rows in `A`\n"
" ncols (int): the number of columns in `B`\n"
" threshold (float): only store values greater than\n"
" A_data (NDArray[int | float]): the non-zero elements of A\n"
" A_indptr (NDArray[int]): the row indices for `A_data`\n"
" A_indices (NDArray[int]): the column indices for `A_data`\n"
" B_data (NDArray[int | float]): the non-zero elements of B\n"
" B_indptr (NDArray[int]): the row indices for `B_data`\n"
" B_indices (NDArray[int]): the column indices for `B_data`\n"
"\n"
"Returns:\n"
" C_data (NDArray[int | float]): the non-zero elements of C\n"
" C_indptr (NDArray[int]): the row indices for `C_data`\n"
" C_indices (NDArray[int]): the column indices for `C_data`\n"
"\n")
);
m.def(
"sp_matmul_topn_mt",
Expand Down Expand Up @@ -476,27 +470,25 @@ void bind_sp_matmul_topn_sorted_mt(nb::module_& m) {
"B_data"_a.noconvert(),
"B_indptr"_a.noconvert(),
"B_indices"_a.noconvert(),
nb::raw_doc(
"Compute sparse dot product and keep top n.\n"
"\n"
"Args:\n"
" top_n (int): the number of results to retain\n"
" nrows (int): the number of rows in `A`\n"
" ncols (int): the number of columns in `B`\n"
" threshold (float): only store values greater than\n"
" A_data (NDArray[int | float]): the non-zero elements of A\n"
" A_indptr (NDArray[int]): the row indices for `A_data`\n"
" A_indices (NDArray[int]): the column indices for `A_data`\n"
" B_data (NDArray[int | float]): the non-zero elements of B\n"
" B_indptr (NDArray[int]): the row indices for `B_data`\n"
" B_indices (NDArray[int]): the column indices for `B_data`\n"
"\n"
"Returns:\n"
" C_data (NDArray[int | float]): the non-zero elements of C\n"
" C_indptr (NDArray[int]): the row indices for `C_data`\n"
" C_indices (NDArray[int]): the column indices for `C_data`\n"
"\n"
)
("Compute sparse dot product and keep top n.\n"
"\n"
"Args:\n"
" top_n (int): the number of results to retain\n"
" nrows (int): the number of rows in `A`\n"
" ncols (int): the number of columns in `B`\n"
" threshold (float): only store values greater than\n"
" A_data (NDArray[int | float]): the non-zero elements of A\n"
" A_indptr (NDArray[int]): the row indices for `A_data`\n"
" A_indices (NDArray[int]): the column indices for `A_data`\n"
" B_data (NDArray[int | float]): the non-zero elements of B\n"
" B_indptr (NDArray[int]): the row indices for `B_data`\n"
" B_indices (NDArray[int]): the column indices for `B_data`\n"
"\n"
"Returns:\n"
" C_data (NDArray[int | float]): the non-zero elements of C\n"
" C_indptr (NDArray[int]): the row indices for `C_data`\n"
" C_indices (NDArray[int]): the column indices for `C_data`\n"
"\n")
);
m.def(
"sp_matmul_topn_sorted_mt",
Expand Down
42 changes: 20 additions & 22 deletions src/sparse_dot_topn_core/src/zip_sp_matmul_topn_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,26 @@ void bind_zip_sp_matmul_topn(nb::module_& m) {
"data"_a.noconvert(),
"indptr"_a.noconvert(),
"indices"_a.noconvert(),
nb::raw_doc(
"Compute sparse dot product and keep top n.\n"
"\n"
"Args:\n"
" top_n (int): the number of results to retain\n"
" Z_max_nnz (int): the maximum number of non-zero values in Z\n"
" nrows (int): the number of rows in `A`\n"
" B_ncols (NDArray[int]): the number of columns in each block "
"of `B`\n"
" data (list[NDArray[int | float]]): the non-zero elements of "
"each C\n"
" indptr (list[NDArray[int]]): the row indices for each "
"`C_data`\n"
" indices (list[NDArray[int]]): the column indices for each "
"`C_data`\n"
"\n"
"Returns:\n"
" Z_data (NDArray[int | float]): the non-zero elements of Z\n"
" Z_indptr (NDArray[int]): the row indices for `Z_data`\n"
" Z_indices (NDArray[int]): the column indices for `Z_data`\n"
"\n"
)
("Compute sparse dot product and keep top n.\n"
"\n"
"Args:\n"
" top_n (int): the number of results to retain\n"
" Z_max_nnz (int): the maximum number of non-zero values in Z\n"
" nrows (int): the number of rows in `A`\n"
" B_ncols (NDArray[int]): the number of columns in each block "
"of `B`\n"
" data (list[NDArray[int | float]]): the non-zero elements of "
"each C\n"
" indptr (list[NDArray[int]]): the row indices for each "
"`C_data`\n"
" indices (list[NDArray[int]]): the column indices for each "
"`C_data`\n"
"\n"
"Returns:\n"
" Z_data (NDArray[int | float]): the non-zero elements of Z\n"
" Z_indptr (NDArray[int]): the row indices for `Z_data`\n"
" Z_indices (NDArray[int]): the column indices for `Z_data`\n"
"\n")
);
m.def(
"zip_sp_matmul_topn",
Expand Down

0 comments on commit fc4f3c7

Please sign in to comment.