sometimes dicts are passed to constructors as `Dict{String,Any}`
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Beginnen Sie damit, das Julia MWE auszuführen und den Konstruktoraufruf in StructTypes.jl:267 parallel zum JSON3-Lesepfad in structs.jl:342 nachzuverfolgen. Vergleichen Sie, wie Outer und Inner Dictionary-Schlüssel erhalten, und überprüfen Sie anschließend, dass der gemeldete Fall der verschachtelten Konstruktion keine separaten Konstruktoren für Dict{String,Any} und Dict{Symbol,Any} mehr erfordert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
I started out thinking this only happened for nested types, but as I set out to make a MWE, I got even more confused. Here it is
using JSON3, StructTypes
struct Inner
a::Int
end
Inner(dct) = Inner(dct[:a])
StructTypes.StructType(::Type{Inner}) = StructTypes.DictType()
struct Outer
I::Inner
end
Outer(dct) = Outer(dct[:I])
StructTypes.StructType(::Type{Outer}) = StructTypes.DictType()
json = JSON3.write(Dict(:I=>Dict(:a=>1)))
JSON3.read(json, Outer)
gives me
ERROR: LoadError: KeyError: key :I not found
Stacktrace:
[1] getindex at ./dict.jl:467 [inlined]
[2] Outer(::Dict{String,Any}) at /home/expandingman/src/scrap.jl:13 (repeats 2 times)
[3] #construct#2 at /home/expandingman/.julia/packages/StructTypes/CpLmq/src/StructTypes.jl:267 [in
lined]
[4] construct at /home/expandingman/.julia/packages/StructTypes/CpLmq/src/StructTypes.jl:267 [inlin
ed]
[5] read(::StructTypes.DictType, ::Base.CodeUnits{UInt8,String}, ::Int64, ::Int64, ::UInt8, ::Type{
Outer}, ::Type{Symbol}, ::Type{Any}; kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),
Tuple{}}}) at /home/expandingman/.julia/packages/JSON3/LtYDK/src/structs.jl:342
[6] read at /home/expandingman/.julia/packages/JSON3/LtYDK/src/structs.jl:285 [inlined]
[7] #read#30 at /home/expandingman/.julia/packages/JSON3/LtYDK/src/structs.jl:279 [inlined]
[8] read at /home/expandingman/.julia/packages/JSON3/LtYDK/src/structs.jl:279 [inlined]
[9] read(::String, ::Type{Outer}; kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tu
ple{}}}) at /home/expandingman/.julia/packages/JSON3/LtYDK/src/structs.jl:34
[10] read(::String, ::Type{Outer}) at /home/expandingman/.julia/packages/JSON3/LtYDK/src/structs.jl
:33
[11] top-level scope at /home/expandingman/src/scrap.jl:19
[12] include(::String) at ./client.jl:457
[13] top-level scope at REPL[3]:1
in expression starting at /home/expandingman/src/scrap.jl:19
Usually I would hit this kind of error with Inner where it would try to construct from Dict("a"=>1), I don't know why I suddenly have this problem with the outer one.
As a workaround, it seems that right now one has to define constructors for both Dict{String,Any} and Dict{Symbol,Any} which seems wrong.
- Vorherrschende Sprache
- Julia
- Sterne
- 86
- Forks
- 22
- Ø Merge
- 4 T. 42 Min.
- Gemergte PRs (30 T.)
- 6
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus JuliaData/StructTypes.jl
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
JuliaData/StructTypes.jl#104 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 30/100
JuliaData/StructTypes.jl#96 · 1 Kommentar ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
JuliaData/StructTypes.jl#87 · 5 Kommentare ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
JuliaData/StructTypes.jl#76 ·
-
Default to OrderedStruct for NamedTuples?Evtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
JuliaData/StructTypes.jl#68 · 3 Kommentare ·
Alle Issues in JuliaData/StructTypes.jl
Ähnliche Issues
-
`ShallowWaterModel` allocates ~9 KiB per grid point per RK3 stage on the CPUEvtl. vergeben @ali-ramadhan hat das heute übernommen. Offenperformance 🏍️
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
CliMA/Oceananigans.jl#6421 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
JuliaQUBO/QUBOLib.jl#105 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
NCAR/musica#1118 · 1 Kommentar · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
`AMSGrad` state starts at `epsilon` instead of zero, so zero gradients move parameters and small gradients are dampedEvtl. vergeben @parth-patel010 hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
FluxML/Optimisers.jl#247 · 1 Kommentar ·
-
README should say that row and column order must matchEvtl. vergeben @SAUMYARSH hat das heute übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 84/100