Option: Option Class

Description Super class Active bindings Methods

Description

Key-value dictionary type base class contains a machine learning project option. A majority of features are derived from Dict::Dict class.

Some concreate classes that stores a project option are also defined in this package, so you do not need to play with this class directly.

Super class

Dict::Dict -> Option

Active bindings

value_width

max print width.

Methods

Public methods

Inherited methods

Method new()

Construct a new Option class object.

Usage
Option$new(
  ...,
  .class = "any",
  .key_prefix = "opt",
  .key_width = 2L,
  .value_width = Inf
)
Arguments
...

Key and value pairs.

.class

A character scalar of object's class. Should be one of the outputs from class().

.key_prefix

A character scalar of key prefix. Used for an auto complement key's prefix, if the key is omitted.

.key_width

A integer scalar of auto increment key number width. If .key_width = 2L (default) and .key_prefix = "op" (default), the first auto complement key will be op01.

.value_width

A integer scalar of character length. Used as max width of output value by self$print() method.

Returns

A new Option class object.


Method print_items()

Print option items.

Usage
Option$print_items(items_name = "Objects", format_fun = NULL)
Arguments
items_name

A character scalar of printed item name.

format_fun

A funtion to format item values. Must be a function that receives a option's value and returns a character scalar.


Method add()

Adds key-value objects to the dictionary.

Usage
Option$add(...)
Arguments
...

Key and value pairs.


Method remove()

Removes objects from the dictionary.

Usage
Option$remove(key = NULL)
Arguments
key

A character scalar.


Method clear()

Overwrite super class's self$clear() to throw an error which ensures the Option object always has at least one item.

Usage
Option$clear()

Method clone()

The objects of this class are cloneable with this method.

Usage
Option$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


five-dots/ml4e documentation built on June 19, 2020, 4:26 p.m.