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.
panel_field_values and feature_matrix derive the element type of their answer through this function. The type is derived from the two arguments, and never forced. A policy of nothing writes no cell, so it keeps T. An integer value keeps T too. The value converts to T only when it writes a cell, so T must hold it. A value of -1 in an unsigned type raises an InexactError there. Any other value, such as NaN or 0.5, needs a type that holds a fraction. It floats an integer T through float_if_integer and keeps every other T. A numeric Panel Field holds floating-point values, so the integer case is the codes of a CategoricalPanelField, whose natural type is an integer. 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}) -> nothing
panel_read_write!(V::AbstractArray{<:Any, 3}, msk::AbstractMatrix{Bool}, v::Real) -> nothingWrite the policy value v into every cell of V where the mask msk is false, in place.
panel_field_values writes its two policies through this function, and feature_matrix writes its placeholder. A mask with the shape of V marks one entry for each cell. The observed mask of a Panel Field is one, and so is the data mask of one column of a Feature Matrix. The active mask of a time-varying panel is observations × assets, and a tensor Panel Field is assets × labels × observations, so on a tensor Panel Field one false entry (t, i) covers every label of that observation and asset.
Algorithm
The method that Julia selects is the algorithm.
- Return at once when
mskorvisnothing. A mask ofnothingmarks no cell, and a policy ofnothingkeeps the stored value. - A mask of the shape of
V: writevinto each cell whose entry ofmskisfalse. - An array of rank three with a matrix mask: for each
falseentry(t, i)ofmsk, writevintoV[i, :, t].
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