From 418149b7a47c1d8cb5749d043f540e3a87e140b1 Mon Sep 17 00:00:00 2001 From: Joel Koch Date: Tue, 19 Nov 2024 15:55:40 +0100 Subject: [PATCH] Apply credo feedback --- lib/sqlite_vec/ecto/bit.ex | 3 +++ lib/sqlite_vec/ecto/float32.ex | 3 +++ lib/sqlite_vec/ecto/int8.ex | 3 +++ lib/sqlite_vec/ecto/query.ex | 1 + test/sqlite_vec/bit_test.exs | 4 ++-- test/sqlite_vec/float32_test.exs | 4 ++-- 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/sqlite_vec/ecto/bit.ex b/lib/sqlite_vec/ecto/bit.ex index f9c9981..bb315b8 100644 --- a/lib/sqlite_vec/ecto/bit.ex +++ b/lib/sqlite_vec/ecto/bit.ex @@ -1,5 +1,8 @@ if Code.ensure_loaded?(Ecto) do defmodule SqliteVec.Ecto.Bit do + @moduledoc """ + `Ecto.Type` for `SqliteVec.Bit` + """ use Ecto.Type def type, do: :binary diff --git a/lib/sqlite_vec/ecto/float32.ex b/lib/sqlite_vec/ecto/float32.ex index 38658cd..adce104 100644 --- a/lib/sqlite_vec/ecto/float32.ex +++ b/lib/sqlite_vec/ecto/float32.ex @@ -1,5 +1,8 @@ if Code.ensure_loaded?(Ecto) do defmodule SqliteVec.Ecto.Float32 do + @moduledoc """ + `Ecto.Type` for `SqliteVec.Float32` + """ use Ecto.Type def type, do: :binary diff --git a/lib/sqlite_vec/ecto/int8.ex b/lib/sqlite_vec/ecto/int8.ex index 35fa042..4f4acf9 100644 --- a/lib/sqlite_vec/ecto/int8.ex +++ b/lib/sqlite_vec/ecto/int8.ex @@ -1,5 +1,8 @@ if Code.ensure_loaded?(Ecto) do defmodule SqliteVec.Ecto.Int8 do + @moduledoc """ + `Ecto.Type` for `SqliteVec.Int8` + """ use Ecto.Type def type, do: :binary diff --git a/lib/sqlite_vec/ecto/query.ex b/lib/sqlite_vec/ecto/query.ex index adc8cff..fedbe2c 100644 --- a/lib/sqlite_vec/ecto/query.ex +++ b/lib/sqlite_vec/ecto/query.ex @@ -40,6 +40,7 @@ if Code.ensure_loaded?(Ecto) do - a or b are bit vectors. Use vec_distance_hamming() for distance calculations between two bitvectors. - a or b do not have the same length. """ + # credo:disable-for-next-line Credo.Check.Readability.FunctionNames defmacro vec_distance_L2(a, b) do quote do fragment("vec_distance_L2(?, ?)", unquote(a), unquote(b)) diff --git a/test/sqlite_vec/bit_test.exs b/test/sqlite_vec/bit_test.exs index 239a388..66992a1 100644 --- a/test/sqlite_vec/bit_test.exs +++ b/test/sqlite_vec/bit_test.exs @@ -47,7 +47,7 @@ defmodule SqliteVec.Bit.Test do tensor end - |> StreamData.filter(&is_finite(&1)) + |> StreamData.filter(&finite?(&1)) end defp random_integer(type, shape, key) do @@ -66,7 +66,7 @@ defmodule SqliteVec.Bit.Test do Nx.Random.uniform(key, shape: shape, type: type) end - defp is_finite(tensor) do + defp finite?(tensor) do tensor |> Nx.is_infinity() |> Nx.any() |> Nx.to_number() == 0 end diff --git a/test/sqlite_vec/float32_test.exs b/test/sqlite_vec/float32_test.exs index 0c14076..205204d 100644 --- a/test/sqlite_vec/float32_test.exs +++ b/test/sqlite_vec/float32_test.exs @@ -26,10 +26,10 @@ defmodule SqliteVec.Float32.Test do tensor end - |> StreamData.filter(&is_finite(&1)) + |> StreamData.filter(&finite?(&1)) end - defp is_finite(tensor) do + defp finite?(tensor) do tensor |> Nx.is_infinity() |> Nx.any() |> Nx.to_number() == 0 end