Skip to content

Commit 1144aef

Browse files
committed
Bump version to 0.3.4 and improve plan handling for vectors of parameters
1 parent 2c6fa81 commit 1144aef

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "AbstractImageReconstruction"
22
uuid = "a4b4fdbf-6459-4ec9-990d-77e1fa24a91b"
33
authors = ["nHackel <[email protected]> and contributors"]
4-
version = "0.3.3"
4+
version = "0.3.4"
55

66
[deps]
77
LRUCache = "8ac3fa9e-de4c-5943-b1dc-09c6b5f20637"

src/RecoPlans/RecoPlans.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ validvalue(plan, ::Type{T}, value::RecoPlan{<:T}) where T = true
9696
validvalue(plan, t::UnionAll, ::RecoPlan{T}) where T = T <: t || T <: Base.typename(t).wrapper # Last case doesnt work for Union{...} that is a UnionAll, such as ProcessCache Unio
9797
validvalue(plan, t::Type{Union}, value) = validvalue(plan, t.a, value) || validvalue(plan, t.b, value)
9898
validvalue(plan, t, value) = false
99+
validvalue(plan, ::Type{arrT}, value::AbstractArray) where {T, arrT <: AbstractArray{T}} = all(x -> validvalue(plan, T, x), value)
99100

100101
#X <: t || X <: RecoPlan{<:t} || ismissing(x)
101102

@@ -111,7 +112,7 @@ end
111112
export setAll!
112113
function setAll!(plan::RecoPlan{T}, name::Symbol, x) where {T<:AbstractImageReconstructionParameters}
113114
fields = getfield(plan, :values)
114-
nestedPlans = filter(entry -> isa(last(entry), RecoPlan), fields)
115+
nestedPlans = filter(entry -> isa(last(entry), RecoPlan) || isa(last(entry), AbstractArray{<:RecoPlan}), fields)
115116
for (key, nested) in nestedPlans
116117
key != name && setAll!(nested, name, x)
117118
end
@@ -123,6 +124,7 @@ function setAll!(plan::RecoPlan{T}, name::Symbol, x) where {T<:AbstractImageReco
123124
end
124125
end
125126
end
127+
setAll!(plans::AbstractArray{<:RecoPlan}, name::Symbol, x) = foreach(p -> setAll!(p, name, x), plans)
126128
setAll!(plan::RecoPlan{<:AbstractImageReconstructionAlgorithm}, name::Symbol, x) = setAll!(plan.parameter, name, x)
127129
function setAll!(plan; kwargs...)
128130
for key in keys(kwargs)
@@ -181,13 +183,14 @@ Base.ismissing(plan::RecoPlan, name::Symbol) = ismissing(getfield(plan, :values)
181183
export build
182184
function build(plan::RecoPlan{T}) where {T<:AbstractImageReconstructionParameters}
183185
fields = copy(getfield(plan, :values))
184-
nestedPlans = filter(entry -> isa(last(entry), RecoPlan), fields)
186+
nestedPlans = filter(entry -> isa(last(entry), RecoPlan) || isa(last(entry), AbstractArray{<:RecoPlan}), fields)
185187
for (name, nested) in nestedPlans
186188
fields[name] = build(nested)
187189
end
188190
fields = filter(entry -> !ismissing(last(entry)), fields)
189191
return T(;fields...)
190192
end
193+
build(plans::AbstractArray{<:RecoPlan}) = map(build, plans)
191194
function build(plan::RecoPlan{T}) where {T<:AbstractImageReconstructionAlgorithm}
192195
parameter = build(plan[:parameter])
193196
return T(parameter)

src/RecoPlans/Serialization.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ function loadPlan!(plan::RecoPlan{T}, dict::Dict{String, Any}, modDict) where {T
9999
if t <: AbstractImageReconstructionAlgorithm || t <: AbstractImageReconstructionParameters
100100
param = loadPlan!(dict[key], modDict)
101101
parent!(param, plan)
102-
103-
if param isa RecoPlan{ProcessResultCache}
104-
end
102+
elseif t <: Vector{<:AbstractImageReconstructionAlgorithm} || t <: Vector{<:AbstractImageReconstructionParameters}
103+
param = map(x-> loadPlan!(x, modDict), dict[key])
104+
foreach(p -> parent!(p, plan), param)
105105
else
106106
param = loadPlanValue(T, name, t, dict[key], modDict)
107107
end

0 commit comments

Comments
 (0)