Table of Contents

Class EnumCategoricalExtensions

Namespace
OptunaSharp
Assembly
OptunaSharp.dll

Typed read-back for enum-valued categorical parameters — the read side of the TEnum lens (see EnumCategorical). Because a categorical is persisted as a bare member-name string with no type memory, the caller must name TEnum at the moment of reading; resolution is therefore deferred to here and can fail if the stored string is not a member of the requested enum.

public static class EnumCategoricalExtensions
Inheritance
EnumCategoricalExtensions
Inherited Members

Methods

GetCategorical<TEnum>(BaseTrial, string)

Reads a categorical parameter of an active or replay trial as TEnum.

public static TEnum GetCategorical<TEnum>(this BaseTrial trial, string name) where TEnum : struct, Enum

Parameters

trial BaseTrial

The trial whose already-suggested parameters are read.

name string

The parameter name to read.

Returns

TEnum

The stored member-name string resolved to its enum member.

Type Parameters

TEnum

The enum the caller asserts this parameter was suggested from.

Exceptions

ArgumentNullException

The trial is null.

KeyError

No parameter with that name has been suggested.

ValueError

The stored string is not a declared member of TEnum.

TypeError

The stored value is not a member-name string.

GetCategorical<TEnum>(IReadOnlyDictionary<string, object?>, string)

Reads a categorical parameter as TEnum from any parameter view. A single lens covers every read surface that exposes params this way — Params, Params, and BestParams alike.

public static TEnum GetCategorical<TEnum>(this IReadOnlyDictionary<string, object?> parameters, string name) where TEnum : struct, Enum

Parameters

parameters IReadOnlyDictionary<string, object>

A parameter dictionary mapping names to their external values.

name string

The parameter name to read.

Returns

TEnum

The stored member-name string resolved to its enum member.

Type Parameters

TEnum

The enum the caller asserts this parameter was suggested from.

Exceptions

ArgumentNullException

The parameter dictionary is null.

KeyError

No parameter with that name is present.

ValueError

The stored string is not a declared member of TEnum.

TypeError

The stored value is not a member-name string (e.g. the parameter is not categorical, or belongs to a different enum).