Skip to content

Commit

Permalink
Merge pull request #36 from invenia/gm/nameddims
Browse files Browse the repository at this point in the history
Support NamedDims functions
  • Loading branch information
Glenn Moynihan authored Oct 21, 2022
2 parents 4c1155e + 0eda537 commit dae9805
Show file tree
Hide file tree
Showing 5 changed files with 286 additions and 179 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
name = "KeyedDistributions"
uuid = "2576fb08-064d-4cab-b15d-8dda7fcb9a6d"
authors = ["Invenia Technical Computing Corporation"]
version = "0.1.8"
version = "0.1.9"

[deps]
AutoHashEquals = "15f4f7f2-30c1-5605-9d31-71845cf9641f"
AxisKeys = "94b1ba4f-4ee9-5380-92f1-94cde586c3c5"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
NamedDims = "356022a1-0364-5f58-8944-0da4b18d706f"
PDMatsExtras = "2c7acb1b-7338-470f-b38f-951d2bcb9193"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[compat]
AutoHashEquals = "0.2"
AxisKeys = "0.1, 0.2"
Distributions = "0.24, 0.25"
NamedDims = "0.2, 0.3, 1"
PDMats = "0.10"
PDMatsExtras = "2.5"
StableRNGs = "1"
Expand Down
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)

KeyedDistributions.jl provides thin wrappers of [`Distribution`](https://juliastats.org/Distributions.jl/latest/types/#Distributions) and [`Sampleable`](https://juliastats.org/Distributions.jl/latest/types/#Sampleable), to store keys for the variates.
KeyedDistributions.jl provides thin wrappers of [`Distribution`](https://juliastats.org/Distributions.jl/latest/types/#Distributions) and [`Sampleable`](https://juliastats.org/Distributions.jl/latest/types/#Sampleable), to store keys and dimnames for the variates.

```julia
julia> using KeyedDistributions, Distributions;
julia> using KeyedDistributions, Distributions, NamedDims;

julia> kd = KeyedDistribution(MvNormal(3, 1.0), [:x, :y, :z]);
julia> kd = KeyedDistribution(MvNormal(3, 1.0); id=[:x, :y, :z]);

julia> axiskeys(kd)
([:x, :y, :z],)

julia> dimnames(kd)
(:id,)

julia> distribution(kd)
ZeroMeanIsoNormal(
dim: 3
Expand All @@ -29,22 +32,22 @@ Methods for `Distribution` and `Sampleable` return [`KeyedArray`](https://github

```julia
julia> mean(kd)
1-dimensional KeyedArray(...) with keys:
3-element Vector{Symbol}
1-dimensional KeyedArray(NamedDimsArray(...)) with keys:
id 3-element Vector{Symbol}
And data, 3-element Zeros{Float64}:
(:x) 0.0
(:y) 0.0
(:z) 0.0

julia> rand(kd, 2)
2-dimensional KeyedArray(...) with keys:
3-element Vector{Symbol}
2-element OneTo{Int}
id 3-element Vector{Symbol}
sample 2-element OneTo{Int}
And data, 3×2 Matrix{Float64}:
(1) (2)
(:x) -1.11227 -0.279841
(:y) 0.00784496 0.871718
(:z) -0.930186 -0.8922
```

In this way, KeyedDistributions.jl extends the [AxisKeys](https://github.com/mcabbott/AxisKeys.jl) ecosystem to [Distributions.jl](https://github.com/JuliaStats/Distributions.jl).
In this way, KeyedDistributions.jl extends the [AxisKeys](https://github.com/mcabbott/AxisKeys.jl) and [NamedDims](https://github.com/invenia/NamedDims.jl) ecosystems to [Distributions.jl](https://github.com/JuliaStats/Distributions.jl).
Loading

2 comments on commit dae9805

@glennmoy
Copy link
Member

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/70778

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.1.9 -m "<description of version>" dae9805cc4680405d0a7dacafb5692e5ad1b9658
git push origin v0.1.9

Please sign in to comment.