forked from mimiquate/candlex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixes Nx.slice with tensor start_indices which affected defn_whi…
…le and Nx.Random PRNG (mimiquate#32)
- Loading branch information
Showing
5 changed files
with
139 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
defmodule Candlex.RandomTest do | ||
use Nx.Case, async: true | ||
|
||
test "key/1" do | ||
Nx.Random.key(42) | ||
|> assert_equal(Nx.tensor([0, 42])) | ||
end | ||
|
||
test "uniform/1" do | ||
{normal, new_key} = | ||
Nx.Random.key(42) | ||
|> Nx.Random.uniform() | ||
|
||
normal | ||
|> assert_close(Nx.tensor(0.9145736694335938)) | ||
|
||
new_key | ||
|> assert_equal(Nx.tensor([2_465_931_498, 3_679_230_171])) | ||
end | ||
|
||
test "normal/1" do | ||
{normal, new_key} = | ||
Nx.Random.key(42) | ||
|> Nx.Random.normal() | ||
|
||
normal | ||
|> assert_close(Nx.tensor(1.3694695234298706)) | ||
|
||
new_key | ||
|> assert_equal(Nx.tensor([2_465_931_498, 3_679_230_171])) | ||
end | ||
end |