Skip to content

Commit 9591202

Browse files
authored
Use both parametric subtypes in GMM convert (#115)
1 parent 10349f9 commit 9591202

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/gmms.jl

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,20 +183,13 @@ end
183183

184184
## some routines for conversion between float types
185185
# @doc """`convert(GMM{::Type}, GMM)` convert the GMM to a different floating point type""" ->
186-
function Base.convert(::Type{GMM{Td}}, gmm::GMM{Ts}) where {Td,Ts}
187-
Ts == Td && return gmm
186+
function Base.convert(::Type{GMM{Td, Cd}}, gmm::GMM{Ts, Cs}) where {Td,Cd,Ts,Cs}
187+
(Ts == Td) && (Cs == Cd) && return gmm
188188
h = vcat(gmm.hist, History(string("Converted to ", Td)))
189189
w = map(Td, gmm.w)
190190
μ = map(Td, gmm.μ)
191-
gmmkind = kind(gmm)
192-
if gmmkind == :full
193-
Σ = map(eltype(FullCov{Td}), gmm.Σ)
194-
elseif gmmkind == :diag
195-
Σ = map(Td, gmm.Σ)
196-
else
197-
error("Unknown kind")
198-
end
199-
GMM(w, μ, Σ, h, gmm.nx)
191+
Σ = map(eltype(Cd), gmm.Σ)
192+
return GMM{Td,Cd}(w, μ, Σ, h, gmm.nx)
200193
end
201194
function Base.convert(::Type{VGMM{Td}}, vg::VGMM{Ts}) where {Td,Ts}
202195
Ts == Td && return vg

0 commit comments

Comments
 (0)