Skip to content
Snippets Groups Projects
Verified Commit e53f5eb3 authored by Michiel Cottaar's avatar Michiel Cottaar
Browse files

do not return index with get_children_blocks

parent 25df3dfb
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@ abstract type GradientBlock <: BuildingBlock end
Parent type for all types combining one or more pulses/gradients.
Required methods:
- [`get_children_blocks`](@ref)(container): return all the [`BuildingBlock`](@ref) objects includes in this container with their indices.
- [`get_children_blocks`](@ref)(container): return all the [`BuildingBlock`](@ref) objects includes in this container.
- [`start_time`](@ref)(container, index): returns the starting time of the child corresponding to `index` relative to the start of the `container` in ms.
- `Base.getindex`(container, index): get child [`BuildingBlock`](@ref) corresponding to `index`.
"""
......@@ -43,9 +43,9 @@ abstract type ContainerBlock <: BuildingBlock end
"""
get_children_blocks(container)
Return all the [`BuildingBlock`](@ref) objects includes in this container with their indices.
Return all the [`BuildingBlock`](@ref) objects includes in this container.
"""
get_children_blocks(bb::BuildingBlock) = [(i, bb[i]) for i in get_children_indices(bb)]
get_children_blocks(bb::BuildingBlock) = [bb[i] for i in get_children_indices(bb)]
"""
get_children_indices(container)
......@@ -53,7 +53,6 @@ get_children_blocks(bb::BuildingBlock) = [(i, bb[i]) for i in get_children_indic
Return the indices of all the children in a [`ContainerBlock`](@ref).
This needs to be defined for every [`ContainerBlock`](@ref).
It is not part of the external API, but is used by [`get_children_blocks`](@ref)
"""
function get_children_indices end
......@@ -350,7 +349,7 @@ function scanner_constraints!(building_block::BuildingBlock, scanner::Scanner, f
rethrow()
end
if building_block isa ContainerBlock
for (_, child_block) in get_children_blocks(building_block)
for child_block in get_children_blocks(building_block)
scanner_constraints!(child_block, scanner, func)
end
end
......
module Pathways
import LinearAlgebra: norm, tr
import StaticArrays: SVector, SMatrix
import ..BuildingBlocks: BuildingBlock, GradientBlock, RFPulseBlock, ContainerBlock, get_children_blocks
import ..BuildingBlocks: BuildingBlock, GradientBlock, RFPulseBlock, ContainerBlock, get_children_indices
import ..Sequences: Sequence
import ..Variables: qvec, qval, bmat_gradient, VariableType, start_time, effective_time, duration, qval_square
import ..Wait: WaitBlock
......@@ -288,7 +288,8 @@ function walk_pathway!(pulse::RFPulseBlock, walker::PathwayWalker, pulse_effects
end
function walk_pathway!(container::ContainerBlock, walker::PathwayWalker, pulse_effects::Vector{Symbol}, nreadout::Ref{Int}, block_start_time::VariableType)
for (index, child) in get_children_blocks(container)
for index in get_children_indices(container)
child = contrainer[index]
if walk_pathway!(child, walker, pulse_effects, nreadout, block_start_time + start_time(container, index))
return true
end
......
......@@ -6,7 +6,7 @@ import Printf: @sprintf
import JuMP: @constraint
import ...BuildSequences: global_model
import ...Variables: variables, start_time, duration, VariableType, get_free_variable, TR, end_time
import ...BuildingBlocks: BuildingBlock, ContainerBlock, to_block, get_children_indices, fixed, BuildingBlockPrinter, _robust_value, get_children_blocks, fixed
import ...BuildingBlocks: BuildingBlock, ContainerBlock, to_block, get_children_indices, fixed, BuildingBlockPrinter, _robust_value, fixed
"""
Sequence(building_blocks...; TR=nothing)
......@@ -75,7 +75,8 @@ function Base.show(io::IO, printer::BuildingBlockPrinter{<:Sequence})
end
print(io, "):")
for (child_index, child_block) in get_children_blocks(seq)
for child_index in get_children_indices(seq)
child_block = seq[child_index]
child_printer = BuildingBlockPrinter(
child_block,
isnothing(printer.start_time) ? nothing : _robust_value(start_time(seq, child_index) + printer.start_time),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment