From fc4f3c7dd8756bfb0f33f6a5d74bcb116ae4fe24 Mon Sep 17 00:00:00 2001 From: Ralph Urlus Date: Thu, 13 Jun 2024 15:46:21 +0200 Subject: [PATCH] FIX: [C++] Remove usage of nb::raw_doc --- .../src/sp_matmul_bindings.cpp | 72 ++++---- .../src/sp_matmul_topn_bindings.cpp | 168 +++++++++--------- .../src/zip_sp_matmul_topn_bindings.cpp | 42 +++-- 3 files changed, 134 insertions(+), 148 deletions(-) diff --git a/src/sparse_dot_topn_core/src/sp_matmul_bindings.cpp b/src/sparse_dot_topn_core/src/sp_matmul_bindings.cpp index d4f08dd..565c5b3 100644 --- a/src/sparse_dot_topn_core/src/sp_matmul_bindings.cpp +++ b/src/sparse_dot_topn_core/src/sp_matmul_bindings.cpp @@ -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", @@ -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", diff --git a/src/sparse_dot_topn_core/src/sp_matmul_topn_bindings.cpp b/src/sparse_dot_topn_core/src/sp_matmul_topn_bindings.cpp index 6ac7b4d..40b5e79 100644 --- a/src/sparse_dot_topn_core/src/sp_matmul_topn_bindings.cpp +++ b/src/sparse_dot_topn_core/src/sp_matmul_topn_bindings.cpp @@ -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", @@ -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", @@ -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", @@ -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", diff --git a/src/sparse_dot_topn_core/src/zip_sp_matmul_topn_bindings.cpp b/src/sparse_dot_topn_core/src/zip_sp_matmul_topn_bindings.cpp index 5210dd3..6cfa387 100644 --- a/src/sparse_dot_topn_core/src/zip_sp_matmul_topn_bindings.cpp +++ b/src/sparse_dot_topn_core/src/zip_sp_matmul_topn_bindings.cpp @@ -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",