Skip to content

Commit

Permalink
Update to Distributions 0.25 (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
devmotion committed May 2, 2021
1 parent fc2c946 commit c5e42a3
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ConsistencyResampling"
uuid = "4937dc1f-c7a3-5772-9d42-4a8277f2eb51"
authors = ["David Widmann <david.widmann@it.uu.se>"]
version = "0.3.0"
version = "0.3.1"

[deps]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down
27 changes: 16 additions & 11 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[ChainRulesCore]]
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "42e3c181483fbd2c416087a0a93838803e358358"
git-tree-sha1 = "a66109c73612c63b10923ac446fddb0f0d21a593"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "0.9.38"
version = "0.9.40"

[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
Expand All @@ -35,7 +35,7 @@ uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
deps = ["Random", "StatsBase"]
path = ".."
uuid = "4937dc1f-c7a3-5772-9d42-4a8277f2eb51"
version = "0.2.1"
version = "0.3.0"

[[DataAPI]]
git-tree-sha1 = "dfb3b7e89e395be1e25c2ad6d7690dc29cc53b1d"
Expand Down Expand Up @@ -67,9 +67,9 @@ uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[Distributions]]
deps = ["FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SparseArrays", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns"]
git-tree-sha1 = "a837fdf80f333415b69684ba8e8ae6ba76de6aaa"
git-tree-sha1 = "36aa8125c8caa6a449b54d5d45ac97afd392549d"
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
version = "0.24.18"
version = "0.25.0"

[[DocStringExtensions]]
deps = ["LibGit2", "Markdown", "Pkg", "Test"]
Expand Down Expand Up @@ -252,10 +252,10 @@ uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[SortingAlgorithms]]
deps = ["DataStructures", "Random", "Test"]
git-tree-sha1 = "03f5898c9959f8115e30bc7226ada7d0df554ddd"
deps = ["DataStructures"]
git-tree-sha1 = "2ec1962eba973f383239da22e75218565c390a96"
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
version = "0.3.1"
version = "1.0.0"

[[SparseArrays]]
deps = ["LinearAlgebra", "Random"]
Expand All @@ -271,11 +271,16 @@ version = "1.3.0"
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[[StatsAPI]]
git-tree-sha1 = "1958272568dc176a1d881acb797beb909c785510"
uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
version = "1.0.0"

[[StatsBase]]
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics"]
git-tree-sha1 = "4d8ca45223d7a28839e775d73a6f6b6b2ac64fd1"
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
git-tree-sha1 = "2f6792d523d7448bbe2fec99eca9218f06cc746d"
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
version = "0.33.6"
version = "0.33.8"

[[StatsFuns]]
deps = ["LogExpFunctions", "Rmath", "SpecialFunctions"]
Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"

[compat]
ConsistencyResampling = "0.3"
Distributions = "0.24"
Distributions = "0.25"
Documenter = "0.26"
StructArrays = "0.5"
julia = "1"
22 changes: 12 additions & 10 deletions docs/src/supported.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,6 @@ predictions = map(Normal, randn(100), rand(100))
nothing #hide
```

Unfortunately, currently Distributions does not define `Random.Sampler` and therefore we have
to implement it to be able to perform consistency resampling:

```@example distribution
using Random
Random.Sampler(::Type{<:AbstractRNG}, s::Sampleable, ::Val{1}) = s
Random.Sampler(::Type{<:AbstractRNG}, s::Sampleable, ::Val{Inf}) = sampler(s)
```

Consistency resampling yields a randomly sampled prediction and a sample from it.

```@example distribution
Expand All @@ -111,3 +101,15 @@ prediction, target = rand(Consistent(predictions))
```@example distribution
prediction in predictions
```

!!! note
This example requires Distributions >= 0.25.0. Older versions of Distributions did not
define `Random.Sampler` and therefore you have to implement it yourself to be able to
perform consistency resampling:
```julia
using Distributions
using Random

Random.Sampler(::Type{<:AbstractRNG}, s::Sampleable, ::Val{1}) = s
Random.Sampler(::Type{<:AbstractRNG}, s::Sampleable, ::Val{Inf}) = sampler(s)
```
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Distributions = "0.24"
Distributions = "0.25"
Documenter = "0.26"
StatsBase = "0.33"
StructArrays = "0.5"
Expand Down
4 changes: 0 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ using Test

Random.seed!(1234)

# Distributions.jl does not implement the Random API
Random.Sampler(::Type{<:AbstractRNG}, s::Sampleable, ::Val{1}) = s
Random.Sampler(::Type{<:AbstractRNG}, s::Sampleable, ::Val{Inf}) = sampler(s)

@testset "ConsistencyResampling" begin
@testset "Alias sampler" begin
include("alias.jl")
Expand Down

2 comments on commit c5e42a3

@devmotion
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/35831

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.1 -m "<description of version>" c5e42a39d878b18c7c98967a2e27dd2cc38798d8
git push origin v0.3.1

Please sign in to comment.