Make type-inferrable
Add function for converting to dict with string keys
Convert to dict with string keys
Avoid now-unnecessary conversion
Test converttoconstant_dataset
Test dims matched to namedtuple keys
Increment version number
Showing 3 of 6 files from the diff.
src/mcmcchains.jl
changed.
src/dataset.jl
changed.
src/utils.jl
changed.
Other files ignored by Codecov
@@ -257,9 +257,8 @@
Loading
257 | 257 | :predictions_constant_data => predictions_constant_data, |
|
258 | 258 | ] |
|
259 | 259 | group_data === nothing && continue |
|
260 | - | group_dict = convert(Dict, group_data) |
|
261 | 260 | group_dataset = |
|
262 | - | convert_to_constant_dataset(group_dict; library = library, kwargs...) |
|
261 | + | convert_to_constant_dataset(group_data; library = library, kwargs...) |
|
263 | 262 | concat!(all_idata, InferenceData(; group => group_dataset)) |
|
264 | 263 | end |
|
265 | 264 |
@@ -28,7 +28,7 @@
Loading
28 | 28 | end |
|
29 | 29 | end |
|
30 | 30 | ||
31 | - | Dataset(; kwargs...) = xarray.Dataset(; kwargs...) |
|
31 | + | Dataset(; kwargs...) = Dataset(xarray.Dataset(; kwargs...)) |
|
32 | 32 | @inline Dataset(data::Dataset) = data |
|
33 | 33 | ||
34 | 34 | @inline PyObject(data::Dataset) = getfield(data, :o) |
@@ -116,25 +116,27 @@
Loading
116 | 116 | library = nothing, |
|
117 | 117 | attrs = nothing, |
|
118 | 118 | ) |
|
119 | - | obj = convert(Dict, obj) |
|
120 | 119 | base = arviz.data.base |
|
121 | - | coords = coords === nothing ? Dict{String,Vector}() : coords |
|
122 | - | dims = dims === nothing ? Dict{String,Vector{String}}() : dims |
|
123 | 120 | ||
124 | - | data = Dict{String,Any}() |
|
121 | + | obj = _asstringkeydict(obj) |
|
122 | + | coords = _asstringkeydict(coords) |
|
123 | + | dims = _asstringkeydict(dims) |
|
124 | + | attrs = _asstringkeydict(attrs) |
|
125 | + | ||
126 | + | data = Dict{String,PyObject}() |
|
125 | 127 | for (key, vals) in obj |
|
126 | 128 | vals = _asarray(vals) |
|
127 | 129 | val_dims = get(dims, key, nothing) |
|
128 | 130 | (val_dims, val_coords) = |
|
129 | 131 | base.generate_dims_coords(size(vals), key; dims = val_dims, coords = coords) |
|
130 | - | data[string(key)] = xarray.DataArray(vals; dims = val_dims, coords = val_coords) |
|
132 | + | data[key] = xarray.DataArray(vals; dims = val_dims, coords = val_coords) |
|
131 | 133 | end |
|
132 | 134 | ||
133 | 135 | default_attrs = base.make_attrs() |
|
134 | 136 | if library !== nothing |
|
135 | 137 | default_attrs = merge(default_attrs, Dict("inference_library" => string(library))) |
|
136 | 138 | end |
|
137 | - | attrs = attrs === nothing ? default_attrs : merge(default_attrs, attrs) |
|
139 | + | attrs = merge(default_attrs, attrs) |
|
138 | 140 | return Dataset(data_vars = data, coords = coords, attrs = attrs) |
|
139 | 141 | end |
|
140 | 142 |
@@ -175,6 +175,10 @@
Loading
175 | 175 | @inline _asarray(x) = [x] |
|
176 | 176 | @inline _asarray(x::AbstractArray) = x |
|
177 | 177 | ||
178 | + | _asstringkeydict(x) = Dict(String(k) => v for (k, v) in pairs(x)) |
|
179 | + | _asstringkeydict(x::Dict{String}) = x |
|
180 | + | _asstringkeydict(::Nothing) = Dict{String,Any}() |
|
181 | + | ||
178 | 182 | function enforce_stat_types(dict) |
|
179 | 183 | return Dict(k => get(sample_stats_types, k, eltype(v)).(v) for (k, v) in dict) |
|
180 | 184 | end |
Files | Coverage |
---|---|
src | 88.13% |
Project Totals (13 files) | 88.13% |
323029585
322959006
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.