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

source
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) -> Type

Return 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, or nothing.

Returns

  • Tr::Type: The element type of the read.

Related

source
PortfolioOptimisers.panel_read_write! — Function
panel_read_write!(V::AbstractArray, msk::Option{<:AbstractArray{Bool}}, v::Option{<:Real}) -> nothing

Write 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

  1. Return at once when msk or v is nothing: there is no cell to write, or the policy keeps the stored value.
  2. Otherwise, for each false entry of msk, write v into the slab of V at that entry.

Arguments

  • V: The values of the read. It is changed in place.
  • msk: The mask whose false entries mark the cells to write, or nothing.
  • v: The policy value, or nothing.

Returns

  • nothing.

Related

source