Skip to content

Commit

Permalink
Merge pull request #137 from JuliaRobotics/21Q3/enh/mkd_notpartial
Browse files Browse the repository at this point in the history
MKD helpers now ignore partial if full
  • Loading branch information
dehann committed Aug 5, 2021
2 parents 2338507 + 47da929 commit 39f2bfc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,13 @@ function manifoldProduct( ff::AbstractVector{<:ManifoldKernelDensity},
for msk in partialDimMask
otherDims .|= msk
end
# error(otherDims)

# build new output ManifoldKernelDensity
bws[:] = getKDEManifoldBandwidths(pGM, manif)
bel = kde!(pGM, bws, addopT, diffopT)

# FIXME u0 might not be representative of the partial information
if sum(otherDims) == ndims
return ManifoldKernelDensity(mani, bel, nothing, ff[1]._u0)
else
return ManifoldKernelDensity(mani, bel, (1:ndims)[otherDims], ff[1]._u0)
end
return ManifoldKernelDensity(mani, bel, otherDims, ff[1]._u0)
end


Expand Down
26 changes: 24 additions & 2 deletions src/services/ManifoldKernelDensity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,33 @@ export calcMean

ManifoldKernelDensity(mani::M,
bel::B,
partial::L=nothing,
::Nothing=nothing,
u0::P=zeros(manifold_dimension(mani));
infoPerCoord::AbstractVector{<:Real}=ones(getNumberCoords(mani, u0)) ) where {M <: MB.AbstractManifold, B <: BallTreeDensity, L, P} = ManifoldKernelDensity{M,B,L,P}(mani,bel,partial,u0,infoPerCoord)
infoPerCoord::AbstractVector{<:Real}=ones(getNumberCoords(mani, u0)) ) where {M <: MB.AbstractManifold, B <: BallTreeDensity, P} = ManifoldKernelDensity{M,B,Nothing,P}(mani,bel,nothing,u0,infoPerCoord)
#

function ManifoldKernelDensity( mani::M,
bel::B,
partial::L,
u0::P=zeros(manifold_dimension(mani));
infoPerCoord::AbstractVector{<:Real}=ones(getNumberCoords(mani, u0)) ) where {M <: MB.AbstractManifold, B <: BallTreeDensity, L<:AbstractVector{<:Integer}, P}
#
if length(partial) != manifold_dimension(mani)
# call the constructor direct
return ManifoldKernelDensity{M,B,L,P}(mani,bel,partial,u0,infoPerCoord)
else
# full manifold, therefore equivalent to L::Nothing
return ManifoldKernelDensity(mani,bel,nothing,u0;infoPerCoord=infoPerCoord)
end
end

ManifoldKernelDensity(mani::M,
bel::B,
pl_mask::Union{<:BitVector,<:AbstractVector{<:Bool}},
u0::P=zeros(manifold_dimension(mani));
infoPerCoord::AbstractVector{<:Real}=ones(getNumberCoords(mani, u0)) ) where {M <: MB.AbstractManifold, B <: BallTreeDensity, P} = ManifoldKernelDensity(mani,bel,(1:manifold_dimension(mani))[pl_mask],u0;infoPerCoord=infoPerCoord)


function ManifoldKernelDensity( M::MB.AbstractManifold,
vecP::AbstractVector{P},
u0=vecP[1];
Expand Down

0 comments on commit 39f2bfc

Please sign in to comment.