API reference
General reference
SpectralFitting.Reflection._add_composite_info!
— MethodUsed exclusively to do recursive CompositeModel
parsing.
SpectralFitting.Reflection.add_objective_reduction!
— Methodadd_objective_reduction!(ra::CompositeAggregation, op::Symbol)
Reduces the current objective count and applies the reduction operation op
to them. For example, if op
is :+
, and the objective count is 3, then after this function has been called the objective count will be 2 and the reduction expression
@. flux2 = flux2 + flux3
will have been added to the CompositeAggregation
.
SpectralFitting.Reflection.assemble_composite_model_call
— Methodassemble_composite_model_call(model::Type{<:CompositeModel}, parameters::Type{<:AbstractVector})
Assemble the full composite model call, with objective unpacking via assemble_objective_unpack
, closure and parameter assignments, model invocation, and objective reduction. Uses assemble_fast_call
to put the final function body together.
SpectralFitting.Reflection.assemble_objective_unpack
— Methodassemble_objective_unpack(N)
Assembles the statements for unpacking the objective cache into a number of views. Assembles the part of the model call that looks like:
objective1 = view(objectives, :, 1), objective2 = ...
for N
objectives slices.
SpectralFitting.Reflection.get_info
— Methodget_info(model::Type{<:AbstractSpectralModel}, lens::Lens)
Returns a ModelInfo
struct for a given model.
SpectralFitting.Reflection.make_constructor
— Methodmake_constructor(model::Type{<:AbstractSpectralModel}, closures::Vector, params::Vector, T::Type)
Create a constructor expression for the model. Should return something similar to
:(PowerLaw{T}(arg1, arg2, arg3)))
unpacking the closures
and params
vectors in the appropriate places.
SpectralFitting.Reflection.parameter_lenses
— Methodparameter_lenses(::Type{<:AbstractSpectralModel}, info::ModelInfo)
Return a vector of lenses Lens
that refer to each of the models parameters. The lenses should be relative to model.lens
.
SpectralFitting.Reflection.set_objective_count!
— Methodset_objective_count!(a::CompositeAggregation, o::Int)
Set the objective count to a specific value. Will bump the maximum objective count if the new value exceeds the current maximum.
SpectralFitting.Reflection.CompositeModelInfo
— Typestruct CompositeModelInfo
"The parameter symbols of the model with the respective lens to the actual parameter."
parameter_symbols::Vector{Pair{Symbol,Lens}}
"Each model assigned to a unique symbol."
models::Vector{Pair{Symbol,ModelInfo}}
"The expression representing the folding operations of this composite model."
model_expression::Expr
"Constructor and objective folding expressions, used in generating the invocation call."
expressions::Vector{Expr}
"The maximum number of objective caches this model will need."
maximum_objective_cache_count::Int
"How many objective caches are currently active."
objective_cache_count::Int
end
The composite equivalent of ModelInfo
, augmented to track the model symbol (a1
, m3
, etc.), and the model parameters (K_1
, a_3
, etc.)
SpectralFitting.Reflection.ModelInfo
— Typestruct ModelInfo
"All parameter symbols for the model."
symbols::Vector{Symbol}
"Unique symbols generated for the parameter assignment when buildin the function call."
generated_symbols::Vector{Symbol}
"Additional closure parameters that need to be handled when invoking the model."
closure_symbols::Vector{Symbol}
"Unique closure generated symbols."
generated_closure_symbols::Vector{Symbol}
"The lens that takes you to this model from some parent."
lens::Lens
"The model type itself."
model::Type
end
All models are parsed into a ModelInfo
struct relative to their parent (in the case of composite models).
The symbols field contains all of the model parameter symbols as they are in the structure, not as they have been generated. Recall when the invocation expressions are generated, we create anonymous paramter names to avoid conflicts. These are the generated_symbols
instead.