Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/PoissonRandom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export pois_rand, PassthroughRNG
# GPU-compatible Poisson sampling via PassthroughRNG
struct PassthroughRNG <: AbstractRNG end

Random.rand(rng::PassthroughRNG) = rand()
Base.rand(rng::PassthroughRNG) = rand()
Random.randexp(rng::PassthroughRNG) = randexp()
Random.randn(rng::PassthroughRNG) = randn()
Base.randn(rng::PassthroughRNG) = randn()

# When an overlay method table (e.g. CUDA.jl's `@device_override
# Random.randexp(::AbstractRNG)`) shadows the methods above, the overlay body
Expand All @@ -20,7 +20,7 @@ Random.randn(rng::PassthroughRNG) = randn()
# `_rand52(r, rng_native_52(r))` → `rand(r, UInt64)`; provide those so the
# chain still reaches bare rand(T) and the device-side default_rng path.
Random.rng_native_52(::PassthroughRNG) = UInt64
Random.rand(rng::PassthroughRNG, ::Type{T}) where {T} = rand(T)
Base.rand(rng::PassthroughRNG, ::Type{T}) where {T} = rand(T)

count_rand(λ::Real) = count_rand(Random.default_rng(), λ)
function count_rand(rng::AbstractRNG, λ::Real)
Expand Down
6 changes: 1 addition & 5 deletions test/qa/Project.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
PoissonRandom = "e409e4f3-bfea-5376-8464-e040bb5c01ab"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand All @@ -13,10 +11,8 @@ PoissonRandom = {path = "../.."}

[compat]
Aqua = "0.8"
ExplicitImports = "1.14.0"
JET = "0.9, 0.10, 0.11"
Random = "1.10"
SafeTestsets = "0.1, 1"
SciMLTesting = "1"
SciMLTesting = "1.6"
Test = "1"
julia = "1.10"
48 changes: 12 additions & 36 deletions test/qa/qa.jl
Original file line number Diff line number Diff line change
@@ -1,36 +1,12 @@
using PoissonRandom, Aqua, JET, ExplicitImports
using Random
using Test

@testset "Aqua" begin
Aqua.find_persistent_tasks_deps(PoissonRandom)
Aqua.test_ambiguities(PoissonRandom, recursive = false)
Aqua.test_deps_compat(PoissonRandom)
Aqua.test_piracies(
PoissonRandom,
treat_as_own = []
)
Aqua.test_project_extras(PoissonRandom)
Aqua.test_stale_deps(PoissonRandom)
Aqua.test_unbound_args(PoissonRandom)
Aqua.test_undefined_exports(PoissonRandom)
end

@testset "JET static analysis" begin
@testset "Type stability" begin
JET.@test_opt target_modules = (PoissonRandom,) pois_rand(10.0)
JET.@test_opt target_modules = (PoissonRandom,) pois_rand(Random.default_rng(), 10.0)
JET.@test_opt target_modules = (PoissonRandom,) pois_rand(PassthroughRNG(), 10.0)
end

@testset "Error analysis" begin
JET.@test_call target_modules = (PoissonRandom,) pois_rand(10.0)
JET.@test_call target_modules = (PoissonRandom,) pois_rand(Random.default_rng(), 10.0)
JET.@test_call target_modules = (PoissonRandom,) pois_rand(PassthroughRNG(), 10.0)
end
end

@testset "ExplicitImports" begin
@test check_no_implicit_imports(PoissonRandom) === nothing
@test check_no_stale_explicit_imports(PoissonRandom) === nothing
end
using SciMLTesting, PoissonRandom, JET, Test

run_qa(
PoissonRandom;
explicit_imports = true,
ei_kwargs = (;
# default_rng / rng_native_52 are Random stdlib internals (not public in
# Random): default_rng is the standard default-RNG accessor; rng_native_52 is
# extended for the PassthroughRNG sampler chain.
all_qualified_accesses_are_public = (; ignore = (:default_rng, :rng_native_52)),
),
)
Loading