Documentation
¶
Index ¶
- Variables
- type BoolFuncs
- func (fs *BoolFuncs) Add(nm string, f func() bool)
- func (fs *BoolFuncs) Delete(nm string) error
- func (fs *BoolFuncs) FindName(nm string) (int, error)
- func (fs *BoolFuncs) InsertAfter(after, nm string, f func() bool) error
- func (fs *BoolFuncs) InsertAt(i int, nm string, f func() bool)
- func (fs *BoolFuncs) InsertBefore(before, nm string, f func() bool) error
- func (fs *BoolFuncs) Names() []string
- func (fs *BoolFuncs) Prepend(nm string, f func() bool)
- func (fs *BoolFuncs) Replace(nm string, f func() bool) error
- func (fs *BoolFuncs) Run() bool
- func (fs *BoolFuncs) RunTrace(level int) bool
- func (fs *BoolFuncs) String() string
- type Funcs
- func (fs *Funcs) Add(nm string, f func())
- func (fs *Funcs) Delete(nm string) error
- func (fs *Funcs) FindName(nm string) (int, error)
- func (fs *Funcs) InsertAfter(after, nm string, f func()) error
- func (fs *Funcs) InsertAt(i int, nm string, f func())
- func (fs *Funcs) InsertBefore(before, nm string, f func()) error
- func (fs *Funcs) Names() []string
- func (fs *Funcs) Prepend(nm string, f func())
- func (fs *Funcs) Replace(nm string, f func()) error
- func (fs *Funcs) Run()
- func (fs *Funcs) RunTrace(level int)
- func (fs *Funcs) String() string
- type Loop
- type NamedBoolFunc
- type NamedFunc
- type Set
- func (set *Set) AddLevels(times ...etime.Times)
- func (set *Set) AddStack(st *Stack)
- func (set *Set) Init(mode etime.Modes)
- func (set *Set) InitAll()
- func (set *Set) InitMap()
- func (set *Set) InitName(name string) (*Stack, error)
- func (set *Set) Run(mode etime.Modes)
- func (set *Set) RunName(name string) (*Stack, error)
- func (set *Set) Stack(mode etime.Modes) *Stack
- func (set *Set) StackNameTry(name string) (*Stack, error)
- func (set *Set) StackTry(mode etime.Modes) (*Stack, error)
- func (set *Set) Step(mode etime.Modes, step etime.Times, n int) (*Stack, error)
- func (set *Set) StepName(name string, step string, n int) (*Stack, error)
- type Stack
- func (st *Stack) AddEnvFuncs()
- func (st *Stack) AddLevels(times ...etime.Times)
- func (st *Stack) DocString() string
- func (st *Stack) EndRun(lp *Loop, level int)
- func (st *Stack) Init()
- func (st *Stack) Level(lev int) *Loop
- func (st *Stack) Loop(time etime.Times) *Loop
- func (st *Stack) MainRun(lp *Loop, level int)
- func (st *Stack) Run()
- func (st *Stack) Scope() etime.ScopeKey
- func (st *Stack) SetStep(time etime.Times, n int)
- func (st *Stack) SetStepTime(time string, n int)
- func (st *Stack) StepCheck(lp *Loop, level int) bool
- func (st *Stack) StepClear()
- func (st *Stack) StepIsScope(lp *Loop) bool
- func (st *Stack) StopCheck(lp *Loop, level int) bool
- func (st *Stack) Times() []string
- type Step
Constants ¶
This section is empty.
Variables ¶
var IndentSize = 4
IndentSize is number of spaces to indent for output
Functions ¶
This section is empty.
Types ¶
type BoolFuncs ¶
type BoolFuncs []*NamedBoolFunc
BoolFuncs is a list of named plain functions
func (*BoolFuncs) FindName ¶
FindName finds index of function by name, returns not found err message if not found
func (*BoolFuncs) InsertAfter ¶
InsertAfter inserts function after other function of given name
func (*BoolFuncs) InsertBefore ¶
InsertBefore inserts function before other function of given name
func (*BoolFuncs) Run ¶
Run runs the list of functions in order, returning true as soon as any of the functions return true, else false
type Funcs ¶
type Funcs []*NamedFunc
Funcs is a list of named plain functions
func (*Funcs) FindName ¶
FindName finds index of function by name, returns not found err message if not found
func (*Funcs) InsertAfter ¶
InsertAfter inserts function after other function of given name
func (*Funcs) InsertBefore ¶
InsertBefore inserts function before other function of given name
type Loop ¶
type Loop struct {
Stack *Stack `desc:"stack that owns this loop"`
Scope etime.ScopeKey `desc:"scope level of this loop"`
Main Funcs `` /* 333-byte string literal not displayed */
Stop BoolFuncs `desc:"functions that cause the loop to stop -- if any return true, it stops"`
End Funcs `` /* 204-byte string literal not displayed */
}
Loop represents one level of looping, with arbitrary functions called at 3 different points in the loop, corresponding to a do..while loop logic, with no initialization, which is necessary to ensure reentrant steppability. In Go, the logic looks like this:
for {
for { <subloops here> } // drills down levels for each subloop
Main() // Main is called after subloops -- increment counters!
if Stop() {
break
}
}
End() // Reset counters here so next pass starts over
func (*Loop) EnvCtr ¶
EnvCtr returns the counter corresponding to this loop's scope, nil if not found
func (*Loop) EnvIsOverMax ¶
EnvIsOverMax is the Env:IsOverMax Stop function
func (*Loop) EnvResetIfOverMax ¶
func (lp *Loop) EnvResetIfOverMax()
EnvResetIfOverMax is the Env:ResetIfOverMax End function
type NamedBoolFunc ¶
type NamedBoolFunc struct {
Name string `` /* 165-byte string literal not displayed */
Func func() bool `desc:"function -- note that you can pass a method to a type as well as a closure here"`
}
NamedBoolFunc is a named function returning bool
type NamedFunc ¶
type NamedFunc struct {
Name string `` /* 165-byte string literal not displayed */
Func func() `desc:"function -- note that you can pass a method to a type as well as a closure here"`
}
NamedFunc is a named function
type Set ¶
type Set struct {
Stacks map[string]*Stack `desc:"the collection of loop stacks -- key is typically etime.Mode"`
StopFlag bool `view:"-" desc:"if true, running will stop at soonest opportunity"`
}
Set contains a set of interconnected loop Stacks (e.g., Train, Test, etc)
func StdTrainTest ¶
func StdTrainTest() *Set
StdTrainTest adds standard Train: Run, Epoch, Trial, Test: Epoch, Trial
func (*Set) AddLevels ¶
AddLevels adds given levels to all Stacks. For algorithms to add mechanism inner loops.
func (*Set) StackNameTry ¶
StackNameTry returns Stack based on name key, returning err if not found
type Stack ¶
type Stack struct {
Mode string `desc:"eval mode for this stack"`
Env envlp.Env `desc:"environment used by default for loop iteration, stopping, if set"`
Order []etime.ScopeKey `desc:"ordered list of the loops, from outer-most (highest) to inner-most (lowest)"`
Loops map[etime.ScopeKey]*Loop `desc:"the loops by scope"`
Ctxt map[string]interface{} `` /* 135-byte string literal not displayed */
Step Step `desc:"stepping state"`
Set *Set `view:"-" desc:"Set of Stacks that we belong to"`
}
Stack contains one stack of nested loops, associated with one evaluation Mode, and, optionally, envlp.Env. If the Env is set, then counters at corresponding Scope levels are incremented, checked for stopping, and reset to control looping.
func NewStackEnv ¶
NewStackEnv returns new stack with loops matching those in the given environment. Adds standard Env counter funcs to manage updating of counters, with Step at the lowest level.
func NewStackScope ¶
NewStack returns new stack for given list of scopes
func (*Stack) AddLevels ¶
AddLevels adds given levels to stack. For algorithms to add mechanism inner loops.
func (*Stack) DocString ¶
DocString returns an indented summary of the loops and functions in the stack
func (*Stack) EndRun ¶
EndRun runs End functions on loop, and then resets Env counter at same Scope level (if Env)
func (*Stack) Init ¶
func (st *Stack) Init()
Init runs End functions for all levels in the Stack, to reset state for a fresh Run.
func (*Stack) Run ¶
func (st *Stack) Run()
Run runs the stack of looping functions. It will stop at any existing Step settings -- call StepClear to clear those.
func (*Stack) SetStepTime ¶
SetStepTime sets the stepping time and n -- 0 = no stepping resets counter.
func (*Stack) StepIsScope ¶
StepIsScope returns true if stepping is happening at scope level of given loop
type Step ¶
type Step struct {
Time string `desc:"stepping level, time string"`
Default string `desc:"default stepping level"`
N int `desc:"number of times to iterate at StepScope level, no stepping if 0"`
Cnt int `view:"-" desc:"counter for number of times through loop"`
LoopTrace bool `desc:"if true, print out a trace of looping stages as they run"`
FuncTrace bool `desc:"if true, print out a trace of functions as they run -- implies LoopTrace"`
}
Step manages stepping state. Also trace flag