VNT: Generalising PartialArrays
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia con src/varnamedtuple/getset.jl e src/varnamedtuple/partial_array.jl, seguendo templated_setindex!!, _getindex_optic, _haskey_optic, _setindex_optic!! e gli helper per la dimensione degli indici mostrati nello stack trace. Il lavoro è completato quando l’indicizzazione di Dict non fallisce più se usata in un modello e l’interfaccia delle strutture dati supportata e il relativo comportamento richiesto sono definiti chiaramente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
PartialArrays work fine ... as long as you're trying to represent an Array.
Other things that you can index into will break, Dicts for example. This is on current breaking; it would have worked on v0.39.
julia> using DynamicPPL, Distributions
Precompiling DynamicPPL...
1 dependency successfully precompiled in 5 seconds. 123 already precompiled.
julia> using DynamicPPL, Distributions
julia> @model function f()
x = Dict()
x["a"] ~ Normal()
end
f (generic function with 2 methods)
julia> f()()
ERROR: ArgumentError: Attempted to set a value with an index of a, but no template was provided for the array. For such an index, a template is needed to determine the shape and type of the array so that the indexed data can be stored correctly.
Stacktrace:
[1] largest_index(x::String)
@ DynamicPPL.VarNamedTuples ~/ppl/dppl/src/varnamedtuple/partial_array.jl:129
[2] map
@ ./tuple.jl:355 [inlined]
[3] get_maximum_size_from_indices(ix::String; kw::@Kwargs{})
@ DynamicPPL.VarNamedTuples ~/ppl/dppl/src/varnamedtuple/partial_array.jl:140
[4] get_maximum_size_from_indices(ix::String)
@ DynamicPPL.VarNamedTuples ~/ppl/dppl/src/varnamedtuple/partial_array.jl:138
[5] make_leaf_singleindex(value::VectorValue{…}, coptic::AbstractPPL.Index{…}, template::Dict{…})
@ DynamicPPL.VarNamedTuples ~/ppl/dppl/src/varnamedtuple/getset.jl:381
[6] make_leaf(value::VectorValue{…}, optic::AbstractPPL.Index{…}, template::Dict{…})
@ DynamicPPL.VarNamedTuples ~/ppl/dppl/src/varnamedtuple/getset.jl:336
[7] _setindex_optic!!(vnt::VarNamedTuple{…}, value::VectorValue{…}, optic::AbstractPPL.Property{…}, template::DynamicPPL.VarNamedTuples.SkipTemplate{…}; allow_new::Val{…})
@ DynamicPPL.VarNamedTuples ~/ppl/dppl/src/varnamedtuple/getset.jl:269
[8] _setindex_optic!!(vnt::VarNamedTuple{…}, value::VectorValue{…}, optic::AbstractPPL.Property{…}, template::DynamicPPL.VarNamedTuples.SkipTemplate{…})
@ DynamicPPL.VarNamedTuples ~/ppl/dppl/src/varnamedtuple/getset.jl:250
[9] templated_setindex!!(vnt::VarNamedTuple{…}, value::VectorValue{…}, vn::VarName{…}, template::Dict{…})
[...]
The nice thing about this, is that I believe we can fix this using a nice Julian multiple-dispatch thing. Look at the last call in the stack trace before I truncated it:
[9] templated_setindex!!(vnt::VarNamedTuple{…}, value::VectorValue{…}, vn::VarName{…}, template::Dict{…})
Contrary to what the error message (ArgumentError: Attempted to set a value with an index of a, but no template was provided for the array) claims, we do have the Dict template here. The problem is that templated_setindex!! doesn't actually know how to make use of the Dict template. I am pretty sure that in principle, all that is needed to make this work is to overload this method and make it cleverer so that it can do what it needs to do.
This is not unlike adding a new rule for an AD package.
For other behaviour to work correctly, we would probably also have to overload a series of other functions, namely _getindex_optic, _haskey_optic, _setindex_optic!!, etc. Now this seems like a faff. Why do this? I think it's good because it will allow us to:
- clean up some of the nasty code in
src/varnamedtuple/getset.jlthat is full of special cases, and instead separate each case into its own method signature - in turn that allows us to have much better understanding of what functions like
make_leafshould do, and thereby unit test them much more robustly - clearly communicate what functions must be implemented for a data structure to be implemented (for example, if we want to allow things like DataFrames, what do we need to overload)?
- (the big one) thereby clearly define what is supported and what is not supported in DynamicPPL: if a data type T implements the necessary interface (i.e. if it overloads these methods, and the result of calling these methods obeys certain properties that we can clearly express, then it is supported. Otherwise not.)
- Lingua principale
- Julia
- Stelle
- 291
- Fork
- 43
- Merge medio
- 1g 23h
- PR unite (30g)
- 15
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TuringLang/DynamicPPL.jl
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 64/100
TuringLang/DynamicPPL.jl#1499 ·
I maintainer di solito rispondono entro 2 giorni
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
TuringLang/DynamicPPL.jl#1480 ·
I maintainer di solito rispondono entro 2 giorni
-
Separate model-evaluation inputs from outputsForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertadata-structures enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
TuringLang/DynamicPPL.jl#1469 ·
I maintainer di solito rispondono entro 2 giorni
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
TuringLang/DynamicPPL.jl#1466 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
documentation
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
TuringLang/DynamicPPL.jl#1390 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di TuringLang/DynamicPPL.jl
Issue simili
-
Release CorleoneInverse as 0.1.1Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
SciML/Corleone.jl#200 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
JuliaAI/MLJTransforms.jl#120 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
exercism/julia#1205 · 3 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
SciML/OrdinaryDiffEq.jl#5175 ·
I maintainer di solito rispondono entro 1 giorno