Skip to content
Closed
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
10 changes: 5 additions & 5 deletions src/combinators/power.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ end

# ToDo: Make rand return static arrays for statically-sized power measures.

function _cartidxs(axs::Tuple{Vararg{<:AbstractUnitRange,N}}) where {N}
function _cartidxs(axs::Tuple{Vararg{AbstractUnitRange,N}}) where {N}
CartesianIndices(map(_dynamic, axs))
end

Expand All @@ -49,16 +49,16 @@ function Base.rand(rng::AbstractRNG, ::Type{T}, d::PowerMeasure) where {T}
end
end

@inline _pm_axes(sz::Tuple{Vararg{<:IntegerLike,N}}) where {N} = map(one_to, sz)
@inline _pm_axes(axs::Tuple{Vararg{<:AbstractUnitRange,N}}) where {N} = axs
@inline _pm_axes(sz::Tuple{Vararg{IntegerLike,N}}) where {N} = map(one_to, sz)
@inline _pm_axes(axs::Tuple{Vararg{AbstractUnitRange,N}}) where {N} = axs

@inline function powermeasure(x::T, sz::Tuple{Vararg{<:Any,N}}) where {T,N}
@inline function powermeasure(x::T, sz::Tuple{Vararg{Any,N}}) where {T,N}
PowerMeasure(x, _pm_axes(sz))
end

marginals(d::PowerMeasure) = fill_with(d.parent, d.axes)

function Base.:^(μ::AbstractMeasure, dims::Tuple{Vararg{<:AbstractArray,N}}) where {N}
function Base.:^(μ::AbstractMeasure, dims::Tuple{Vararg{AbstractArray,N}}) where {N}
powermeasure(μ, dims)
end

Expand Down
2 changes: 1 addition & 1 deletion src/combinators/smart-constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ powermeasure(m::AbstractMeasure, ::Tuple{}) = m

function powermeasure(
μ::WeightedMeasure,
dims::Tuple{<:AbstractArray,Vararg{<:AbstractArray}},
dims::Tuple{<:AbstractArray,Vararg{AbstractArray}},
)
k = mapreduce(length, *, dims) * μ.logweight
return weightedmeasure(k, μ.base^dims)
Expand Down
4 changes: 2 additions & 2 deletions src/static.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ Returns an instance of `FillArrays.Fill`.
"""
function fill_with end

@inline function fill_with(x::T, sz::Tuple{Vararg{<:IntegerLike,N}}) where {T,N}
@inline function fill_with(x::T, sz::Tuple{Vararg{IntegerLike,N}}) where {T,N}
fill_with(x, map(one_to, sz))
end

@inline function fill_with(x::T, axs::Tuple{Vararg{<:AbstractUnitRange,N}}) where {T,N}
@inline function fill_with(x::T, axs::Tuple{Vararg{AbstractUnitRange,N}}) where {T,N}
# While `FillArrays.Fill` (mostly?) works with axes that are static unit
# ranges, some operations that automatic differentiation requires do fail
# on such instances of `Fill` (e.g. `reshape` from dynamic to static size).
Expand Down