-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Colon doesn't subsume itself #99
Comments
My guess is that Is there cases you would want otherwise? |
This came about in TuringLang/DynamicPPL.jl#637, when trying to split a type unstable Can we assume that when calling |
There is a way to e.g. julia> x = ones(3)
3-element Vector{Float64}:
1.0
1.0
1.0
julia> vn1 = @varname(x[:], true)
x[:]
julia> x = ones(3, 3)
t3×3 Matrix{Float64}:
e 1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
julia> vn2 = @varname(x[:], true)
x[:]
julia> dump(vn1)
VarName{:x, Accessors.IndexLens{Tuple{AbstractPPL.ConcretizedSlice{Int64, Base.OneTo{Int64}}}}}
optic: Accessors.IndexLens{Tuple{AbstractPPL.ConcretizedSlice{Int64, Base.OneTo{Int64}}}}
indices: Tuple{AbstractPPL.ConcretizedSlice{Int64, Base.OneTo{Int64}}}
1: AbstractPPL.ConcretizedSlice{Int64, Base.OneTo{Int64}}
range: Base.OneTo{Int64}
stop: Int64 3
julia> dump(vn2)
VarName{:x, Accessors.IndexLens{Tuple{AbstractPPL.ConcretizedSlice{Int64, Base.OneTo{Int64}}}}}
optic: Accessors.IndexLens{Tuple{AbstractPPL.ConcretizedSlice{Int64, Base.OneTo{Int64}}}}
indices: Tuple{AbstractPPL.ConcretizedSlice{Int64, Base.OneTo{Int64}}}
1: AbstractPPL.ConcretizedSlice{Int64, Base.OneTo{Int64}}
range: Base.OneTo{Int64}
stop: Int64 9 ref: Line 524 in b9cd48b
Looking at Turing's julia> @macroexpand @model m(x) = x[:] ~ some_d()
quote
function m(__model__::Model, __varinfo__::AbstractVarInfo, __context__::AbstractPPL.AbstractContext, x::Any; )
#= REPL[15]:1 =#
begin
var"##dist#242" = some_d()
var"##vn#239" = (DynamicPPL.resolve_varnames)((VarName){:x}((AbstractPPL.concretize)((Accessors.opticcompose)((Accessors.IndexLens)((:,))), x)), var"##dist#242")
var"##isassumption#240" = begin
if (DynamicPPL.contextual_isassumption)(__context__, var"##vn#239")
if !((DynamicPPL.inargnames)(var"##vn#239", __model__)) || (DynamicPPL.inmissings)(var"##vn#239", __model__)
true
else
(Base.maybeview)(x, :) === missing
end
else
false
end
end
begin
#= /Users/xiandasun/.julia/packages/DynamicPPL/DvdZw/src/compiler.jl:579 =#
var"##retval#244" = if (DynamicPPL.contextual_isfixed)(__context__, var"##vn#239")
x[:] = (DynamicPPL.getfixed_nested)(__context__, var"##vn#239")
elseif var"##isassumption#240"
begin
(var"##value#243", __varinfo__) = (DynamicPPL.tilde_assume!!)(__context__, (DynamicPPL.unwrap_right_vn)((DynamicPPL.check_tilde_rhs)(var"##dist#242"), var"##vn#239")..., __varinfo__)
x = (Accessors.set)(x, (BangBang.AccessorsImpl.prefermutation)((Accessors.opticcompose)((Accessors.IndexLens)((:,)))), var"##value#243")
var"##value#243"
end
else
if !((DynamicPPL.inargnames)(var"##vn#239", __model__))
x[:] = (DynamicPPL.getconditioned_nested)(__context__, var"##vn#239")
end
(var"##value#241", __varinfo__) = (DynamicPPL.tilde_observe!!)(__context__, (DynamicPPL.check_tilde_rhs)(var"##dist#242"), (Base.maybeview)(x, :), var"##vn#239", __varinfo__)
var"##value#241"
end
#= /Users/xiandasun/.julia/packages/DynamicPPL/DvdZw/src/compiler.jl:580 =#
return (var"##retval#244", __varinfo__)
end
end
end
begin
$(Expr(:meta, :doc))
function m(x::Any; )
#= REPL[15]:1 =#
return (Model)(m, NamedTuple{(:x,)}((x,)); )
end
end
end there is a Is there a small example for this? |
Cool thanks, I didn't know concretization was a thing at all. The case I ran into came from using So is the answer then that for unconcretized |
I think so, or at least this might be the more correct thing to do |
Is there a reason why this is intentional?
The text was updated successfully, but these errors were encountered: