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

Fix typespecs #20

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 5 additions & 4 deletions lib/hnswlib_bfindex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ defmodule HNSWLib.BFIndex do
"""
@spec knn_query(%T{}, Nx.Tensor.t() | binary() | [binary()], [
{:k, pos_integer()}
]) :: :ok | {:error, String.t()}
]) :: {:ok, Nx.Tensor.t(), Nx.Tensor.t()} | {:error, String.t()}
def knn_query(self, query, opts \\ [])

def knn_query(self = %T{}, query, opts) when is_binary(query) do
Expand Down Expand Up @@ -148,8 +148,9 @@ defmodule HNSWLib.BFIndex do
@doc """
Get the current number of threads to use in the index.
"""
@spec set_num_threads(%T{}, pos_integer()) :: {:ok, integer()} | {:error, String.t()}
def set_num_threads(self = %T{}, num_threads) when is_integer(num_threads) and num_threads > 0 do
@spec set_num_threads(%T{}, pos_integer()) :: :ok | {:error, String.t()}
def set_num_threads(self = %T{}, num_threads)
when is_integer(num_threads) and num_threads > 0 do
HNSWLib.Nif.bfindex_set_num_threads(self.reference, num_threads)
end

Expand All @@ -162,7 +163,7 @@ defmodule HNSWLib.BFIndex do

Path to save the index to.
"""
@spec save_index(%T{}, Path.t()) :: {:ok, integer()} | {:error, String.t()}
@spec save_index(%T{}, Path.t()) :: :ok | {:error, String.t()}
def save_index(self = %T{}, path) when is_binary(path) do
HNSWLib.Nif.bfindex_save_index(self.reference, path)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/hnswlib_index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ defmodule HNSWLib.Index do
@doc """
Set the number of threads to use.
"""
@spec set_num_threads(%T{}, integer()) :: {:ok, integer()} | {:error, String.t()}
@spec set_num_threads(%T{}, integer()) :: :ok | {:error, String.t()}
def set_num_threads(self = %T{}, new_num_threads) do
HNSWLib.Nif.index_set_num_threads(self.reference, new_num_threads)
end
Expand All @@ -210,7 +210,7 @@ defmodule HNSWLib.Index do

Path to save the index to.
"""
@spec save_index(%T{}, Path.t()) :: :ok
@spec save_index(%T{}, Path.t()) :: :ok | {:error, String.t()}
def save_index(self = %T{}, path) when is_binary(path) do
HNSWLib.Nif.index_save_index(self.reference, path)
end
Expand Down
Loading