Skip to content

Commit

Permalink
better randn
Browse files Browse the repository at this point in the history
  • Loading branch information
islent committed Jul 30, 2024
1 parent b384966 commit 9915068
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
version:
- '1.6.0'
- '1.10.4'
os:
- ubuntu-latest
- macOS-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1.6.0]
julia-version: [1.10.4]
julia-arch: [x64]
os: [ubuntu-latest]
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CompatHelperManual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
if: "contains(github.event.head_commit.message, '[compat]')"
strategy:
matrix:
julia-version: [1.6.0]
julia-version: [1.10.4]
julia-arch: [x64]
os: [ubuntu-latest]
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ManuallyBuildDoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v1
- uses: julia-actions/setup-julia@latest
with:
version: '1.6.0'
version: '1.10.4'
- run: julia --project=docs -e '
using Pkg;
Pkg.add("Documenter");
Expand Down
2 changes: 1 addition & 1 deletion src/PhysicalParticles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Base: +, -, *, /, zero, length, iterate, real, show, ==, #getproperty,
convert,
Array, Vector,
one, zero, isone, iszero, isnan, isinf, oneunit, isapprox, parse
import Random: rand
import Random: rand, randn
import LinearAlgebra: norm, normalize, dot, cross, ×

import Statistics: mean, std, var, median, middle
Expand Down
2 changes: 2 additions & 0 deletions src/Random.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Random.rand(rng::AbstractRNG, ::Random.SamplerType{PVector2D{T}}) where T = PVector2D(rand(rng,T), rand(rng,T))
Random.rand(rng::AbstractRNG, ::Random.SamplerType{PVector{T}}) where T = PVector(rand(rng,T), rand(rng,T), rand(rng,T))
Random.randn(rng::AbstractRNG, ::Type{PVector2D{T}}) where T = PVector2D(randn(rng,T), randn(rng,T))
Random.randn(rng::AbstractRNG, ::Type{PVector{T}}) where T = PVector(randn(rng,T), randn(rng,T), randn(rng,T))

"""
randn_pvector2d(n::Integer, T::DataType = Float64)
Expand Down
4 changes: 4 additions & 0 deletions test/testPhysicalParticles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ end
@test p_Star2D[1].Pos == a[1]

# randn
randn(PVector2D{Float64})

a_randn = randn_pvector2d(5)
@test length(a_randn) == 5

Expand Down Expand Up @@ -199,6 +201,8 @@ end
@test_throws ErrorException assign_particles(ps, :Pos, [PVector(u"m")])

# randn
randn(PVector{Float64})

a_randn = randn_pvector(5)
@test length(a_randn) == 5

Expand Down

0 comments on commit 9915068

Please sign in to comment.