Skip to content

Commit

Permalink
Update test seeds to :exsss
Browse files Browse the repository at this point in the history
  • Loading branch information
sabiwara committed Aug 26, 2024
1 parent d8202a6 commit b51133b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bench/enum/random.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ Benchee.run(
"Enum.random/1 (vector)" => fn _ -> Enum.random(vector) end,
"Enum.random/1 (range)" => fn _ -> Enum.random(range) end
},
before_scenario: fn _ -> :rand.seed(:exrop, {101, 102, 103}) end
before_scenario: fn _ -> :rand.seed(:exsss, {101, 102, 103}) end
)
4 changes: 2 additions & 2 deletions bench/ord_map/new.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule Bench.Maps.New do

defp shuffle(enum) do
if @shuffled do
:rand.seed(:exrop, {1, 2, 3})
:rand.seed(:exsss, {1, 2, 3})
Enum.shuffle(enum)
else
enum
Expand All @@ -22,7 +22,7 @@ defmodule Bench.Maps.New do
],
inputs: inputs(),
before_scenario: fn n ->
:rand.seed(:exrop, {1, 2, 3})
:rand.seed(:exsss, {1, 2, 3})
1..n |> shuffle() |> Enum.map(fn i -> {i, "i"} end)
end
)
Expand Down
2 changes: 1 addition & 1 deletion bench/vector/shuffle.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ Benchee.run(
"Enum.shuffle/1 (vector)" => fn _ -> Enum.shuffle(vector) end,
"Aja.Enum.shuffle/1 (vector)" => fn _ -> Aja.Enum.shuffle(vector) end
},
before_scenario: fn _ -> :rand.seed(:exrop, {101, 102, 103}) end
before_scenario: fn _ -> :rand.seed(:exsss, {101, 102, 103}) end
)
4 changes: 2 additions & 2 deletions lib/list.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ defmodule Aja.List do
## Examples
# Although not necessary, let's seed the random algorithm
iex> :rand.seed(:exrop, {1, 2, 3})
iex> :rand.seed(:exsss, {1, 2, 3})
iex> Aja.List.repeat(&:rand.uniform/0, 3)
[0.7498295129076106, 0.06161655489244533, 0.7924073127680873]
[0.5455598952593053, 0.6039309974353404, 0.6684893034823949]
# It is basically just syntactic sugar for the following:
iex> Stream.repeatedly(&:rand.uniform/0) |> Enum.take(3)
Expand Down
14 changes: 7 additions & 7 deletions lib/vector.ex
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,9 @@ defmodule Aja.Vector do
## Examples
# Although not necessary, let's seed the random algorithm
iex> :rand.seed(:exrop, {1, 2, 3})
iex> :rand.seed(:exsss, {1, 2, 3})
iex> Aja.Vector.repeat(&:rand.uniform/0, 3)
vec([0.7498295129076106, 0.06161655489244533, 0.7924073127680873])
vec([0.5455598952593053, 0.6039309974353404, 0.6684893034823949])
"""
def repeat(generator_fun, n)
Expand Down Expand Up @@ -1869,9 +1869,9 @@ defmodule Aja.Vector do
## Examples
# Although not necessary, let's seed the random algorithm
iex> :rand.seed(:exrop, {1, 2, 3})
iex> :rand.seed(:exsss, {1, 2, 3})
iex> Aja.Vector.new(1..10) |> Aja.Vector.take_random(2)
vec([7, 2])
vec([6, 1])
iex> Aja.Vector.new([:foo, :bar, :baz]) |> Aja.Vector.take_random(100)
vec([:bar, :baz, :foo])
Expand All @@ -1890,11 +1890,11 @@ defmodule Aja.Vector do
## Examples
# Although not necessary, let's seed the random algorithm
iex> :rand.seed(:exrop, {1, 2, 3})
iex> :rand.seed(:exsss, {1, 2, 3})
iex> Aja.Vector.new([1, 2, 3]) |> Aja.Vector.shuffle()
vec([3, 1, 2])
vec([1, 2, 3])
iex> Aja.Vector.new([1, 2, 3]) |> Aja.Vector.shuffle()
vec([1, 3, 2])
vec([3, 1, 2])
"""
@spec shuffle(t(val)) :: t(val) when val: value
Expand Down
2 changes: 1 addition & 1 deletion test/support/test_helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ defmodule Aja.TestHelpers do

def with_seed(fun) when is_function(fun, 0) do
Task.async(fn ->
:rand.seed(:exrop, {101, 102, 103})
:rand.seed(:exsss, {101, 102, 103})
fun.()
end)
|> Task.await()
Expand Down

0 comments on commit b51133b

Please sign in to comment.