juanfung / scpd

0 stars 0 forks source link

julia 0.7 updates for `CausalMixtures.jl` #1

Closed juanfung closed 5 years ago

juanfung commented 6 years ago

Update 2018-01-08: updates for julia 0.7 should also work for julia 1.0

Original code written for julia 0.4.

Major changes in julia 0.6 (current stable) to be incorporated:

new way

mutable struct MyType ...

old way

immutable IType ...

new way

struct IType ...

juanfung commented 5 years ago

This commit 1c48ac7ba67fd6c7e4d4d950b4f93a96fe5c5e22 imports package StatsModels and drops usage of package Debug (see https://github.com/juanfung/scpd/issues/2)

juanfung commented 5 years ago

Type declarations fixed by: 20221fc28395d7629c53dc94097d58350f5655a1

juanfung commented 5 years ago

TODO: typealias seems to be deprecated, with no alternative given in v0.7 (instead, this error: "syntax: extra token TypeAliasName after end of expression").

Documentation suggests aliasing via simple assignment, i.e., TypeAliasName = .... Check this works and update CausalMixtures.jl.

juanfung commented 5 years ago

typealias replaced by simple assignment = by 82a1cd82f1cb356ecb1d40b6017925e8169d790b

juanfung commented 5 years ago

After above commits, the following warnings and errors remain when loading CausalMixtures.jl:

┌ Warning: Deprecated syntax parametric method syntax sumbw{T <: Associative}(b::Base.ValueIterator{T},; i::Int64 = 1) around /home/juanfung/Dropbox/Projects/School choice/scpd/Analyze/CausalMixtures/src/CausalMixtures.jl:160. │ Use sumbw(b::Base.ValueIterator{T},; i::Int64 = 1) where T <: Associative instead. └ @ ~/Dropbox/Projects/School choice/scpd/Analyze/CausalMixtures/src/CausalMixtures.jl:160 WARNING: importing deprecated binding Base.Associative into CausalMixtures. WARNING: Base.Associative is deprecated, use AbstractDict instead. likely near /home/juanfung/Dropbox/Projects/School choice/scpd/Analyze/CausalMixtures/src/CausalMixtures.jl:159 WARNING: Base.Associative is deprecated, use AbstractDict instead. likely near /home/juanfung/Dropbox/Projects/School choice/scpd/Analyze/CausalMixtures/src/CausalMixtures.jl:159 WARNING: Base.Associative is deprecated, use AbstractDict instead. likely near /home/juanfung/Dropbox/Projects/School choice/scpd/Analyze/CausalMixtures/src/CausalMixtures.jl:159 WARNING: importing deprecated binding Base.LinSpace into CausalMixtures. WARNING: Base.LinSpace is deprecated, use LinRange instead. likely near /home/juanfung/Dropbox/Projects/School choice/scpd/Analyze/CausalMixtures/src/CausalMixtures.jl:296 WARNING: Base.LinSpace is deprecated, use LinRange instead. likely near /home/juanfung/Dropbox/Projects/School choice/scpd/Analyze/CausalMixtures/src/CausalMixtures.jl:296 WARNING: Base.LinSpace is deprecated, use LinRange instead. likely near /home/juanfung/Dropbox/Projects/School choice/scpd/Analyze/CausalMixtures/src/CausalMixtures.jl:296 ERROR: LoadError: cannot define function PPD; it already has a value

TODO:

juanfung commented 5 years ago

This commit fixes aliasing problem with PPD d5e8990aaf16ebfdf38c46f16da02e666cebaa91

Works as expected; ie, calling CausalMixtures.PPD() creates default instance of PosteriorPredictive

juanfung commented 5 years ago

This commit 4d6975aff74db5346b5bd364c953c8fd504a8dbd addresses deprecation warnings for use of Base.Associative, Base.LinSpace, and (not noted above) @printf. For the latter, must explicitly load module Printf.

juanfung commented 5 years ago

Now, all that remains:

julia> include("CausalMixtures.jl")

WARNING: replacing module CausalMixtures. ┌ Warning: Deprecated syntax parametric method syntax sumbw{T <: AbstractDict}(b::Base.ValueIterator{T},; i::Int64 = 1) around /home/juanfung/Dropbox/Projects/School choice/scpd/Analyze/CausalMixtures/src/CausalMixtures.jl:160. │ Use sumbw(b::Base.ValueIterator{T},; i::Int64 = 1) where T <: AbstractDict instead. └ @ ~/Dropbox/Projects/School choice/scpd/Analyze/CausalMixtures/src/CausalMixtures.jl:160 ┌ Warning: Deprecated syntax (j == 1)? at /home/juanfung/Dropbox/Projects/School choice/scpd/Analyze/CausalMixtures/src/sampler_functions.jl:412. │ Use (j == 1) ? instead. └ @ ~/Dropbox/Projects/School choice/scpd/Analyze/CausalMixtures/src/sampler_functions.jl:412 Main.CausalMixtures

juanfung commented 5 years ago

This commit 5b5eb3bd380381bc5cc91021a079d99a5cbb237b fixes remaining deprecation warnings!

julia> include("CausalMixtures.jl")

WARNING: replacing module CausalMixtures. Main.CausalMixtures

juanfung commented 5 years ago

Closing issue because loading module CausalMixtures.jl in julia v0.7 does not cause any errors or deprecation warnings.

TODO: Check the code works on toy example, causal-sims.jl.