# Immutable deprecation fix in BayesianDataFusion

**URL:** <https://discourse.julialang.org/t/immutable-deprecation-fix-in-bayesiandatafusion/8182>\
**Category:** General Usage\
**Tags:** question, package\
**Created:** [January 5, 2018, 3:10pm UTC](https://discourse.julialang.org/t/immutable-deprecation-fix-in-bayesiandatafusion/8182 "2018-01-05T15:10:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![spinkney](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@spinkney](https://discourse.julialang.org/u/spinkney)\
**Post date:** [January 5, 2018, 3:10pm UTC](https://discourse.julialang.org/t/immutable-deprecation-fix-in-bayesiandatafusion/8182/1 "2018-01-05T15:10:47Z")

</div>

I’m a Julia noob and I’m trying to get [BayesianDataFusion.jl](https://github.com/jaak-s/BayesianDataFusion.jl) to work with 0.6. I found that the issue I have is related to the deprecation of `immutable` to using `struct`. I created an attempt at a fix but I have zero confidence in it. I also opened an issue on the package’s github page but I don’t think the maintainer will get to it soon [issue 9](https://github.com/jaak-s/BayesianDataFusion.jl/issues/9). You can see below the original code and my fix. Does anyone have suggestions on a better attempt?

### Deprecated 0.5 code

```julia
using Compat
using Distributions
using PDMats

import Base.LinAlg: Cholesky

immutable NormalWishart <: Distribution
    dim::Int
    zeromean::Bool
    mu::Vector{Float64}
    kappa::Float64
    #Tchol::Cholesky{Float64} # Precision matrix (well, sqrt of one)
    T::Matrix{Float64}
    nu::Float64

    function NormalWishart(mu::Vector{Float64}, kappa::Real,
                                  T::Matrix{Float64}, nu::Real)
        # Probably should put some error checking in here
        d = length(mu)
        zmean::Bool = true
        for i = 1:d
            if mu[i] != 0.
                zmean = false
                break
            end
        end
        @compat new(d, zmean, mu, Float64(kappa), full(Symmetric(T)), Float64(nu))
    end
end

function NormalWishart(mu::Vector{Float64}, kappa::Real,
                       T::AbstractMatrix{Float64}, nu::Real)
    NormalWishart(mu, kappa, full(T), nu)
end

import Distributions.rand

function rand(nw::NormalWishart)
    Lam = rand(Wishart(nw.nu, nw.T))
    mu = rand(MvNormal(nw.mu, full(inv(Symmetric(Lam))) ./ nw.kappa))
    return (mu, Lam)
end

```

### Attempted fix for 0.6

```julia
struct NormalWishart{I<:Int, B<:Bool, Num<:Real, ST<:AbstractPDMat} <: ContinuousMatrixDistribution
    dim::I
    zeromean::B
    mu::Vector{Num}
    kappa::Num
    #Tchol::Cholesky{Num} # Precision matrix (well, sqrt of one)
    T::ST
    nu::Num
end

```

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 5, 2018, 3:30pm UTC](https://discourse.julialang.org/t/immutable-deprecation-fix-in-bayesiandatafusion/8182/2 "2018-01-05T15:30:55Z")

</div>

> [@spinkney](#):
>
> I don’t think the maintainer will get to it soon

Why do you think this is the case?

However, if you have a strong reason to believe this, your best bet is to

1. fork the package on github,
2. clone and branch (in `git`),
3. make the change, and see if CI on Travis works. You will need to enable CI for 0.6 in `.travis.yml`.

Then you can submit this as a PR, or if the maintainer is unresponsive, you may consider adopting the package if you find it useful.

See [the manual](https://docs.julialang.org/en/latest/manual/packages/#Making-changes-to-an-existing-package-1) for more guidance.

---

<div class="post-metadata">

**Author:** ![spinkney](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@spinkney](https://discourse.julialang.org/u/spinkney)\
**Post date:** [January 5, 2018, 3:59pm UTC](https://discourse.julialang.org/t/immutable-deprecation-fix-in-bayesiandatafusion/8182/3 "2018-01-05T15:59:06Z")

</div>

Thanks, I’ll test with Travis. I’m not sure the maintainer will get to it because the Python implementation has been actively worked on in the past 2 months but the Julia source has been over a year since it’s been worked on.
