Skip to content

Commit

Permalink
added '?' sign to assume_centered option
Browse files Browse the repository at this point in the history
  • Loading branch information
norm4nn committed Nov 8, 2024
1 parent 7e4378b commit df80bc3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/scholar/covariance/ledoit_wolf.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defmodule Scholar.Covariance.LedoitWolf do
defstruct [:covariance, :shrinkage, :location]

opts_schema = [
assume_centered: [
assume_centered?: [
default: false,
type: :boolean,
doc: """
Expand Down Expand Up @@ -93,7 +93,7 @@ defmodule Scholar.Covariance.LedoitWolf do
iex> key = Nx.Random.key(0)
iex> {x, _new_key} = Nx.Random.multivariate_normal(key, Nx.tensor([0.0, 0.0, 0.0]), Nx.tensor([[3.0, 2.0, 1.0], [1.0, 2.0, 3.0], [1.3, 1.0, 2.2]]), shape: {10}, type: :f32)
iex> cov = Scholar.Covariance.LedoitWolf.fit(x, assume_centered: true)
iex> cov = Scholar.Covariance.LedoitWolf.fit(x, assume_centered?: true)
iex> cov.covariance
#Nx.Tensor<
f32[3][3]
Expand All @@ -110,7 +110,7 @@ defmodule Scholar.Covariance.LedoitWolf do
end

defnp fit_n(x, opts) do
{x, location} = Scholar.Covariance.Utils.center(x, opts[:assume_centered])
{x, location} = Scholar.Covariance.Utils.center(x, opts[:assume_centered?])

{covariance, shrinkage} =
ledoit_wolf(x)
Expand Down
4 changes: 2 additions & 2 deletions lib/scholar/covariance/shrunk_covariance.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Scholar.Covariance.ShrunkCovariance do
defstruct [:covariance, :location]

opts_schema = [
assume_centered: [
assume_centered?: [
default: false,
type: :boolean,
doc: """
Expand Down Expand Up @@ -94,7 +94,7 @@ defmodule Scholar.Covariance.ShrunkCovariance do
"""
end

{x, location} = Scholar.Covariance.Utils.center(x, opts[:assume_centered])
{x, location} = Scholar.Covariance.Utils.center(x, opts[:assume_centered?])

covariance =
Scholar.Covariance.Utils.empirical_covariance(x)
Expand Down
4 changes: 2 additions & 2 deletions test/scholar/covariance/ledoit_wolf_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ defmodule Scholar.Covariance.LedoitWolfTest do
)
end

test "fit test - :assume_centered is true" do
test "fit test - :assume_centered? is true" do
key = key()

{x, _new_key} =
Expand All @@ -52,7 +52,7 @@ defmodule Scholar.Covariance.LedoitWolfTest do
type: :f32
)

model = LedoitWolf.fit(x, assume_centered: true)
model = LedoitWolf.fit(x, assume_centered?: true)

assert_all_close(
model.covariance,
Expand Down
4 changes: 2 additions & 2 deletions test/scholar/covariance/shrunk_covariance_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ defmodule Scholar.Covariance.ShrunkCovarianceTest do
)
end

test "fit test - :assume_centered is true" do
test "fit test - :assume_centered? is true" do
key = key()

{x, _new_key} =
Expand All @@ -50,7 +50,7 @@ defmodule Scholar.Covariance.ShrunkCovarianceTest do
type: :f32
)

model = ShrunkCovariance.fit(x, assume_centered: true)
model = ShrunkCovariance.fit(x, assume_centered?: true)

assert_all_close(
model.covariance,
Expand Down

0 comments on commit df80bc3

Please sign in to comment.