Pretty show: private API
The types of PortfolioOptimisers.jl hold many fields. The functions below print them one field per line, with the fields of a nested type indented under it. By default the printout hides a field that holds nothing, and this documentation shows it. set_show_nothing_fields! turns those fields on or off, and a type can overload show_fields to hide a field of its own choice.
PortfolioOptimisers.@define_pretty_show — Macro
@define_pretty_show(T, flag::Bool = true)Defines a Base.show method for T that prints the type name and one aligned line per field.
A field whose value also has a pretty show prints under its parent with an indent. A field of that kind that is too tall prints as Name ⋯. The budget that compact_show_budget reads sets the height at which a nested field collapses, and set_compact_show! sets the budget. The method prints the fields that pretty_show_fields resolves. The default of SHOW_NOTHING_FIELDS hides a field that holds nothing, and a type hides a field of its own choice through show_fields.
Algorithm
The macro emits two definitions. Steps 3 to 9 are the body of the Base.show method that it emits.
When
flagistrue, definehas_pretty_show_method(::T)::Bool = true. The method annotates its return type, as do the four methods thathas_pretty_show_methoddeclares by hand.Define
Base.show(io::IO, obj::T).Read
fields, the field names thatpretty_show_fieldsresolves forobj. Whenfieldsis empty, printT()and return. A type with no field reaches this step, and so does a type whose every field is hidden.When the
IOcontext sets:compactor:multiline, print the type name alone and return.Print the wrapper name of the type, then compute
padding, the length of the longest field name plus two.For each field in declaration order, read
valwithgetproperty, so that a property a rule of@forward_propertiesswaps prints the swapped value.Choose the connector
sym1. It is┴for the last printed line, and┼for each other line. The last printed line is the last field offields, so a hidden field never gets the┴. A nested value whose own resolved field list is empty prints on one line, so it also gets┴.Print the field name, right-aligned to
padding.Print the rest of the line from
val, through the first branch that matches it.nothingprints asnothing.- A value that has a pretty-show method renders into a buffer, and the lines of the buffer are
alglines. When more thancompact_show_budget(io)lines are not empty, print the wrapper name of the value and⋯. Otherwise print the first line after the connector, and indent the other lines under│. - A non-empty vector whose every element has a pretty-show method prints the summary from
pretty_show_vector_summary. The lines frompretty_show_vector_bodyfollow, each with an indent under│. - A matrix prints its size and its type.
- A vector of more than six entries, or a vector of arrays, prints its length and its type.
- A
DataTypeprintsDataType, which is its type, and then the wrapper name of the value. A parametrised type thus shows the wrapper that it instantiates, andVector{Float64}prints asDataType: Array. - Each other value prints its type and
repr(val).
Arguments
T: The type for which to define the pretty-printing method.flag::Bool = true: Whentrue, the macro also defineshas_pretty_show_method(::T) = true. A parent reads that method to find thatTprints through thisshow. Passfalsefor a type that its parent must print withrepr.
Returns
- Defines a
Base.show(io::IO, obj::T)method for the given type.
Related
PortfolioOptimisers.show_fields — Function
show_fields(obj) -> NTuple{17, Symbol}
Name the fields of obj that @define_pretty_show can print, in declaration order.
The default method returns every declared field. A type that hides one of its fields overloads this method for itself and returns the other fields. The overload gets the instance, so it can hide a field always or only for some values. A partial-fit cache holds the state of an incremental fit and not configuration, so its type always hides it. The moment estimators hide an optional cvg only when it is nothing. The caller did not select that option, so it is not part of the configuration. A field added in this way changes no rendered docstring.
This method selects fields by type, and SHOW_NOTHING_FIELDS selects them by configuration. pretty_show_fields combines the two, and a per-name entry of the configuration overrides this method in both directions.
Arguments
obj: The value to print.
Returns
fields: The field names that the method can print, as a tuple or a vector ofSymbol.
Related
show_fields(
est::Union{MissingDataFilter, PriceGapFill, PricesToReturns}
) -> Tuple{Vararg{Symbol}}
Lists the fields that the display of a data step shows.
The display shows cache only when the step keeps a state, so a step that has folded no block shows no cache line.
Returns
fns::Tuple: The names of the fields to show.
Related
show_fields(
me::SimpleExpectedReturns
) -> Union{Tuple{Symbol}, Tuple{Symbol, Symbol}}
Renders every field of a SimpleExpectedReturns except cache, and cvg only where a policy is set.
A cache holds the state of an incremental fit. That state is not part of the configuration, and it prints under the estimator at each site that renders the estimator. Set set_show_nothing_fields!(:SimpleExpectedReturns, true) to render it. The method reads cvg from the instance and not from the type, because an option that the caller did not set is not part of the configuration that the caller chose. An estimator whose cvg is nothing renders as it did before the field existed. An estimator that holds a CoveragePolicy renders it.
Arguments
me: The expected returns estimator. The method reads only itscvgfield.
Returns
fields::Tuple: The field names to render, which is(:w,)with no policy and(:w, :cvg)with one.
Related
show_fields(_::GeneralCovariance) -> Tuple{Symbol, Symbol}
Renders every field of a GeneralCovariance except cache.
A cache holds the state of an incremental fit. That state is not part of the configuration, and it prints under the estimator at each site that renders the estimator. Set set_show_nothing_fields!(:GeneralCovariance, true) to render it.
Arguments
::GeneralCovariance: The covariance estimator. The method reads only its type.
Returns
fields::Tuple: The field names to render, which is(:ce, :w).
Related
show_fields(
ce::Covariance
) -> Union{NTuple{4, Symbol}, NTuple{5, Symbol}}
Renders every field of a Covariance except cache, and cvg only where a policy is set.
A cache holds the state of an incremental fit. That state is not part of the configuration, and it prints under the estimator at each site that renders the estimator. Set set_show_nothing_fields!(:Covariance, true) to render it. The method reads cvg from the instance and not from the type, as the method for SimpleExpectedReturns does. That method states the reason.
Arguments
ce: The covariance estimator. The method reads only itscvgfield.
Returns
fields::Tuple: The field names to render, which is(:me, :ce, :alg, :w)with no policy and(:me, :ce, :alg, :w, :cvg)with one.
Related
show_fields(
ve::SimpleVariance
) -> Union{Tuple{Symbol, Symbol, Symbol}, NTuple{4, Symbol}}
Renders every field of a SimpleVariance except cache, and cvg only where a policy is set.
A cache holds the state of an incremental fit. That state is not part of the configuration, and it prints under the estimator at each site that renders the estimator. Set set_show_nothing_fields!(:SimpleVariance, true) to render it. The method reads cvg from the instance and not from the type, as the method for SimpleExpectedReturns does. That method states the reason.
Arguments
ve: The variance estimator. The method reads only itscvgfield.
Returns
fields::Tuple: The field names to render, which is(:me, :w, :corrected)with no policy and(:me, :w, :corrected, :cvg)with one.
Related
show_fields(_::GerberCovariance) -> NTuple{5, Symbol}
Renders every field of a GerberCovariance except cache.
A cache holds the state of an incremental fit, not a part of the configuration. Without this method, that state prints under the estimator at every site that renders one. Set set_show_nothing_fields!(:GerberCovariance, true) to render it.
Arguments
::GerberCovariance: Gerber covariance estimator, read for its type alone.
Returns
fields::Tuple: The field names to render, which is(:ve, :me, :pdm, :t, :alg).
Related
show_fields(_::SmythBrobyCovariance) -> NTuple{9, Symbol}
Renders every field of a SmythBrobyCovariance except cache.
A cache holds the state of an incremental fit, not a part of the configuration. Without this method, that state prints under the estimator at every site that renders one. Set set_show_nothing_fields!(:SmythBrobyCovariance, true) to render it.
Arguments
::SmythBrobyCovariance: Smyth-Broby covariance estimator, read for its type alone.
Returns
fields::Tuple: The field names to render, which is(:ve, :me, :pdm, :c1, :c2, :c3, :n, :alg, :ex).
Related
show_fields(_::GerberIQCovariance) -> NTuple{10, Symbol}
Renders every field of a GerberIQCovariance except cache.
A cache holds the state of an incremental fit, not a part of the configuration. Without this method, that state prints under the estimator at every site that renders one. Set set_show_nothing_fields!(:GerberIQCovariance, true) to render it.
Arguments
::GerberIQCovariance: Gerber IQ covariance estimator, read for its type alone.
Returns
fields::Tuple: The field names to render, which is(:ve, :me, :pdm, :c, :decay, :oc, :sc, :kind, :alg, :ex).
Related
show_fields(_::DistanceCovariance) -> NTuple{5, Symbol}
Renders every field of a DistanceCovariance except cache.
A cache holds the state of an incremental fit. That state is not part of the configuration, and it prints under the estimator at each site that renders the estimator. Set set_show_nothing_fields!(:DistanceCovariance, true) to render it.
Arguments
::DistanceCovariance: The distance covariance estimator. The method reads only its type.
Returns
fields::Tuple: The names of the fields to render,(:metric, :args, :kwargs, :w, :ex).
Related
show_fields(
_::LowerTailDependenceCovariance
) -> Tuple{Symbol, Symbol, Symbol}
Renders every field of a LowerTailDependenceCovariance except cache.
A cache holds the state of an incremental fit. That state is not part of the configuration, and it prints under the estimator at each site that renders the estimator. Set set_show_nothing_fields!(:LowerTailDependenceCovariance, true) to render it.
Arguments
::LowerTailDependenceCovariance: The lower tail dependence covariance estimator. The method reads only its type.
Returns
fields::Tuple: The names of the fields to render,(:ve, :alpha, :ex).
Related
show_fields(_::RankCovarianceEstimator) -> Tuple{Symbol}
Renders every field of a RankCovarianceEstimator, such as a KendallCovariance or a SpearmanCovariance, except cache.
A cache holds the state of an incremental fit. That state is not part of the configuration, and it prints under the estimator at each site that renders the estimator. Set set_show_nothing_fields!(:KendallCovariance, true) or set_show_nothing_fields!(:SpearmanCovariance, true) to render it for that type.
Arguments
::RankCovarianceEstimator: The rank covariance estimator. The method reads only its type.
Returns
fields::Tuple: The names of the fields to render,(:ve,).
Related
show_fields(
_::MutualInfoCovariance
) -> Tuple{Symbol, Symbol, Symbol}
Renders every field of a MutualInfoCovariance except cache.
A cache holds the state of an incremental fit. That state is not part of the configuration, and it prints under the estimator at each site that renders the estimator. Set set_show_nothing_fields!(:MutualInfoCovariance, true) to render it.
Arguments
::MutualInfoCovariance: The mutual information covariance estimator. The method reads only its type.
Returns
fields::Tuple: The field names to render, which is(:ve, :bins, :normalise).
Related
show_fields(
_::PortfolioOptimisersCovariance
) -> Tuple{Symbol, Symbol}
Renders every field of a PortfolioOptimisersCovariance except cache.
A cache holds the state of an incremental fit. That state is not part of the configuration, and it prints under the estimator at each site that renders the estimator. Set set_show_nothing_fields!(:PortfolioOptimisersCovariance, true) to render it.
Arguments
::PortfolioOptimisersCovariance: The covariance estimator. The method reads only its type.
Returns
fields::Tuple: The field names to render, which is(:ce, :mp).
Related
show_fields(
ske::Coskewness
) -> Union{NTuple{5, Symbol}, NTuple{6, Symbol}}
Renders every field of a Coskewness, and leaves out cvg when it is nothing.
A cvg of nothing selects the reduce-and-expand path, which is the default of every estimator. A line for it gives the reader no data, and it changes the output of every doctest that shows the estimator. A coverage policy that is set is configuration, so it prints.
Arguments
ske: The coskewness estimator. The method reads itscvgfield alone.
Returns
fields::Tuple: The field names to render, which is(:me, :mp, :alg, :w, :cache)with no policy and(:me, :mp, :alg, :w, :cvg, :cache)with one.
Related
show_fields(
kte::Cokurtosis
) -> Union{NTuple{5, Symbol}, NTuple{6, Symbol}}
Renders every field of a Cokurtosis, and leaves out cvg when it is nothing.
A cvg of nothing selects the reduce-and-expand path, which is the default of every estimator. A line for it gives the reader no data, and it changes the output of every doctest that shows the estimator. A coverage policy that is set is configuration, so it prints.
Arguments
kte: The cokurtosis estimator. The method reads itscvgfield alone.
Returns
fields::Tuple: The field names to render, which is(:me, :mp, :alg, :w, :cache)with no policy and(:me, :mp, :alg, :w, :cvg, :cache)with one.
Related
show_fields(
_::ImpliedVolatility
) -> Tuple{Symbol, Symbol, Symbol}
Renders every field of an ImpliedVolatility except cache.
A cache holds the state of an incremental fit. That state is not part of the configuration, and it prints under the estimator at each site that renders the estimator. Set set_show_nothing_fields!(:ImpliedVolatility, true) to render it.
Arguments
::ImpliedVolatility: The implied volatility covariance estimator. The method reads only its type.
Returns
fields::Tuple: The field names to render, which is(:ce, :alg, :ppy).
Related
show_fields(_::CorrelationCovariance) -> Tuple{Symbol}
Renders every field of a CorrelationCovariance except cache.
A cache holds the state of an incremental fit. That state is not part of the configuration, and it prints under the estimator at each site that renders the estimator. Set set_show_nothing_fields!(:CorrelationCovariance, true) to render it.
Arguments
::CorrelationCovariance: The correlation covariance estimator. The method reads only its type.
Returns
fields::Tuple: The field names to render, which is(:ce,).
Related
show_fields(
est::Union{WindowedCokurtosis, WindowedCoskewness, WindowedCovariance, WindowedExpectedReturns, WindowedVariance}
) -> Union{Tuple{Symbol, Symbol, Symbol}, NTuple{4, Symbol}}
Return the fields of a windowed estimator that the printout shows, which are every field except cache.
The cache field holds the Partial Fit State of an online fit. It is not configuration. Without this method, the state prints under the estimator each time a Prior or an optimiser that holds the estimator prints. To show the field for one type, call set_show_nothing_fields! with the name of the type and true, for example set_show_nothing_fields!(:WindowedCovariance, true).
Arguments
est: Windowed estimator. The function reads its type alone.
Returns
fields::Tuple: The field names to show, which are every field name except:cache.
Related
show_fields(
de::Union{ChangeInIntensity, ChangeToScale, GrowthRate}
) -> Tuple{Vararg{Symbol}}
Renders every field of a GrowthRate, a ChangeToScale or a ChangeInIntensity except cache.
The state a cache holds is the running detail of an incremental fit, not the configuration a reader looks the type up for, and it prints under the estimator at every site that renders one, such as a CompositeExposure. Set set_show_nothing_fields!(:GrowthRate, true) to render it.
Arguments
de: The estimator.
Returns
fields::Tuple: The field names to render, every field name but:cache.
Related
show_fields(
de::Union{DaysToCover, EWMean, EWVolumeRatio}
) -> Tuple{Vararg{Symbol}}
Renders every field of an EWMean, an EWVolumeRatio or a DaysToCover except cache.
The state a cache holds is the running detail of an incremental fit, not the configuration a reader looks the type up for, and it prints under the estimator at every site that renders one, such as a CompositeExposure. Set set_show_nothing_fields!(:EWMean, true) to render it.
Arguments
de: The estimator.
Returns
fields::Tuple: The field names to render, every field name but:cache.
Related
show_fields(
de::Union{EWResidualVolatility, EWVolatility}
) -> Tuple{Vararg{Symbol}}
Renders every field of an EWVolatility or of an EWResidualVolatility except cache.
The state a cache holds is the running detail of an incremental fit, not the configuration a reader looks the type up for, and it prints under the estimator at every site that renders one, such as a CompositeExposure. Set set_show_nothing_fields!(:EWVolatility, true) to render it.
Arguments
de: The estimator.
Returns
fields::Tuple: The field names to render, every field name but:cache.
Related
show_fields(
de::Union{EWBeta, EWDownsideBeta, EWMacroSensitivity}
) -> Tuple{Vararg{Symbol}}
Renders every field of an EWBeta, an EWMacroSensitivity or an EWDownsideBeta except cache.
The state a cache holds is the running detail of an incremental fit, not the configuration a reader looks the type up for, and it prints under the estimator at every site that renders one, such as a CompositeExposure. Set set_show_nothing_fields!(:EWBeta, true) to render it.
Arguments
de: The estimator.
Returns
fields::Tuple: The field names to render, every field name but:cache.
Related
show_fields(_::RollingLogReturn) -> NTuple{4, Symbol}
Renders every field of a RollingLogReturn except cache.
The state a cache holds is the running detail of an incremental fit, not the configuration a reader looks the type up for, and it prints under the estimator at every site that renders one, such as a CompositeExposure. Set set_show_nothing_fields!(:RollingLogReturn, true) to render it.
Arguments
de: The estimator.
Returns
fields::Tuple: The field names to render,(:window, :skip, :sign, :exponentiate).
Related
show_fields(_::RankOneCovariance) -> Tuple{Symbol}
Renders every field of a RankOneCovariance except cache.
The state a cache holds is the running detail of an incremental fit, not the configuration a reader looks the type up for, and it prints under the estimator at every site that renders one. Set set_show_nothing_fields!(:RankOneCovariance, true) to render it.
Arguments
::RankOneCovariance: Rank-one covariance estimator, read for its type alone.
Returns
fields::Tuple: The field names to render, which is(:shift,).
Related
show_fields(
_::GeodesicShrinkageCovariance
) -> NTuple{4, Symbol}
Renders every field of a GeodesicShrinkageCovariance except cache.
The state a cache holds is the running detail of an incremental fit, not the configuration a reader looks the type up for, and it prints under the estimator at every site that renders one. Set set_show_nothing_fields!(:GeodesicShrinkageCovariance, true) to render it.
Arguments
::GeodesicShrinkageCovariance: Geodesic shrinkage covariance estimator, read for its type alone.
Returns
fields::Tuple: The field names to render, which is(:ce, :pdm, :tgt, :alpha).
Related
show_fields(
pe::EmpiricalPrior
) -> Union{NTuple{5, Symbol}, NTuple{6, Symbol}}
Renders every field of an EmpiricalPrior except cache, and max_scenarios only where it is set.
The state in cache belongs to an incremental fit and is not part of the configuration, and it would print under the estimator at every site that renders one. Most callers leave max_scenarios at nothing, and a nothing row would change the rendering of every estimator that holds a prior. The row appears only when a caller sets a cap. Set set_show_nothing_fields!(:EmpiricalPrior, true) to render both.
Arguments
pe: Empirical prior estimator.
Returns
fields::Tuple: The field names to render, which is(:ce, :me, :horizon, :fill_limit, :x_src)with no scenario cap and(:ce, :me, :horizon, :fill_limit, :max_scenarios, :x_src)with one.
Related
show_fields(_::FactorPrior) -> NTuple{7, Symbol}
Renders every field of a FactorPrior except cache.
The state in cache belongs to an incremental fit and is not part of the configuration, and it would print under the estimator at every site that renders one. Set set_show_nothing_fields!(:FactorPrior, true) to render it.
Arguments
::FactorPrior: Prior estimator, read for its type alone.
Returns
fields::Tuple: The field names to render, which is(:pe, :mp, :re, :ve, :rsd, :mtx_sqrt, :x_src).
Related
show_fields(
_::BayesianBlackLittermanPrior
) -> NTuple{9, Symbol}
Give every field of a BayesianBlackLittermanPrior to print, except cache.
The state in cache changes at each step of an incremental fit, and it is not part of the configuration. Each site that prints the estimator also prints this state, unless this method leaves it out. Set set_show_nothing_fields!(:BayesianBlackLittermanPrior, true) to print it.
Arguments
::BayesianBlackLittermanPrior: Prior estimator, read for its type alone.
Returns
fields::Tuple: The field names to render, which is(:pe, :f_mp, :mp, :views, :sets, :views_conf, :rf, :tau, :x_src).
Related
show_fields(
_::FactorBlackLittermanPrior
) -> NTuple{15, Symbol}
Give every field of a FactorBlackLittermanPrior to print, except cache.
The state in cache changes at each step of an incremental fit, and it is not part of the configuration. Each site that prints the estimator also prints this state, unless this method leaves it out. Set set_show_nothing_fields!(:FactorBlackLittermanPrior, true) to print it.
Arguments
::FactorBlackLittermanPrior: Prior estimator, read for its type alone.
Returns
fields::Tuple: The field names to render, which is(:pe, :f_mp, :mp, :re, :ve, :rsd, :views, :sets, :views_conf, :w, :rf, :l, :tau, :mtx_sqrt, :x_src).
Related
show_fields(
_::AugmentedBlackLittermanPrior
) -> NTuple{14, Symbol}
Give every field of an AugmentedBlackLittermanPrior to print, except cache.
The state in cache changes at each step of an incremental fit, and it is not part of the configuration. Each site that prints the estimator also prints this state, unless this method leaves it out. Set set_show_nothing_fields!(:AugmentedBlackLittermanPrior, true) to print it.
Arguments
::AugmentedBlackLittermanPrior: Prior estimator, read for its type alone.
Returns
fields::Tuple: The field names to render, which is(:a_pe, :f_pe, :mp, :re, :a_views, :f_views, :sets, :a_views_conf, :f_views_conf, :w, :rf, :l, :tau, :x_src).
Related
show_fields(
_::MeucciEntropyPoolingPrior
) -> NTuple{17, Symbol}
Give every field of a MeucciEntropyPoolingPrior to print, except cache.
The state in cache changes at each step of an incremental fit, and it is not part of the configuration. Each site that prints the estimator also prints this state, unless this method leaves it out. Set set_show_nothing_fields!(:MeucciEntropyPoolingPrior, true) to print it.
Arguments
::MeucciEntropyPoolingPrior: Prior estimator, read for its type alone.
Returns
fields::Tuple: The field names to render, which is(:pe, :mu_views, :var_views, :cvar_views, :sigma_views, :sk_views, :kt_views, :cov_views, :rho_views, :sets, :ds_opt, :dm_opt, :opt, :diagnose, :w, :alg, :x_src).
Related
show_fields(_::EntropyPoolingPrior) -> NTuple{17, Symbol}
Give every field of an EntropyPoolingPrior to print, except cache.
The state in cache changes at each step of an incremental fit, and it is not part of the configuration. Each site that prints the estimator also prints this state, unless this method leaves it out. Set set_show_nothing_fields!(:EntropyPoolingPrior, true) to print it.
Arguments
::EntropyPoolingPrior: Prior estimator, read for its type alone.
Returns
fields::Tuple: The field names to render, which is(:pe, :mu_views, :var_views, :cvar_views, :evar_views, :rlvar_views, :sigma_views, :sk_views, :kt_views, :cov_views, :rho_views, :sets, :opt, :diagnose, :w, :alg, :x_src).
Related
show_fields(_::OpinionPoolingPrior) -> NTuple{8, Symbol}
Renders every field of a OpinionPoolingPrior except cache.
The state a cache holds is the running detail of an incremental fit, not the configuration a reader looks the type up for, and it prints under the estimator at every site that renders one. Set set_show_nothing_fields!(:OpinionPoolingPrior, true) to render it.
Arguments
::OpinionPoolingPrior: Prior estimator, read for its type alone.
Returns
fields::Tuple: The field names to render, which is(:pes, :pe1, :pe2, :p, :w, :alg, :ex, :x_src).
Related
show_fields(
_::HighOrderFactorPriorEstimator
) -> NTuple{6, Symbol}
Give every field of a HighOrderFactorPriorEstimator to print, except cache.
The state in cache changes at each step of an incremental fit, and it is not part of the configuration. Each site that prints the estimator also prints this state, unless this method leaves it out. Set set_show_nothing_fields!(:HighOrderFactorPriorEstimator, true) to print it.
Arguments
::HighOrderFactorPriorEstimator: Prior estimator. The method reads its type alone.
Returns
fields::Tuple: The names of the fields to print,(:pe, :kte, :ske, :ex, :rsd, :x_src).
Related
show_fields(
_::CrossSectionalFactorPrior
) -> NTuple{30, Symbol}
Renders every field of a CrossSectionalFactorPrior except cache.
The state a cache holds is the running detail of an incremental fit, not the configuration a reader looks the type up for. Set set_show_nothing_fields!(:CrossSectionalFactorPrior, true) to render it.
Arguments
::CrossSectionalFactorPrior: Prior estimator, read for its type alone.
Returns
fields::Tuple: The field names to render, every field butcache.
Related
show_fields(fees::Fees)Return the fields the pretty-printer renders for a Fees. These are every field but imsk when the mark is nothing, and every field when it is set.
investable_fees_view writes imsk and a caller never does. A fee that a caller wrote therefore holds nothing there and prints no imsk row. A fee that investable_fees_view reduced shows the mask it reduced the fee on, so a reader can tell the two states apart at the REPL.
Algorithm
- On a
nothingfees.imsk, return the names of the nine fields beforeimsk. - Otherwise return the names of all ten fields,
imsklast.
Arguments
fees: The fee to render.
Returns
NTuple{N, Symbol}: The field names to print, in declaration order.
Related
show_fields(
opt::Union{BaseClusteringOptimisationEstimator, BaseStackingOptimisationEstimator, BaseSubsetResamplingOptimisationEstimator, BestConstantRebalancedPortfolio, EqualWeighted, InverseVolatility, JuMPOptimiser, NestedClustered, RandomWeighted}
) -> Any
Renders every field of an optimiser that takes the online step, except its cache.
The cache holds the state of an incremental fit, not the configuration that a reader looks up, and it would print under every optimiser that holds it. set_show_nothing_fields!(:Name, true) renders it for the type Name.
Arguments
opt: The optimiser.
Returns
fields::Tuple: Every field name exceptcache.
Related
show_fields(
p::Pipeline
) -> Union{Tuple{Symbol, Symbol}, Tuple{Symbol, Symbol, Symbol}}
Lists the fields that show renders for a Pipeline: the names, the steps, and the cache only when it holds a state.
A pipeline that took no step therefore renders no cache line.
Related
PortfolioOptimisers.pretty_show_fields — Function
pretty_show_fields(obj) -> Any
Resolve the fields that @define_pretty_show renders for obj.
Three sources decide, in a fixed order of precedence. A per-name entry of SHOW_NOTHING_FIELDS overrides the show_fields method of the type, and that method overrides the global default of SHOW_NOTHING_FIELDS. The name is the name of the type without its module, so two types with one name in two modules share one entry.
Algorithm
- Read
cfg, the active value ofSHOW_NOTHING_FIELDS. Readentry, its per-name entry for the name of the type ofobj, ornothingwhen the type has no entry. - Choose
fields. It is every declared field whenentryistrue, so that a per-name request to show all fields overrides ashow_fieldsoverload. In the other cases it is the result ofshow_fields. - Choose
show. It isentrywhen the type has an entry, and the global default ofcfgin the other case. - Return
fieldswhenshowistrue. Otherwise return the members offieldswhose value, read withgetproperty, is notnothing.
Arguments
obj: The value to print.
Returns
fields: The field names to render, in declaration order. Every declared field, the result ofshow_fields, or the members of that result whose value is notnothing.
Related
PortfolioOptimisers.has_pretty_show_method — Function
has_pretty_show_method(_) -> Bool
Return whether the type of a value has a custom pretty-printing show method. The default method returns false.
A method that returns true for a type tells @define_pretty_show that the type has a custom pretty-printing method.
Arguments
::Any: A value of any type.
Returns
flag::Bool:falsefor the default method, which means that the type has no custom pretty-printing method.
Related
PortfolioOptimisers.pretty_show_vector_summary — Function
pretty_show_vector_summary(val::AbstractVector) -> String
Build the one-line summary of a vector field that @define_pretty_show prints.
The summary has the form "N-element Vector{Name}". When all elements have the same wrapper-type name, Name is that name. Two elements that differ only in their type parameters have the same wrapper-type name. In other cases, Name is the wrapper name of the element type, or the element type itself when it is a Union.
Algorithm
- Collect
names, the wrapper-type name of every element. - Read
et, the element type of the vector. - Choose
tname. It is the common name when every entry ofnamesis equal, the string ofetwhenetis aUnion, and the wrapper name ofetin the other cases. - Build the summary from the length of the vector and
tname.
Arguments
val: A non-empty vector whose elements all have a custom pretty-printing method.
Returns
summary::String: The one-line"N-element Vector{Name}"summary.
Related
PortfolioOptimisers.pretty_show_vector_element — Function
pretty_show_vector_element(v) -> String
Render one vector element as a collapsed line for @define_pretty_show.
Each element of a listed vector prints as its wrapper-type name only. When the element is a struct with fields, a " ⋯" after the name marks the collapsed struct. A struct field over the budget collapses to Name ⋯ in the same way. An element with no field prints its name alone.
Algorithm
- Take
s, the wrapper-type name ofv. - Return
sunchanged whenvhas no field, and otherwise returnsfollowed by" ⋯".
Arguments
v: The vector element to render.
Returns
line::String: The collapsed one-line rendering ofv.
Related
PortfolioOptimisers.pretty_show_vector_body — Function
pretty_show_vector_body(
io::IO,
lines::AbstractVector{<:AbstractString}
) -> Any
Apply the collapse budget to the element lines of a vector that @define_pretty_show prints.
The budget comes from compact_show_budget. A vector thus obeys the same :limit key, global set_compact_show! setting and per-call :po_compact override as a struct field. The budget is nothing when the collapse is off, when the output is not limited, or when the override turns it off. The function then returns every line. When the list has more lines than the budget, the function keeps the first lines and the last lines, as Base does for a long array. One "⋮" line marks the lines that it removes.
Algorithm
- Read
budgetfromcompact_show_budget, andn, the number of lines. - Return
linesunchanged whenbudgetisnothing, or whenndoes not exceed it. - Split the budget into
nhead, its half rounded up, andntail, the rest. - Return the first
nheadlines, one"⋮"line, and the lastntaillines.
Arguments
io: The output stream.compact_show_budgetreads the budget from it.lines: The display string of each element, frompretty_show_vector_element.
Returns
body::Vector{String}: The lines to print. When the function removes lines, a"⋮"line stands in their place.
Related