From fd7c1dfb46d48650b3a7afa6fbd89e7829b1b182 Mon Sep 17 00:00:00 2001 From: Mateusz Baran Date: Fri, 18 Oct 2024 14:57:28 +0200 Subject: [PATCH 1/5] Split distributions extension --- NEWS.md | 6 + Project.toml | 5 +- .../ManifoldsDistributionsExt.jl | 4 - .../distributions_for_manifolds.jl | 99 -------------- ...oldsDistributionsRecursiveArrayToolsExt.jl | 124 ++++++++++++++++++ src/Manifolds.jl | 9 +- 6 files changed, 141 insertions(+), 106 deletions(-) create mode 100644 ext/ManifoldsDistributionsRecursiveArrayToolsExt.jl diff --git a/NEWS.md b/NEWS.md index 95c19c063..6c7f719b7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.10.4] - 2024-10-18 + +### Changed + +* The `Distributions.jl` extension has been split into an extension that additionally requires `RecursiveArrayTools.jl` and one that does not. + ## [0.10.3] - 2024-10-04 ### Changed diff --git a/Project.toml b/Project.toml index 074f5a4b8..a7b476e9d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Manifolds" uuid = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e" authors = ["Seth Axen ", "Mateusz Baran ", "Ronny Bergmann ", "Antoine Levitt "] -version = "0.10.3" +version = "0.10.4" [deps] Einsum = "b7d42ee7-0b51-5a75-98ca-779d3107e4c0" @@ -35,7 +35,8 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [extensions] ManifoldsBoundaryValueDiffEqExt = "BoundaryValueDiffEq" -ManifoldsDistributionsExt = ["Distributions", "RecursiveArrayTools"] +ManifoldsDistributionsExt = "Distributions" +ManifoldsDistributionsRecursiveArrayToolsExt = ["Distributions", "RecursiveArrayTools"] ManifoldsHybridArraysExt = "HybridArrays" ManifoldsNLsolveExt = "NLsolve" ManifoldsOrdinaryDiffEqDiffEqCallbacksExt = ["DiffEqCallbacks", "OrdinaryDiffEq", "RecursiveArrayTools"] diff --git a/ext/ManifoldsDistributionsExt/ManifoldsDistributionsExt.jl b/ext/ManifoldsDistributionsExt/ManifoldsDistributionsExt.jl index d068a23e5..8abc822a0 100644 --- a/ext/ManifoldsDistributionsExt/ManifoldsDistributionsExt.jl +++ b/ext/ManifoldsDistributionsExt/ManifoldsDistributionsExt.jl @@ -13,8 +13,6 @@ if isdefined(Base, :get_extension) uniform_distribution using Manifolds: get_iterator, get_parameter, _read, _write - - using RecursiveArrayTools: ArrayPartition else # imports need to be relative for Requires.jl-based workflows: # https://github.com/JuliaArrays/ArrayInterface.jl/pull/387 @@ -30,8 +28,6 @@ else uniform_distribution using ..Manifolds: get_iterator, get_parameter, _read, _write - - using ..RecursiveArrayTools: ArrayPartition end include("distributions.jl") diff --git a/ext/ManifoldsDistributionsExt/distributions_for_manifolds.jl b/ext/ManifoldsDistributionsExt/distributions_for_manifolds.jl index c9719078c..c2b34df95 100644 --- a/ext/ManifoldsDistributionsExt/distributions_for_manifolds.jl +++ b/ext/ManifoldsDistributionsExt/distributions_for_manifolds.jl @@ -1,103 +1,4 @@ -## product manifold - -""" - ProductPointDistribution(M::ProductManifold, distributions) - -Product distribution on manifold `M`, combined from `distributions`. -""" -struct ProductPointDistribution{ - TM<:ProductManifold, - TD<:(NTuple{N,Distribution} where {N}), -} <: MPointDistribution{TM} - manifold::TM - distributions::TD -end - -function ProductPointDistribution(M::ProductManifold, distributions::MPointDistribution...) - return ProductPointDistribution{typeof(M),typeof(distributions)}(M, distributions) -end -function ProductPointDistribution(distributions::MPointDistribution...) - M = ProductManifold(map(d -> support(d).manifold, distributions)...) - return ProductPointDistribution(M, distributions...) -end - -""" - ProductFVectorDistribution([type::VectorSpaceFiber], [x], distrs...) - -Generates a random vector at point `x` from vector space (a fiber of a tangent -bundle) of type `type` using the product distribution of given distributions. - -Vector space type and `x` can be automatically inferred from distributions `distrs`. -""" -struct ProductFVectorDistribution{ - TSpace<:VectorSpaceFiber{<:Any,<:ProductManifold}, - TD<:(NTuple{N,Distribution} where {N}), -} <: FVectorDistribution{TSpace} - type::TSpace - distributions::TD -end - -function ProductFVectorDistribution(distributions::FVectorDistribution...) - M = ProductManifold(map(d -> support(d).space.manifold, distributions)...) - fiber_type = support(distributions[1]).space.fiber_type - if !all(d -> support(d).space.fiber_type == fiber_type, distributions) - error( - "Not all distributions have support in vector spaces of the same type, which is currently not supported", - ) - end - # Probably worth considering sum spaces in the future? - p = ArrayPartition(map(d -> support(d).space.point, distributions)...) - return ProductFVectorDistribution(Fiber(M, p, fiber_type), distributions) -end - -function Random.rand(rng::AbstractRNG, d::ProductFVectorDistribution) - return ArrayPartition(map(d -> rand(rng, d), d.distributions)...) -end -function Random.rand(rng::AbstractRNG, d::ProductPointDistribution) - return ArrayPartition(map(d -> rand(rng, d), d.distributions)...) -end - -function Distributions._rand!( - rng::AbstractRNG, - d::ProductFVectorDistribution, - X::ArrayPartition, -) - map( - (t1, t2) -> Distributions._rand!(rng, t1, t2), - d.distributions, - submanifold_components(d.type.manifold, X), - ) - return X -end -function Distributions._rand!( - rng::AbstractRNG, - d::ProductPointDistribution, - p::ArrayPartition, -) - map( - (t1, t2) -> Distributions._rand!(rng, t1, t2), - d.distributions, - submanifold_components(d.manifold, p), - ) - return p -end - -Distributions.support(d::ProductPointDistribution) = MPointSupport(d.manifold) -function Distributions.support(tvd::ProductFVectorDistribution) - return FVectorSupport(tvd.type) -end - -function uniform_distribution(M::ProductManifold) - return ProductPointDistribution(M, map(uniform_distribution, M.manifolds)) -end -function uniform_distribution(M::ProductManifold, p) - return ProductPointDistribution( - M, - map(uniform_distribution, M.manifolds, submanifold_components(M, p)), - ) -end - ## power manifold """ diff --git a/ext/ManifoldsDistributionsRecursiveArrayToolsExt.jl b/ext/ManifoldsDistributionsRecursiveArrayToolsExt.jl new file mode 100644 index 000000000..8b277a5ed --- /dev/null +++ b/ext/ManifoldsDistributionsRecursiveArrayToolsExt.jl @@ -0,0 +1,124 @@ +module ManifoldsDistributionsRecursiveArrayToolsExt + +if isdefined(Base, :get_extension) + using Manifolds + using Distributions + using Random + using LinearAlgebra + + import Manifolds: uniform_distribution + + using RecursiveArrayTools: ArrayPartition +else + # imports need to be relative for Requires.jl-based workflows: + # https://github.com/JuliaArrays/ArrayInterface.jl/pull/387 + using ..Manifolds + using ..Distributions + using ..Random + + import ..Manifolds: uniform_distribution + + using ..RecursiveArrayTools: ArrayPartition +end + +## product manifold + +""" + ProductPointDistribution(M::ProductManifold, distributions) + +Product distribution on manifold `M`, combined from `distributions`. +""" +struct ProductPointDistribution{ + TM<:ProductManifold, + TD<:(NTuple{N,Distribution} where {N}), +} <: MPointDistribution{TM} + manifold::TM + distributions::TD +end + +function ProductPointDistribution(M::ProductManifold, distributions::MPointDistribution...) + return ProductPointDistribution{typeof(M),typeof(distributions)}(M, distributions) +end +function ProductPointDistribution(distributions::MPointDistribution...) + M = ProductManifold(map(d -> support(d).manifold, distributions)...) + return ProductPointDistribution(M, distributions...) +end + +""" + ProductFVectorDistribution([type::VectorSpaceFiber], [x], distrs...) + +Generates a random vector at point `x` from vector space (a fiber of a tangent +bundle) of type `type` using the product distribution of given distributions. + +Vector space type and `x` can be automatically inferred from distributions `distrs`. +""" +struct ProductFVectorDistribution{ + TSpace<:VectorSpaceFiber{<:Any,<:ProductManifold}, + TD<:(NTuple{N,Distribution} where {N}), +} <: FVectorDistribution{TSpace} + type::TSpace + distributions::TD +end + +function ProductFVectorDistribution(distributions::FVectorDistribution...) + M = ProductManifold(map(d -> support(d).space.manifold, distributions)...) + fiber_type = support(distributions[1]).space.fiber_type + if !all(d -> support(d).space.fiber_type == fiber_type, distributions) + error( + "Not all distributions have support in vector spaces of the same type, which is currently not supported", + ) + end + # Probably worth considering sum spaces in the future? + p = ArrayPartition(map(d -> support(d).space.point, distributions)...) + return ProductFVectorDistribution(Fiber(M, p, fiber_type), distributions) +end + +function Random.rand(rng::AbstractRNG, d::ProductFVectorDistribution) + return ArrayPartition(map(d -> rand(rng, d), d.distributions)...) +end +function Random.rand(rng::AbstractRNG, d::ProductPointDistribution) + return ArrayPartition(map(d -> rand(rng, d), d.distributions)...) +end + +function Distributions._rand!( + rng::AbstractRNG, + d::ProductFVectorDistribution, + X::ArrayPartition, +) + map( + (t1, t2) -> Distributions._rand!(rng, t1, t2), + d.distributions, + submanifold_components(d.type.manifold, X), + ) + return X +end +function Distributions._rand!( + rng::AbstractRNG, + d::ProductPointDistribution, + p::ArrayPartition, +) + map( + (t1, t2) -> Distributions._rand!(rng, t1, t2), + d.distributions, + submanifold_components(d.manifold, p), + ) + return p +end + +Distributions.support(d::ProductPointDistribution) = MPointSupport(d.manifold) +function Distributions.support(tvd::ProductFVectorDistribution) + return FVectorSupport(tvd.type) +end + +function uniform_distribution(M::ProductManifold) + return ProductPointDistribution(M, map(uniform_distribution, M.manifolds)) +end +function uniform_distribution(M::ProductManifold, p) + return ProductPointDistribution( + M, + map(uniform_distribution, M.manifolds, submanifold_components(M, p)), + ) +end + + +end diff --git a/src/Manifolds.jl b/src/Manifolds.jl index e693a5b88..756d88fe5 100644 --- a/src/Manifolds.jl +++ b/src/Manifolds.jl @@ -597,6 +597,9 @@ function __init__() if exc.f === solve_exp_ode print(io, "\nDid you forget to load OrdinaryDiffEq? For example: ") printstyled(io, "`using OrdinaryDiffEq`", color=:cyan) + elseif exc.f === uniform_distribution + print(io, "\nDid you forget to load Distributions or RecurisveArrayTools? For example: ") + printstyled(io, "`using Distributions`", color=:cyan) end end end @@ -610,6 +613,10 @@ function __init__() include("../ext/ManifoldsBoundaryValueDiffEqExt.jl") end + @require Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" begin + include("../ext/ManifoldsDistributionsExt/ManifoldsDistributionsExt.jl") + end + @require NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56" begin include("../ext/ManifoldsNLsolveExt.jl") end @@ -630,7 +637,7 @@ function __init__() ) @require Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" begin - include("../ext/ManifoldsDistributionsExt/ManifoldsDistributionsExt.jl") + include("../ext/ManifoldsDistributionsRecursiveArrayToolsExt.jl") end @require OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" begin From 7e473a1e56e0f82777f0e8d6db27e3e605a89150 Mon Sep 17 00:00:00 2001 From: Mateusz Baran Date: Fri, 18 Oct 2024 15:03:09 +0200 Subject: [PATCH 2/5] maybe keep using formatter v1 for now --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 410d633ce..ce8609b53 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -18,7 +18,7 @@ jobs: - name: Install JuliaFormatter and format run: | using Pkg - Pkg.add(PackageSpec(name="JuliaFormatter")) + Pkg.add(PackageSpec(name="JuliaFormatter", version="1")) using JuliaFormatter format("."; verbose=true) shell: julia --color=yes {0} From 2063f690eb274263240100c9126c7af62c0d3244 Mon Sep 17 00:00:00 2001 From: Mateusz Baran Date: Fri, 18 Oct 2024 15:06:24 +0200 Subject: [PATCH 3/5] formatting --- ext/ManifoldsDistributionsRecursiveArrayToolsExt.jl | 1 - src/Manifolds.jl | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/ManifoldsDistributionsRecursiveArrayToolsExt.jl b/ext/ManifoldsDistributionsRecursiveArrayToolsExt.jl index 8b277a5ed..089f327c2 100644 --- a/ext/ManifoldsDistributionsRecursiveArrayToolsExt.jl +++ b/ext/ManifoldsDistributionsRecursiveArrayToolsExt.jl @@ -120,5 +120,4 @@ function uniform_distribution(M::ProductManifold, p) ) end - end diff --git a/src/Manifolds.jl b/src/Manifolds.jl index 756d88fe5..82c9e9091 100644 --- a/src/Manifolds.jl +++ b/src/Manifolds.jl @@ -598,7 +598,10 @@ function __init__() print(io, "\nDid you forget to load OrdinaryDiffEq? For example: ") printstyled(io, "`using OrdinaryDiffEq`", color=:cyan) elseif exc.f === uniform_distribution - print(io, "\nDid you forget to load Distributions or RecurisveArrayTools? For example: ") + print( + io, + "\nDid you forget to load Distributions or RecurisveArrayTools? For example: ", + ) printstyled(io, "`using Distributions`", color=:cyan) end end From 32703f9a8cc6962e9c851208d55c30bfb044544d Mon Sep 17 00:00:00 2001 From: Mateusz Baran Date: Fri, 18 Oct 2024 17:30:29 +0200 Subject: [PATCH 4/5] undo the split --- NEWS.md | 4 +- Project.toml | 3 +- .../ManifoldsDistributionsExt.jl | 4 + .../distributions_for_manifolds.jl | 99 ++++++++++++++ ...oldsDistributionsRecursiveArrayToolsExt.jl | 123 ------------------ src/Manifolds.jl | 10 +- 6 files changed, 109 insertions(+), 134 deletions(-) delete mode 100644 ext/ManifoldsDistributionsRecursiveArrayToolsExt.jl diff --git a/NEWS.md b/NEWS.md index 6c7f719b7..e5f931594 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,9 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.10.4] - 2024-10-18 -### Changed +### Added -* The `Distributions.jl` extension has been split into an extension that additionally requires `RecursiveArrayTools.jl` and one that does not. +* `uniform_distribution` now has an error hint explaining what has to be done to make it work. ## [0.10.3] - 2024-10-04 diff --git a/Project.toml b/Project.toml index a7b476e9d..24e970544 100644 --- a/Project.toml +++ b/Project.toml @@ -35,8 +35,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [extensions] ManifoldsBoundaryValueDiffEqExt = "BoundaryValueDiffEq" -ManifoldsDistributionsExt = "Distributions" -ManifoldsDistributionsRecursiveArrayToolsExt = ["Distributions", "RecursiveArrayTools"] +ManifoldsDistributionsExt = ["Distributions", "RecursiveArrayTools"] ManifoldsHybridArraysExt = "HybridArrays" ManifoldsNLsolveExt = "NLsolve" ManifoldsOrdinaryDiffEqDiffEqCallbacksExt = ["DiffEqCallbacks", "OrdinaryDiffEq", "RecursiveArrayTools"] diff --git a/ext/ManifoldsDistributionsExt/ManifoldsDistributionsExt.jl b/ext/ManifoldsDistributionsExt/ManifoldsDistributionsExt.jl index 8abc822a0..d068a23e5 100644 --- a/ext/ManifoldsDistributionsExt/ManifoldsDistributionsExt.jl +++ b/ext/ManifoldsDistributionsExt/ManifoldsDistributionsExt.jl @@ -13,6 +13,8 @@ if isdefined(Base, :get_extension) uniform_distribution using Manifolds: get_iterator, get_parameter, _read, _write + + using RecursiveArrayTools: ArrayPartition else # imports need to be relative for Requires.jl-based workflows: # https://github.com/JuliaArrays/ArrayInterface.jl/pull/387 @@ -28,6 +30,8 @@ else uniform_distribution using ..Manifolds: get_iterator, get_parameter, _read, _write + + using ..RecursiveArrayTools: ArrayPartition end include("distributions.jl") diff --git a/ext/ManifoldsDistributionsExt/distributions_for_manifolds.jl b/ext/ManifoldsDistributionsExt/distributions_for_manifolds.jl index c2b34df95..c9719078c 100644 --- a/ext/ManifoldsDistributionsExt/distributions_for_manifolds.jl +++ b/ext/ManifoldsDistributionsExt/distributions_for_manifolds.jl @@ -1,4 +1,103 @@ +## product manifold + +""" + ProductPointDistribution(M::ProductManifold, distributions) + +Product distribution on manifold `M`, combined from `distributions`. +""" +struct ProductPointDistribution{ + TM<:ProductManifold, + TD<:(NTuple{N,Distribution} where {N}), +} <: MPointDistribution{TM} + manifold::TM + distributions::TD +end + +function ProductPointDistribution(M::ProductManifold, distributions::MPointDistribution...) + return ProductPointDistribution{typeof(M),typeof(distributions)}(M, distributions) +end +function ProductPointDistribution(distributions::MPointDistribution...) + M = ProductManifold(map(d -> support(d).manifold, distributions)...) + return ProductPointDistribution(M, distributions...) +end + +""" + ProductFVectorDistribution([type::VectorSpaceFiber], [x], distrs...) + +Generates a random vector at point `x` from vector space (a fiber of a tangent +bundle) of type `type` using the product distribution of given distributions. + +Vector space type and `x` can be automatically inferred from distributions `distrs`. +""" +struct ProductFVectorDistribution{ + TSpace<:VectorSpaceFiber{<:Any,<:ProductManifold}, + TD<:(NTuple{N,Distribution} where {N}), +} <: FVectorDistribution{TSpace} + type::TSpace + distributions::TD +end + +function ProductFVectorDistribution(distributions::FVectorDistribution...) + M = ProductManifold(map(d -> support(d).space.manifold, distributions)...) + fiber_type = support(distributions[1]).space.fiber_type + if !all(d -> support(d).space.fiber_type == fiber_type, distributions) + error( + "Not all distributions have support in vector spaces of the same type, which is currently not supported", + ) + end + # Probably worth considering sum spaces in the future? + p = ArrayPartition(map(d -> support(d).space.point, distributions)...) + return ProductFVectorDistribution(Fiber(M, p, fiber_type), distributions) +end + +function Random.rand(rng::AbstractRNG, d::ProductFVectorDistribution) + return ArrayPartition(map(d -> rand(rng, d), d.distributions)...) +end +function Random.rand(rng::AbstractRNG, d::ProductPointDistribution) + return ArrayPartition(map(d -> rand(rng, d), d.distributions)...) +end + +function Distributions._rand!( + rng::AbstractRNG, + d::ProductFVectorDistribution, + X::ArrayPartition, +) + map( + (t1, t2) -> Distributions._rand!(rng, t1, t2), + d.distributions, + submanifold_components(d.type.manifold, X), + ) + return X +end +function Distributions._rand!( + rng::AbstractRNG, + d::ProductPointDistribution, + p::ArrayPartition, +) + map( + (t1, t2) -> Distributions._rand!(rng, t1, t2), + d.distributions, + submanifold_components(d.manifold, p), + ) + return p +end + +Distributions.support(d::ProductPointDistribution) = MPointSupport(d.manifold) +function Distributions.support(tvd::ProductFVectorDistribution) + return FVectorSupport(tvd.type) +end + +function uniform_distribution(M::ProductManifold) + return ProductPointDistribution(M, map(uniform_distribution, M.manifolds)) +end +function uniform_distribution(M::ProductManifold, p) + return ProductPointDistribution( + M, + map(uniform_distribution, M.manifolds, submanifold_components(M, p)), + ) +end + ## power manifold """ diff --git a/ext/ManifoldsDistributionsRecursiveArrayToolsExt.jl b/ext/ManifoldsDistributionsRecursiveArrayToolsExt.jl deleted file mode 100644 index 089f327c2..000000000 --- a/ext/ManifoldsDistributionsRecursiveArrayToolsExt.jl +++ /dev/null @@ -1,123 +0,0 @@ -module ManifoldsDistributionsRecursiveArrayToolsExt - -if isdefined(Base, :get_extension) - using Manifolds - using Distributions - using Random - using LinearAlgebra - - import Manifolds: uniform_distribution - - using RecursiveArrayTools: ArrayPartition -else - # imports need to be relative for Requires.jl-based workflows: - # https://github.com/JuliaArrays/ArrayInterface.jl/pull/387 - using ..Manifolds - using ..Distributions - using ..Random - - import ..Manifolds: uniform_distribution - - using ..RecursiveArrayTools: ArrayPartition -end - -## product manifold - -""" - ProductPointDistribution(M::ProductManifold, distributions) - -Product distribution on manifold `M`, combined from `distributions`. -""" -struct ProductPointDistribution{ - TM<:ProductManifold, - TD<:(NTuple{N,Distribution} where {N}), -} <: MPointDistribution{TM} - manifold::TM - distributions::TD -end - -function ProductPointDistribution(M::ProductManifold, distributions::MPointDistribution...) - return ProductPointDistribution{typeof(M),typeof(distributions)}(M, distributions) -end -function ProductPointDistribution(distributions::MPointDistribution...) - M = ProductManifold(map(d -> support(d).manifold, distributions)...) - return ProductPointDistribution(M, distributions...) -end - -""" - ProductFVectorDistribution([type::VectorSpaceFiber], [x], distrs...) - -Generates a random vector at point `x` from vector space (a fiber of a tangent -bundle) of type `type` using the product distribution of given distributions. - -Vector space type and `x` can be automatically inferred from distributions `distrs`. -""" -struct ProductFVectorDistribution{ - TSpace<:VectorSpaceFiber{<:Any,<:ProductManifold}, - TD<:(NTuple{N,Distribution} where {N}), -} <: FVectorDistribution{TSpace} - type::TSpace - distributions::TD -end - -function ProductFVectorDistribution(distributions::FVectorDistribution...) - M = ProductManifold(map(d -> support(d).space.manifold, distributions)...) - fiber_type = support(distributions[1]).space.fiber_type - if !all(d -> support(d).space.fiber_type == fiber_type, distributions) - error( - "Not all distributions have support in vector spaces of the same type, which is currently not supported", - ) - end - # Probably worth considering sum spaces in the future? - p = ArrayPartition(map(d -> support(d).space.point, distributions)...) - return ProductFVectorDistribution(Fiber(M, p, fiber_type), distributions) -end - -function Random.rand(rng::AbstractRNG, d::ProductFVectorDistribution) - return ArrayPartition(map(d -> rand(rng, d), d.distributions)...) -end -function Random.rand(rng::AbstractRNG, d::ProductPointDistribution) - return ArrayPartition(map(d -> rand(rng, d), d.distributions)...) -end - -function Distributions._rand!( - rng::AbstractRNG, - d::ProductFVectorDistribution, - X::ArrayPartition, -) - map( - (t1, t2) -> Distributions._rand!(rng, t1, t2), - d.distributions, - submanifold_components(d.type.manifold, X), - ) - return X -end -function Distributions._rand!( - rng::AbstractRNG, - d::ProductPointDistribution, - p::ArrayPartition, -) - map( - (t1, t2) -> Distributions._rand!(rng, t1, t2), - d.distributions, - submanifold_components(d.manifold, p), - ) - return p -end - -Distributions.support(d::ProductPointDistribution) = MPointSupport(d.manifold) -function Distributions.support(tvd::ProductFVectorDistribution) - return FVectorSupport(tvd.type) -end - -function uniform_distribution(M::ProductManifold) - return ProductPointDistribution(M, map(uniform_distribution, M.manifolds)) -end -function uniform_distribution(M::ProductManifold, p) - return ProductPointDistribution( - M, - map(uniform_distribution, M.manifolds, submanifold_components(M, p)), - ) -end - -end diff --git a/src/Manifolds.jl b/src/Manifolds.jl index 82c9e9091..d786c3006 100644 --- a/src/Manifolds.jl +++ b/src/Manifolds.jl @@ -600,9 +600,9 @@ function __init__() elseif exc.f === uniform_distribution print( io, - "\nDid you forget to load Distributions or RecurisveArrayTools? For example: ", + "\nDid you forget to load Distributions and RecurisveArrayTools? For example: ", ) - printstyled(io, "`using Distributions`", color=:cyan) + printstyled(io, "`using Distributions, RecurisveArrayTools`", color=:cyan) end end end @@ -616,10 +616,6 @@ function __init__() include("../ext/ManifoldsBoundaryValueDiffEqExt.jl") end - @require Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" begin - include("../ext/ManifoldsDistributionsExt/ManifoldsDistributionsExt.jl") - end - @require NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56" begin include("../ext/ManifoldsNLsolveExt.jl") end @@ -640,7 +636,7 @@ function __init__() ) @require Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" begin - include("../ext/ManifoldsDistributionsRecursiveArrayToolsExt.jl") + include("../ext/ManifoldsDistributionsExt/ManifoldsDistributionsExt.jl") end @require OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" begin From 04d4f84cc14daf8284e315ac95605fd4d72c0cea Mon Sep 17 00:00:00 2001 From: Mateusz Baran Date: Fri, 18 Oct 2024 17:32:15 +0200 Subject: [PATCH 5/5] fix typo --- src/Manifolds.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Manifolds.jl b/src/Manifolds.jl index d786c3006..7e7327bc9 100644 --- a/src/Manifolds.jl +++ b/src/Manifolds.jl @@ -600,9 +600,9 @@ function __init__() elseif exc.f === uniform_distribution print( io, - "\nDid you forget to load Distributions and RecurisveArrayTools? For example: ", + "\nDid you forget to load Distributions and RecursiveArrayTools? For example: ", ) - printstyled(io, "`using Distributions, RecurisveArrayTools`", color=:cyan) + printstyled(io, "`using Distributions, RecursiveArrayTools`", color=:cyan) end end end