Skip to content

Commit

Permalink
Apply credo feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
joelpaulkoch committed Nov 19, 2024
1 parent 6287b65 commit 418149b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lib/sqlite_vec/ecto/bit.ex
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/sqlite_vec/ecto/float32.ex
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/sqlite_vec/ecto/int8.ex
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/sqlite_vec/ecto/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions test/sqlite_vec/bit_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions test/sqlite_vec/float32_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 418149b

Please sign in to comment.