Panel field values: private API
Functions
PortfolioOptimisers.panel_field_array — Function
panel_field_array(f::NumericPanelField) -> AbstractArray{<:Real}
panel_field_array(f::CategoricalPanelField) -> AbstractArray{<:Integer}
panel_field_array(f::TensorPanelField) -> AbstractArray{<:Real}Return the array that holds the stored cells of one Panel Field.
A numeric and a tensor Panel Field store their values in vals, and a categorical Panel Field stores integer codes over its levels in codes. panel_field_values reads each kind through this function, so it applies one rule to all three.
Algorithm
The method that Julia selects is the algorithm.
Arguments
f: The Panel Field.
Returns
A::AbstractArray: The stored array of the Panel Field, not a copy.
Related
PortfolioOptimisers.panel_read_eltype — Function
panel_read_eltype(::Type{T}, v::Nothing) -> Type
panel_read_eltype(::Type{T}, v::Integer) -> Type
panel_read_eltype(::Type{T}, v::Real) -> TypeReturn the element type that holds the stored type T and the policy value v of a read.
The type is derived from the two arguments, and never forced. A policy of nothing writes no cell, and an integer value fits every numeric type, so both keep T. Any other value, such as NaN or 0.5, needs a type that holds a fraction, so it floats an integer T through float_if_integer and keeps every other T. A Float32 field read with NaN stays Float32.
Algorithm
The method that Julia selects is the algorithm.
Arguments
T: The element type of the stored array.v: The policy value, ornothing.
Returns
Tr::Type: The element type of the read.
Related
PortfolioOptimisers.panel_read_write! — Function
panel_read_write!(V::AbstractArray, msk::Option{<:AbstractArray{Bool}}, v::Option{<:Real}) -> nothingWrite the policy value v into every cell of V where the mask msk is false, in place.
msk covers the leading axes of V. An observed mask has the shape of V, so a cell is one entry. The active mask of a time-varying panel is observations × assets, so on a tensor Panel Field one false entry covers every label of that observation and asset.
Algorithm
- Return at once when
mskorvisnothing: there is no cell to write, or the policy keeps the stored value. - Otherwise, for each
falseentry ofmsk, writevinto the slab ofVat that entry.
Arguments
V: The values of the read. It is changed in place.msk: The mask whosefalseentries mark the cells to write, ornothing.v: The policy value, ornothing.
Returns
nothing.
Related