juanfung / scpd

0 stars 0 forks source link

`ifelse` function cannot be used to perform element-wise comparisons for vectors #11

Closed juanfung closed 5 years ago

juanfung commented 5 years ago

For v0.7+.

Eg, consider the following (line 98 in causal-hedonic.jl)

d_obs = ifelse( d_star .> 0, 1, 0 )

This throws the following error:

ERROR: TypeError: non-boolean (BitArray{1}) used in boolean context Stacktrace: [1] top-level scope at none:0

The following works: d_obs = [ di > 0 ? 1 : 0 for di in d_star ].

TODO:

juanfung commented 5 years ago

Trying to call dpm_init() via causal-sims.jl, get the following related error:

ERROR: TypeError: non-boolean (BitArray{1}) used in boolean context Stacktrace: [1] #dpm_init#60(::Bool, ::Function, ::CausalMixtures.RawData, ::InputPriors, ::InputParams) at /home/juanfung/Dropbox/Projects/School choice/scpd/Analyze/CausalMixtures/src/dpm_init.jl:82 [2] dpm_init(::CausalMixtures.RawData, ::InputPriors, ::InputParams) at /home/juanfung/Dropbox/Projects/School choice/scpd/Analyze/CausalMixtures/src/dpm_init.jl:35 [3] top-level scope at util.jl:156

The culprit is line 82 of dpm_init.jl:

    ## truncated normal support for latent data
    lower = ifelse( d .== 1,  0 : -Inf )
    upper = ifelse( d .== 1, Inf : 0 )

Should be:

    ## truncated normal support for latent data
    lower = [ di == 1 ?  0 : -Inf for di in d ]
    upper = [ di == 1 ? Inf : 0 for di in d ]
juanfung commented 5 years ago

The dpm_init() issue fixed by feccfabece12ae1d693ae0e0b8ce6281f1be1ec5

juanfung commented 5 years ago

Should be fixed, but leaving open for now.

juanfung commented 5 years ago

This issue seems to be resolved.