diff --git a/chem/gtigen.go b/chem/gtigen.go index ec271fbd..2edae931 100644 --- a/chem/gtigen.go +++ b/chem/gtigen.go @@ -16,7 +16,7 @@ var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/chem.EnzRate", var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/chem.Paramer", IDName: "paramer", Doc: "The Paramer interface defines functions implemented for Params\nstructures, containing chem React, Enz, etc functions.\nThis interface is largely for documentation purposes."}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/chem.React", IDName: "react", Doc: "React models a basic chemical reaction:\n\n\tKf\n\nA + B --> AB\n\n\t<-- Kb\n\nwhere Kf is the forward and Kb is the backward time constant.\nThe source Kf and Kb constants are in terms of concentrations μM-1 and sec-1\nbut calculations take place using N's, and the forward direction has\ntwo factors while reverse only has one, so a corrective volume factor needs\nto be divided out to set the actual forward factor.", Directives: []gti.Directive{{Tool: "go", Directive: "generate", Args: []string{"goki", "generate", "-add-types"}}}, Fields: []gti.Field{{Name: "Kf", Doc: "forward rate constant for N / sec assuming 2 forward factors"}, {Name: "Kb", Doc: "backward rate constant for N / sec assuming 1 backward factor"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/chem.React", IDName: "react", Doc: "React models a basic chemical reaction:\n\n\tKf\n\nA + B --> AB\n\n\t<-- Kb\n\nwhere Kf is the forward and Kb is the backward time constant.\nThe source Kf and Kb constants are in terms of concentrations μM-1 and sec-1\nbut calculations take place using N's, and the forward direction has\ntwo factors while reverse only has one, so a corrective volume factor needs\nto be divided out to set the actual forward factor.", Directives: []gti.Directive{{Tool: "go", Directive: "generate", Args: []string{"core", "generate", "-add-types"}}}, Fields: []gti.Field{{Name: "Kf", Doc: "forward rate constant for N / sec assuming 2 forward factors"}, {Name: "Kb", Doc: "backward rate constant for N / sec assuming 1 backward factor"}}}) var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/chem.SimpleEnz", IDName: "simple-enz", Doc: "SimpleEnz models a simple enzyme-catalyzed reaction\nthat transforms S = substrate into P product via E which is not consumed\nassuming there is much more E than S and P -- E effectively acts as a\nrate constant multiplier\n\n\tKf*E\n\nS ----> P\n\nS = substrate, E = enzyme, P = product, Kf is the rate of the reaction", Fields: []gti.Field{{Name: "Kf", Doc: "S->P forward rate constant, in μM-1 msec-1"}}}) diff --git a/econfig/enumgen.go b/econfig/enumgen.go index 8b5a4c0d..2e19dbde 100644 --- a/econfig/enumgen.go +++ b/econfig/enumgen.go @@ -3,119 +3,46 @@ package econfig import ( - "errors" - "log" - "strconv" - "strings" - "cogentcore.org/core/enums" ) var _TestEnumValues = []TestEnum{0, 1} -// TestEnumN is the highest valid value -// for type TestEnum, plus one. +// TestEnumN is the highest valid value for type TestEnum, plus one. const TestEnumN TestEnum = 2 -// An "invalid array index" compiler error signifies that the constant values have changed. -// Re-run the enumgen command to generate them again. -func _TestEnumNoOp() { - var x [1]struct{} - _ = x[TestValue1-(0)] - _ = x[TestValue2-(1)] -} - -var _TestEnumNameToValueMap = map[string]TestEnum{ - `TestValue1`: 0, - `testvalue1`: 0, - `TestValue2`: 1, - `testvalue2`: 1, -} +var _TestEnumValueMap = map[string]TestEnum{`TestValue1`: 0, `TestValue2`: 1} -var _TestEnumDescMap = map[TestEnum]string{ - 0: ``, - 1: ``, -} +var _TestEnumDescMap = map[TestEnum]string{0: ``, 1: ``} -var _TestEnumMap = map[TestEnum]string{ - 0: `TestValue1`, - 1: `TestValue2`, -} +var _TestEnumMap = map[TestEnum]string{0: `TestValue1`, 1: `TestValue2`} -// String returns the string representation -// of this TestEnum value. -func (i TestEnum) String() string { - if str, ok := _TestEnumMap[i]; ok { - return str - } - return strconv.FormatInt(int64(i), 10) -} +// String returns the string representation of this TestEnum value. +func (i TestEnum) String() string { return enums.String(i, _TestEnumMap) } -// SetString sets the TestEnum value from its -// string representation, and returns an -// error if the string is invalid. +// SetString sets the TestEnum value from its string representation, +// and returns an error if the string is invalid. func (i *TestEnum) SetString(s string) error { - if val, ok := _TestEnumNameToValueMap[s]; ok { - *i = val - return nil - } - if val, ok := _TestEnumNameToValueMap[strings.ToLower(s)]; ok { - *i = val - return nil - } - return errors.New(s + " is not a valid value for type TestEnum") + return enums.SetString(i, s, _TestEnumValueMap, "TestEnum") } // Int64 returns the TestEnum value as an int64. -func (i TestEnum) Int64() int64 { - return int64(i) -} +func (i TestEnum) Int64() int64 { return int64(i) } // SetInt64 sets the TestEnum value from an int64. -func (i *TestEnum) SetInt64(in int64) { - *i = TestEnum(in) -} +func (i *TestEnum) SetInt64(in int64) { *i = TestEnum(in) } // Desc returns the description of the TestEnum value. -func (i TestEnum) Desc() string { - if str, ok := _TestEnumDescMap[i]; ok { - return str - } - return i.String() -} - -// TestEnumValues returns all possible values -// for the type TestEnum. -func TestEnumValues() []TestEnum { - return _TestEnumValues -} +func (i TestEnum) Desc() string { return enums.Desc(i, _TestEnumDescMap) } -// Values returns all possible values -// for the type TestEnum. -func (i TestEnum) Values() []enums.Enum { - res := make([]enums.Enum, len(_TestEnumValues)) - for i, d := range _TestEnumValues { - res[i] = d - } - return res -} +// TestEnumValues returns all possible values for the type TestEnum. +func TestEnumValues() []TestEnum { return _TestEnumValues } -// IsValid returns whether the value is a -// valid option for type TestEnum. -func (i TestEnum) IsValid() bool { - _, ok := _TestEnumMap[i] - return ok -} +// Values returns all possible values for the type TestEnum. +func (i TestEnum) Values() []enums.Enum { return enums.Values(_TestEnumValues) } // MarshalText implements the [encoding.TextMarshaler] interface. -func (i TestEnum) MarshalText() ([]byte, error) { - return []byte(i.String()), nil -} +func (i TestEnum) MarshalText() ([]byte, error) { return []byte(i.String()), nil } // UnmarshalText implements the [encoding.TextUnmarshaler] interface. -func (i *TestEnum) UnmarshalText(text []byte) error { - if err := i.SetString(string(text)); err != nil { - log.Println("TestEnum.UnmarshalText:", err) - } - return nil -} +func (i *TestEnum) UnmarshalText(text []byte) error { return enums.UnmarshalText(i, text, "TestEnum") } diff --git a/econfig/gtigen.go b/econfig/gtigen.go index ae7c5b87..b90210b2 100644 --- a/econfig/gtigen.go +++ b/econfig/gtigen.go @@ -6,7 +6,7 @@ import ( "cogentcore.org/core/gti" ) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/econfig.TestEnum", IDName: "test-enum", Doc: "TestEnum is an enum type for testing", Directives: []gti.Directive{{Tool: "go", Directive: "generate", Args: []string{"goki", "generate"}}, {Tool: "enums", Directive: "enum"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/econfig.TestEnum", IDName: "test-enum", Doc: "TestEnum is an enum type for testing"}) var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/econfig.Includeser", IDName: "includeser", Doc: "Includeser enables processing of Includes []string field with files to include in Config objects."}) diff --git a/egui/enumgen.go b/egui/enumgen.go index 29047239..66bd8bd9 100644 --- a/egui/enumgen.go +++ b/egui/enumgen.go @@ -3,124 +3,48 @@ package egui import ( - "errors" - "log" - "strconv" - "strings" - "cogentcore.org/core/enums" ) var _ToolGhostingValues = []ToolGhosting{0, 1, 2} -// ToolGhostingN is the highest valid value -// for type ToolGhosting, plus one. +// ToolGhostingN is the highest valid value for type ToolGhosting, plus one. const ToolGhostingN ToolGhosting = 3 -// An "invalid array index" compiler error signifies that the constant values have changed. -// Re-run the enumgen command to generate them again. -func _ToolGhostingNoOp() { - var x [1]struct{} - _ = x[ActiveStopped-(0)] - _ = x[ActiveRunning-(1)] - _ = x[ActiveAlways-(2)] -} - -var _ToolGhostingNameToValueMap = map[string]ToolGhosting{ - `ActiveStopped`: 0, - `activestopped`: 0, - `ActiveRunning`: 1, - `activerunning`: 1, - `ActiveAlways`: 2, - `activealways`: 2, -} +var _ToolGhostingValueMap = map[string]ToolGhosting{`ActiveStopped`: 0, `ActiveRunning`: 1, `ActiveAlways`: 2} -var _ToolGhostingDescMap = map[ToolGhosting]string{ - 0: ``, - 1: ``, - 2: ``, -} +var _ToolGhostingDescMap = map[ToolGhosting]string{0: ``, 1: ``, 2: ``} -var _ToolGhostingMap = map[ToolGhosting]string{ - 0: `ActiveStopped`, - 1: `ActiveRunning`, - 2: `ActiveAlways`, -} +var _ToolGhostingMap = map[ToolGhosting]string{0: `ActiveStopped`, 1: `ActiveRunning`, 2: `ActiveAlways`} -// String returns the string representation -// of this ToolGhosting value. -func (i ToolGhosting) String() string { - if str, ok := _ToolGhostingMap[i]; ok { - return str - } - return strconv.FormatInt(int64(i), 10) -} +// String returns the string representation of this ToolGhosting value. +func (i ToolGhosting) String() string { return enums.String(i, _ToolGhostingMap) } -// SetString sets the ToolGhosting value from its -// string representation, and returns an -// error if the string is invalid. +// SetString sets the ToolGhosting value from its string representation, +// and returns an error if the string is invalid. func (i *ToolGhosting) SetString(s string) error { - if val, ok := _ToolGhostingNameToValueMap[s]; ok { - *i = val - return nil - } - if val, ok := _ToolGhostingNameToValueMap[strings.ToLower(s)]; ok { - *i = val - return nil - } - return errors.New(s + " is not a valid value for type ToolGhosting") + return enums.SetString(i, s, _ToolGhostingValueMap, "ToolGhosting") } // Int64 returns the ToolGhosting value as an int64. -func (i ToolGhosting) Int64() int64 { - return int64(i) -} +func (i ToolGhosting) Int64() int64 { return int64(i) } // SetInt64 sets the ToolGhosting value from an int64. -func (i *ToolGhosting) SetInt64(in int64) { - *i = ToolGhosting(in) -} +func (i *ToolGhosting) SetInt64(in int64) { *i = ToolGhosting(in) } // Desc returns the description of the ToolGhosting value. -func (i ToolGhosting) Desc() string { - if str, ok := _ToolGhostingDescMap[i]; ok { - return str - } - return i.String() -} +func (i ToolGhosting) Desc() string { return enums.Desc(i, _ToolGhostingDescMap) } -// ToolGhostingValues returns all possible values -// for the type ToolGhosting. -func ToolGhostingValues() []ToolGhosting { - return _ToolGhostingValues -} +// ToolGhostingValues returns all possible values for the type ToolGhosting. +func ToolGhostingValues() []ToolGhosting { return _ToolGhostingValues } -// Values returns all possible values -// for the type ToolGhosting. -func (i ToolGhosting) Values() []enums.Enum { - res := make([]enums.Enum, len(_ToolGhostingValues)) - for i, d := range _ToolGhostingValues { - res[i] = d - } - return res -} - -// IsValid returns whether the value is a -// valid option for type ToolGhosting. -func (i ToolGhosting) IsValid() bool { - _, ok := _ToolGhostingMap[i] - return ok -} +// Values returns all possible values for the type ToolGhosting. +func (i ToolGhosting) Values() []enums.Enum { return enums.Values(_ToolGhostingValues) } // MarshalText implements the [encoding.TextMarshaler] interface. -func (i ToolGhosting) MarshalText() ([]byte, error) { - return []byte(i.String()), nil -} +func (i ToolGhosting) MarshalText() ([]byte, error) { return []byte(i.String()), nil } // UnmarshalText implements the [encoding.TextUnmarshaler] interface. func (i *ToolGhosting) UnmarshalText(text []byte) error { - if err := i.SetString(string(text)); err != nil { - log.Println("ToolGhosting.UnmarshalText:", err) - } - return nil + return enums.UnmarshalText(i, text, "ToolGhosting") } diff --git a/egui/gtigen.go b/egui/gtigen.go index 692a0cff..0cca85b2 100644 --- a/egui/gtigen.go +++ b/egui/gtigen.go @@ -10,4 +10,4 @@ var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/egui.GUI", IDNa var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/egui.ToolbarItem", IDName: "toolbar-item", Doc: "ToolbarItem holds the configuration values for a toolbar item", Fields: []gti.Field{{Name: "Label"}, {Name: "Icon"}, {Name: "Tooltip"}, {Name: "Active"}, {Name: "Func"}}}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/egui.ToolGhosting", IDName: "tool-ghosting", Doc: "ToolGhosting the mode enum", Directives: []gti.Directive{{Tool: "go", Directive: "generate", Args: []string{"goki", "generate"}}, {Tool: "enums", Directive: "enum"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/egui.ToolGhosting", IDName: "tool-ghosting", Doc: "ToolGhosting the mode enum"}) diff --git a/emer/enumgen.go b/emer/enumgen.go index c239ffee..95fa2a46 100644 --- a/emer/enumgen.go +++ b/emer/enumgen.go @@ -3,248 +3,89 @@ package emer import ( - "errors" - "log" - "strconv" - "strings" - "cogentcore.org/core/enums" ) var _LayerTypeValues = []LayerType{0, 1, 2, 3} -// LayerTypeN is the highest valid value -// for type LayerType, plus one. +// LayerTypeN is the highest valid value for type LayerType, plus one. const LayerTypeN LayerType = 4 -// An "invalid array index" compiler error signifies that the constant values have changed. -// Re-run the enumgen command to generate them again. -func _LayerTypeNoOp() { - var x [1]struct{} - _ = x[Hidden-(0)] - _ = x[Input-(1)] - _ = x[Target-(2)] - _ = x[Compare-(3)] -} - -var _LayerTypeNameToValueMap = map[string]LayerType{ - `Hidden`: 0, - `hidden`: 0, - `Input`: 1, - `input`: 1, - `Target`: 2, - `target`: 2, - `Compare`: 3, - `compare`: 3, -} +var _LayerTypeValueMap = map[string]LayerType{`Hidden`: 0, `Input`: 1, `Target`: 2, `Compare`: 3} -var _LayerTypeDescMap = map[LayerType]string{ - 0: `Hidden is an internal representational layer that does not receive direct input / targets`, - 1: `Input is a layer that receives direct external input in its Ext inputs`, - 2: `Target is a layer that receives direct external target inputs used for driving plus-phase learning`, - 3: `Compare is a layer that receives external comparison inputs, which drive statistics but do NOT drive activation or learning directly`, -} +var _LayerTypeDescMap = map[LayerType]string{0: `Hidden is an internal representational layer that does not receive direct input / targets`, 1: `Input is a layer that receives direct external input in its Ext inputs`, 2: `Target is a layer that receives direct external target inputs used for driving plus-phase learning`, 3: `Compare is a layer that receives external comparison inputs, which drive statistics but do NOT drive activation or learning directly`} -var _LayerTypeMap = map[LayerType]string{ - 0: `Hidden`, - 1: `Input`, - 2: `Target`, - 3: `Compare`, -} +var _LayerTypeMap = map[LayerType]string{0: `Hidden`, 1: `Input`, 2: `Target`, 3: `Compare`} -// String returns the string representation -// of this LayerType value. -func (i LayerType) String() string { - if str, ok := _LayerTypeMap[i]; ok { - return str - } - return strconv.FormatInt(int64(i), 10) -} +// String returns the string representation of this LayerType value. +func (i LayerType) String() string { return enums.String(i, _LayerTypeMap) } -// SetString sets the LayerType value from its -// string representation, and returns an -// error if the string is invalid. +// SetString sets the LayerType value from its string representation, +// and returns an error if the string is invalid. func (i *LayerType) SetString(s string) error { - if val, ok := _LayerTypeNameToValueMap[s]; ok { - *i = val - return nil - } - if val, ok := _LayerTypeNameToValueMap[strings.ToLower(s)]; ok { - *i = val - return nil - } - return errors.New(s + " is not a valid value for type LayerType") + return enums.SetString(i, s, _LayerTypeValueMap, "LayerType") } // Int64 returns the LayerType value as an int64. -func (i LayerType) Int64() int64 { - return int64(i) -} +func (i LayerType) Int64() int64 { return int64(i) } // SetInt64 sets the LayerType value from an int64. -func (i *LayerType) SetInt64(in int64) { - *i = LayerType(in) -} +func (i *LayerType) SetInt64(in int64) { *i = LayerType(in) } // Desc returns the description of the LayerType value. -func (i LayerType) Desc() string { - if str, ok := _LayerTypeDescMap[i]; ok { - return str - } - return i.String() -} +func (i LayerType) Desc() string { return enums.Desc(i, _LayerTypeDescMap) } -// LayerTypeValues returns all possible values -// for the type LayerType. -func LayerTypeValues() []LayerType { - return _LayerTypeValues -} +// LayerTypeValues returns all possible values for the type LayerType. +func LayerTypeValues() []LayerType { return _LayerTypeValues } -// Values returns all possible values -// for the type LayerType. -func (i LayerType) Values() []enums.Enum { - res := make([]enums.Enum, len(_LayerTypeValues)) - for i, d := range _LayerTypeValues { - res[i] = d - } - return res -} - -// IsValid returns whether the value is a -// valid option for type LayerType. -func (i LayerType) IsValid() bool { - _, ok := _LayerTypeMap[i] - return ok -} +// Values returns all possible values for the type LayerType. +func (i LayerType) Values() []enums.Enum { return enums.Values(_LayerTypeValues) } // MarshalText implements the [encoding.TextMarshaler] interface. -func (i LayerType) MarshalText() ([]byte, error) { - return []byte(i.String()), nil -} +func (i LayerType) MarshalText() ([]byte, error) { return []byte(i.String()), nil } // UnmarshalText implements the [encoding.TextUnmarshaler] interface. func (i *LayerType) UnmarshalText(text []byte) error { - if err := i.SetString(string(text)); err != nil { - log.Println("LayerType.UnmarshalText:", err) - } - return nil + return enums.UnmarshalText(i, text, "LayerType") } var _PrjnTypeValues = []PrjnType{0, 1, 2, 3} -// PrjnTypeN is the highest valid value -// for type PrjnType, plus one. +// PrjnTypeN is the highest valid value for type PrjnType, plus one. const PrjnTypeN PrjnType = 4 -// An "invalid array index" compiler error signifies that the constant values have changed. -// Re-run the enumgen command to generate them again. -func _PrjnTypeNoOp() { - var x [1]struct{} - _ = x[Forward-(0)] - _ = x[Back-(1)] - _ = x[Lateral-(2)] - _ = x[Inhib-(3)] -} - -var _PrjnTypeNameToValueMap = map[string]PrjnType{ - `Forward`: 0, - `forward`: 0, - `Back`: 1, - `back`: 1, - `Lateral`: 2, - `lateral`: 2, - `Inhib`: 3, - `inhib`: 3, -} +var _PrjnTypeValueMap = map[string]PrjnType{`Forward`: 0, `Back`: 1, `Lateral`: 2, `Inhib`: 3} -var _PrjnTypeDescMap = map[PrjnType]string{ - 0: `Forward is a feedforward, bottom-up projection from sensory inputs to higher layers`, - 1: `Back is a feedback, top-down projection from higher layers back to lower layers`, - 2: `Lateral is a lateral projection within the same layer / area`, - 3: `Inhib is an inhibitory projection that drives inhibitory synaptic inputs instead of excitatory`, -} +var _PrjnTypeDescMap = map[PrjnType]string{0: `Forward is a feedforward, bottom-up projection from sensory inputs to higher layers`, 1: `Back is a feedback, top-down projection from higher layers back to lower layers`, 2: `Lateral is a lateral projection within the same layer / area`, 3: `Inhib is an inhibitory projection that drives inhibitory synaptic inputs instead of excitatory`} -var _PrjnTypeMap = map[PrjnType]string{ - 0: `Forward`, - 1: `Back`, - 2: `Lateral`, - 3: `Inhib`, -} +var _PrjnTypeMap = map[PrjnType]string{0: `Forward`, 1: `Back`, 2: `Lateral`, 3: `Inhib`} -// String returns the string representation -// of this PrjnType value. -func (i PrjnType) String() string { - if str, ok := _PrjnTypeMap[i]; ok { - return str - } - return strconv.FormatInt(int64(i), 10) -} +// String returns the string representation of this PrjnType value. +func (i PrjnType) String() string { return enums.String(i, _PrjnTypeMap) } -// SetString sets the PrjnType value from its -// string representation, and returns an -// error if the string is invalid. +// SetString sets the PrjnType value from its string representation, +// and returns an error if the string is invalid. func (i *PrjnType) SetString(s string) error { - if val, ok := _PrjnTypeNameToValueMap[s]; ok { - *i = val - return nil - } - if val, ok := _PrjnTypeNameToValueMap[strings.ToLower(s)]; ok { - *i = val - return nil - } - return errors.New(s + " is not a valid value for type PrjnType") + return enums.SetString(i, s, _PrjnTypeValueMap, "PrjnType") } // Int64 returns the PrjnType value as an int64. -func (i PrjnType) Int64() int64 { - return int64(i) -} +func (i PrjnType) Int64() int64 { return int64(i) } // SetInt64 sets the PrjnType value from an int64. -func (i *PrjnType) SetInt64(in int64) { - *i = PrjnType(in) -} +func (i *PrjnType) SetInt64(in int64) { *i = PrjnType(in) } // Desc returns the description of the PrjnType value. -func (i PrjnType) Desc() string { - if str, ok := _PrjnTypeDescMap[i]; ok { - return str - } - return i.String() -} +func (i PrjnType) Desc() string { return enums.Desc(i, _PrjnTypeDescMap) } -// PrjnTypeValues returns all possible values -// for the type PrjnType. -func PrjnTypeValues() []PrjnType { - return _PrjnTypeValues -} +// PrjnTypeValues returns all possible values for the type PrjnType. +func PrjnTypeValues() []PrjnType { return _PrjnTypeValues } -// Values returns all possible values -// for the type PrjnType. -func (i PrjnType) Values() []enums.Enum { - res := make([]enums.Enum, len(_PrjnTypeValues)) - for i, d := range _PrjnTypeValues { - res[i] = d - } - return res -} - -// IsValid returns whether the value is a -// valid option for type PrjnType. -func (i PrjnType) IsValid() bool { - _, ok := _PrjnTypeMap[i] - return ok -} +// Values returns all possible values for the type PrjnType. +func (i PrjnType) Values() []enums.Enum { return enums.Values(_PrjnTypeValues) } // MarshalText implements the [encoding.TextMarshaler] interface. -func (i PrjnType) MarshalText() ([]byte, error) { - return []byte(i.String()), nil -} +func (i PrjnType) MarshalText() ([]byte, error) { return []byte(i.String()), nil } // UnmarshalText implements the [encoding.TextUnmarshaler] interface. -func (i *PrjnType) UnmarshalText(text []byte) error { - if err := i.SetString(string(text)); err != nil { - log.Println("PrjnType.UnmarshalText:", err) - } - return nil -} +func (i *PrjnType) UnmarshalText(text []byte) error { return enums.UnmarshalText(i, text, "PrjnType") } diff --git a/emer/gtigen.go b/emer/gtigen.go index 3b3e03d0..14413737 100644 --- a/emer/gtigen.go +++ b/emer/gtigen.go @@ -10,7 +10,7 @@ var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/emer.Layer", ID var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/emer.Layers", IDName: "layers", Doc: "Layers is a slice of layers"}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/emer.LayerType", IDName: "layer-type", Doc: "LayerType is the type of the layer: Input, Hidden, Target, Compare.\nClass parameter styles automatically key off of these types.\nSpecialized algorithms can extend this to other types, but these types encompass\nmost standard neural network models.", Directives: []gti.Directive{{Tool: "enums", Directive: "enum"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/emer.LayerType", IDName: "layer-type", Doc: "LayerType is the type of the layer: Input, Hidden, Target, Compare.\nClass parameter styles automatically key off of these types.\nSpecialized algorithms can extend this to other types, but these types encompass\nmost standard neural network models."}) var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/emer.LayNames", IDName: "lay-names", Doc: "LayNames is a list of layer names.\nHas convenience methods for adding, validating."}) @@ -28,4 +28,4 @@ var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/emer.Prjn", IDN var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/emer.Prjns", IDName: "prjns", Doc: "Prjns is a slice of projections"}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/emer.PrjnType", IDName: "prjn-type", Doc: "PrjnType is the type of the projection (extensible for more specialized algorithms).\nClass parameter styles automatically key off of these types.", Directives: []gti.Directive{{Tool: "enums", Directive: "enum"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/emer.PrjnType", IDName: "prjn-type", Doc: "PrjnType is the type of the projection (extensible for more specialized algorithms).\nClass parameter styles automatically key off of these types."}) diff --git a/env/gtigen.go b/env/gtigen.go index 69b7cbc2..ff92a475 100644 --- a/env/gtigen.go +++ b/env/gtigen.go @@ -10,7 +10,7 @@ var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/env.Ctr", IDNam var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/env.Ctrs", IDName: "ctrs", Doc: "Ctrs contains an ordered slice of timescales,\nand a lookup map of counters by timescale\nused to manage counters in the Env.", Fields: []gti.Field{{Name: "Order", Doc: "ordered list of the counter timescales, from outer-most (highest) to inner-most (lowest)"}, {Name: "Ctrs", Doc: "map of the counters by timescale"}}}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/env.CurPrvF32", IDName: "cur-prv-f-32", Doc: "CurPrvF32 is basic state management for current and previous values, float32 values", Fields: []gti.Field{{Name: "Cur", Doc: "current value"}, {Name: "Prv", Doc: "previous value"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/env.CurPrvF32", IDName: "cur-prv-f32", Doc: "CurPrvF32 is basic state management for current and previous values, float32 values", Fields: []gti.Field{{Name: "Cur", Doc: "current value"}, {Name: "Prv", Doc: "previous value"}}}) var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/env.CurPrvInt", IDName: "cur-prv-int", Doc: "CurPrvInt is basic state management for current and previous values, int values", Fields: []gti.Field{{Name: "Cur", Doc: "current value"}, {Name: "Prv", Doc: "previous value"}}}) diff --git a/erand/distsplot/gtigen.go b/erand/distsplot/gtigen.go index 7bb15ced..31349489 100644 --- a/erand/distsplot/gtigen.go +++ b/erand/distsplot/gtigen.go @@ -3,7 +3,7 @@ package main import ( - "cogentcore.org/core/gti" + "goki.dev/gti" ) var _ = gti.AddType(>i.Type{Name: "main.Sim", IDName: "sim", Doc: "Sim holds the params, table, etc", Fields: []gti.Field{{Name: "Dist", Doc: "random params"}, {Name: "NSamp", Doc: "number of samples"}, {Name: "NBins", Doc: "number of bins in the histogram"}, {Name: "Range", Doc: "range for histogram"}, {Name: "Table", Doc: "table for raw data"}, {Name: "Hist", Doc: "histogram of data"}, {Name: "Plot", Doc: "the plot"}}}) diff --git a/erand/enumgen.go b/erand/enumgen.go index fa42f850..4de03872 100644 --- a/erand/enumgen.go +++ b/erand/enumgen.go @@ -3,144 +3,46 @@ package erand import ( - "errors" - "log" - "strconv" - "strings" - "cogentcore.org/core/enums" ) var _RndDistsValues = []RndDists{0, 1, 2, 3, 4, 5, 6} -// RndDistsN is the highest valid value -// for type RndDists, plus one. +// RndDistsN is the highest valid value for type RndDists, plus one. const RndDistsN RndDists = 7 -// An "invalid array index" compiler error signifies that the constant values have changed. -// Re-run the enumgen command to generate them again. -func _RndDistsNoOp() { - var x [1]struct{} - _ = x[Uniform-(0)] - _ = x[Binomial-(1)] - _ = x[Poisson-(2)] - _ = x[Gamma-(3)] - _ = x[Gaussian-(4)] - _ = x[Beta-(5)] - _ = x[Mean-(6)] -} - -var _RndDistsNameToValueMap = map[string]RndDists{ - `Uniform`: 0, - `uniform`: 0, - `Binomial`: 1, - `binomial`: 1, - `Poisson`: 2, - `poisson`: 2, - `Gamma`: 3, - `gamma`: 3, - `Gaussian`: 4, - `gaussian`: 4, - `Beta`: 5, - `beta`: 5, - `Mean`: 6, - `mean`: 6, -} +var _RndDistsValueMap = map[string]RndDists{`Uniform`: 0, `Binomial`: 1, `Poisson`: 2, `Gamma`: 3, `Gaussian`: 4, `Beta`: 5, `Mean`: 6} -var _RndDistsDescMap = map[RndDists]string{ - 0: `Uniform has a uniform probability distribution over Var = range on either side of the Mean`, - 1: `Binomial represents number of 1's in n (Par) random (Bernouli) trials of probability p (Var)`, - 2: `Poisson represents number of events in interval, with event rate (lambda = Var) plus Mean`, - 3: `Gamma represents maximum entropy distribution with two parameters: scaling parameter (Var) and shape parameter k (Par) plus Mean`, - 4: `Gaussian normal with Var = stddev plus Mean`, - 5: `Beta with Var = alpha and Par = beta shape parameters`, - 6: `Mean is just the constant Mean, no randomness`, -} +var _RndDistsDescMap = map[RndDists]string{0: `Uniform has a uniform probability distribution over Var = range on either side of the Mean`, 1: `Binomial represents number of 1's in n (Par) random (Bernouli) trials of probability p (Var)`, 2: `Poisson represents number of events in interval, with event rate (lambda = Var) plus Mean`, 3: `Gamma represents maximum entropy distribution with two parameters: scaling parameter (Var) and shape parameter k (Par) plus Mean`, 4: `Gaussian normal with Var = stddev plus Mean`, 5: `Beta with Var = alpha and Par = beta shape parameters`, 6: `Mean is just the constant Mean, no randomness`} -var _RndDistsMap = map[RndDists]string{ - 0: `Uniform`, - 1: `Binomial`, - 2: `Poisson`, - 3: `Gamma`, - 4: `Gaussian`, - 5: `Beta`, - 6: `Mean`, -} +var _RndDistsMap = map[RndDists]string{0: `Uniform`, 1: `Binomial`, 2: `Poisson`, 3: `Gamma`, 4: `Gaussian`, 5: `Beta`, 6: `Mean`} -// String returns the string representation -// of this RndDists value. -func (i RndDists) String() string { - if str, ok := _RndDistsMap[i]; ok { - return str - } - return strconv.FormatInt(int64(i), 10) -} +// String returns the string representation of this RndDists value. +func (i RndDists) String() string { return enums.String(i, _RndDistsMap) } -// SetString sets the RndDists value from its -// string representation, and returns an -// error if the string is invalid. +// SetString sets the RndDists value from its string representation, +// and returns an error if the string is invalid. func (i *RndDists) SetString(s string) error { - if val, ok := _RndDistsNameToValueMap[s]; ok { - *i = val - return nil - } - if val, ok := _RndDistsNameToValueMap[strings.ToLower(s)]; ok { - *i = val - return nil - } - return errors.New(s + " is not a valid value for type RndDists") + return enums.SetString(i, s, _RndDistsValueMap, "RndDists") } // Int64 returns the RndDists value as an int64. -func (i RndDists) Int64() int64 { - return int64(i) -} +func (i RndDists) Int64() int64 { return int64(i) } // SetInt64 sets the RndDists value from an int64. -func (i *RndDists) SetInt64(in int64) { - *i = RndDists(in) -} +func (i *RndDists) SetInt64(in int64) { *i = RndDists(in) } // Desc returns the description of the RndDists value. -func (i RndDists) Desc() string { - if str, ok := _RndDistsDescMap[i]; ok { - return str - } - return i.String() -} - -// RndDistsValues returns all possible values -// for the type RndDists. -func RndDistsValues() []RndDists { - return _RndDistsValues -} +func (i RndDists) Desc() string { return enums.Desc(i, _RndDistsDescMap) } -// Values returns all possible values -// for the type RndDists. -func (i RndDists) Values() []enums.Enum { - res := make([]enums.Enum, len(_RndDistsValues)) - for i, d := range _RndDistsValues { - res[i] = d - } - return res -} +// RndDistsValues returns all possible values for the type RndDists. +func RndDistsValues() []RndDists { return _RndDistsValues } -// IsValid returns whether the value is a -// valid option for type RndDists. -func (i RndDists) IsValid() bool { - _, ok := _RndDistsMap[i] - return ok -} +// Values returns all possible values for the type RndDists. +func (i RndDists) Values() []enums.Enum { return enums.Values(_RndDistsValues) } // MarshalText implements the [encoding.TextMarshaler] interface. -func (i RndDists) MarshalText() ([]byte, error) { - return []byte(i.String()), nil -} +func (i RndDists) MarshalText() ([]byte, error) { return []byte(i.String()), nil } // UnmarshalText implements the [encoding.TextUnmarshaler] interface. -func (i *RndDists) UnmarshalText(text []byte) error { - if err := i.SetString(string(text)); err != nil { - log.Println("RndDists.UnmarshalText:", err) - } - return nil -} +func (i *RndDists) UnmarshalText(text []byte) error { return enums.UnmarshalText(i, text, "RndDists") } diff --git a/erand/gtigen.go b/erand/gtigen.go index ce0e67bf..9f471fed 100644 --- a/erand/gtigen.go +++ b/erand/gtigen.go @@ -10,8 +10,8 @@ var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/erand.Rand", ID var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/erand.SysRand", IDName: "sys-rand", Doc: "SysRand supports the system random number generator\nfor either a separate rand.Rand source, or, if that\nis nil, the global rand stream.", Fields: []gti.Field{{Name: "Rand", Doc: "if non-nil, use this random number source instead of the global default one"}}}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/erand.RndParams", IDName: "rnd-params", Doc: "RndParams provides parameterized random number generation according to different distributions\nand variance, mean params", Directives: []gti.Directive{{Tool: "go", Directive: "generate", Args: []string{"goki", "generate"}}, {Tool: "git", Directive: "add"}}, Fields: []gti.Field{{Name: "Dist", Doc: "distribution to generate random numbers from"}, {Name: "Mean", Doc: "mean of random distribution -- typically added to generated random variants"}, {Name: "Var", Doc: "variability parameter for the random numbers (gauss = standard deviation, not variance; uniform = half-range, others as noted in RndDists)"}, {Name: "Par", Doc: "extra parameter for distribution (depends on each one)"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/erand.RndParams", IDName: "rnd-params", Doc: "RndParams provides parameterized random number generation according to different distributions\nand variance, mean params", Directives: []gti.Directive{{Tool: "go", Directive: "generate", Args: []string{"core", "generate"}}, {Tool: "git", Directive: "add"}}, Fields: []gti.Field{{Name: "Dist", Doc: "distribution to generate random numbers from"}, {Name: "Mean", Doc: "mean of random distribution -- typically added to generated random variants"}, {Name: "Var", Doc: "variability parameter for the random numbers (gauss = standard deviation, not variance; uniform = half-range, others as noted in RndDists)"}, {Name: "Par", Doc: "extra parameter for distribution (depends on each one)"}}}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/erand.RndDists", IDName: "rnd-dists", Doc: "RndDists are different random number distributions", Directives: []gti.Directive{{Tool: "enums", Directive: "enum"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/erand.RndDists", IDName: "rnd-dists", Doc: "RndDists are different random number distributions"}) var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/erand.Seeds", IDName: "seeds", Doc: "Seeds is a set of random seeds, typically used one per Run"}) diff --git a/esg/enumgen.go b/esg/enumgen.go index ec494d9e..cd27cf7f 100644 --- a/esg/enumgen.go +++ b/esg/enumgen.go @@ -3,367 +3,130 @@ package esg import ( - "errors" - "log" - "strconv" - "strings" - "cogentcore.org/core/enums" ) var _CondElsValues = []CondEls{0, 1, 2, 3, 4} -// CondElsN is the highest valid value -// for type CondEls, plus one. +// CondElsN is the highest valid value for type CondEls, plus one. const CondElsN CondEls = 5 -// An "invalid array index" compiler error signifies that the constant values have changed. -// Re-run the enumgen command to generate them again. -func _CondElsNoOp() { - var x [1]struct{} - _ = x[CRule-(0)] - _ = x[And-(1)] - _ = x[Or-(2)] - _ = x[Not-(3)] - _ = x[SubCond-(4)] -} - -var _CondElsNameToValueMap = map[string]CondEls{ - `CRule`: 0, - `crule`: 0, - `And`: 1, - `and`: 1, - `Or`: 2, - `or`: 2, - `Not`: 3, - `not`: 3, - `SubCond`: 4, - `subcond`: 4, -} +var _CondElsValueMap = map[string]CondEls{`CRule`: 0, `And`: 1, `Or`: 2, `Not`: 3, `SubCond`: 4} -var _CondElsDescMap = map[CondEls]string{ - 0: `CRule means Rule is name of a rule to evaluate truth value`, - 1: ``, - 2: ``, - 3: ``, - 4: `SubCond is a sub-condition expression`, -} +var _CondElsDescMap = map[CondEls]string{0: `CRule means Rule is name of a rule to evaluate truth value`, 1: ``, 2: ``, 3: ``, 4: `SubCond is a sub-condition expression`} -var _CondElsMap = map[CondEls]string{ - 0: `CRule`, - 1: `And`, - 2: `Or`, - 3: `Not`, - 4: `SubCond`, -} +var _CondElsMap = map[CondEls]string{0: `CRule`, 1: `And`, 2: `Or`, 3: `Not`, 4: `SubCond`} -// String returns the string representation -// of this CondEls value. -func (i CondEls) String() string { - if str, ok := _CondElsMap[i]; ok { - return str - } - return strconv.FormatInt(int64(i), 10) -} +// String returns the string representation of this CondEls value. +func (i CondEls) String() string { return enums.String(i, _CondElsMap) } -// SetString sets the CondEls value from its -// string representation, and returns an -// error if the string is invalid. +// SetString sets the CondEls value from its string representation, +// and returns an error if the string is invalid. func (i *CondEls) SetString(s string) error { - if val, ok := _CondElsNameToValueMap[s]; ok { - *i = val - return nil - } - if val, ok := _CondElsNameToValueMap[strings.ToLower(s)]; ok { - *i = val - return nil - } - return errors.New(s + " is not a valid value for type CondEls") + return enums.SetString(i, s, _CondElsValueMap, "CondEls") } // Int64 returns the CondEls value as an int64. -func (i CondEls) Int64() int64 { - return int64(i) -} +func (i CondEls) Int64() int64 { return int64(i) } // SetInt64 sets the CondEls value from an int64. -func (i *CondEls) SetInt64(in int64) { - *i = CondEls(in) -} +func (i *CondEls) SetInt64(in int64) { *i = CondEls(in) } // Desc returns the description of the CondEls value. -func (i CondEls) Desc() string { - if str, ok := _CondElsDescMap[i]; ok { - return str - } - return i.String() -} +func (i CondEls) Desc() string { return enums.Desc(i, _CondElsDescMap) } -// CondElsValues returns all possible values -// for the type CondEls. -func CondElsValues() []CondEls { - return _CondElsValues -} +// CondElsValues returns all possible values for the type CondEls. +func CondElsValues() []CondEls { return _CondElsValues } -// Values returns all possible values -// for the type CondEls. -func (i CondEls) Values() []enums.Enum { - res := make([]enums.Enum, len(_CondElsValues)) - for i, d := range _CondElsValues { - res[i] = d - } - return res -} - -// IsValid returns whether the value is a -// valid option for type CondEls. -func (i CondEls) IsValid() bool { - _, ok := _CondElsMap[i] - return ok -} +// Values returns all possible values for the type CondEls. +func (i CondEls) Values() []enums.Enum { return enums.Values(_CondElsValues) } // MarshalText implements the [encoding.TextMarshaler] interface. -func (i CondEls) MarshalText() ([]byte, error) { - return []byte(i.String()), nil -} +func (i CondEls) MarshalText() ([]byte, error) { return []byte(i.String()), nil } // UnmarshalText implements the [encoding.TextUnmarshaler] interface. -func (i *CondEls) UnmarshalText(text []byte) error { - if err := i.SetString(string(text)); err != nil { - log.Println("CondEls.UnmarshalText:", err) - } - return nil -} +func (i *CondEls) UnmarshalText(text []byte) error { return enums.UnmarshalText(i, text, "CondEls") } var _ElementsValues = []Elements{0, 1} -// ElementsN is the highest valid value -// for type Elements, plus one. +// ElementsN is the highest valid value for type Elements, plus one. const ElementsN Elements = 2 -// An "invalid array index" compiler error signifies that the constant values have changed. -// Re-run the enumgen command to generate them again. -func _ElementsNoOp() { - var x [1]struct{} - _ = x[RuleEl-(0)] - _ = x[TokenEl-(1)] -} +var _ElementsValueMap = map[string]Elements{`RuleEl`: 0, `TokenEl`: 1} -var _ElementsNameToValueMap = map[string]Elements{ - `RuleEl`: 0, - `ruleel`: 0, - `TokenEl`: 1, - `tokenel`: 1, -} +var _ElementsDescMap = map[Elements]string{0: `RuleEl means Value is name of a rule`, 1: `TokenEl means Value is a token to emit`} -var _ElementsDescMap = map[Elements]string{ - 0: `RuleEl means Value is name of a rule`, - 1: `TokenEl means Value is a token to emit`, -} +var _ElementsMap = map[Elements]string{0: `RuleEl`, 1: `TokenEl`} -var _ElementsMap = map[Elements]string{ - 0: `RuleEl`, - 1: `TokenEl`, -} +// String returns the string representation of this Elements value. +func (i Elements) String() string { return enums.String(i, _ElementsMap) } -// String returns the string representation -// of this Elements value. -func (i Elements) String() string { - if str, ok := _ElementsMap[i]; ok { - return str - } - return strconv.FormatInt(int64(i), 10) -} - -// SetString sets the Elements value from its -// string representation, and returns an -// error if the string is invalid. +// SetString sets the Elements value from its string representation, +// and returns an error if the string is invalid. func (i *Elements) SetString(s string) error { - if val, ok := _ElementsNameToValueMap[s]; ok { - *i = val - return nil - } - if val, ok := _ElementsNameToValueMap[strings.ToLower(s)]; ok { - *i = val - return nil - } - return errors.New(s + " is not a valid value for type Elements") + return enums.SetString(i, s, _ElementsValueMap, "Elements") } // Int64 returns the Elements value as an int64. -func (i Elements) Int64() int64 { - return int64(i) -} +func (i Elements) Int64() int64 { return int64(i) } // SetInt64 sets the Elements value from an int64. -func (i *Elements) SetInt64(in int64) { - *i = Elements(in) -} +func (i *Elements) SetInt64(in int64) { *i = Elements(in) } // Desc returns the description of the Elements value. -func (i Elements) Desc() string { - if str, ok := _ElementsDescMap[i]; ok { - return str - } - return i.String() -} - -// ElementsValues returns all possible values -// for the type Elements. -func ElementsValues() []Elements { - return _ElementsValues -} +func (i Elements) Desc() string { return enums.Desc(i, _ElementsDescMap) } -// Values returns all possible values -// for the type Elements. -func (i Elements) Values() []enums.Enum { - res := make([]enums.Enum, len(_ElementsValues)) - for i, d := range _ElementsValues { - res[i] = d - } - return res -} +// ElementsValues returns all possible values for the type Elements. +func ElementsValues() []Elements { return _ElementsValues } -// IsValid returns whether the value is a -// valid option for type Elements. -func (i Elements) IsValid() bool { - _, ok := _ElementsMap[i] - return ok -} +// Values returns all possible values for the type Elements. +func (i Elements) Values() []enums.Enum { return enums.Values(_ElementsValues) } // MarshalText implements the [encoding.TextMarshaler] interface. -func (i Elements) MarshalText() ([]byte, error) { - return []byte(i.String()), nil -} +func (i Elements) MarshalText() ([]byte, error) { return []byte(i.String()), nil } // UnmarshalText implements the [encoding.TextUnmarshaler] interface. -func (i *Elements) UnmarshalText(text []byte) error { - if err := i.SetString(string(text)); err != nil { - log.Println("Elements.UnmarshalText:", err) - } - return nil -} +func (i *Elements) UnmarshalText(text []byte) error { return enums.UnmarshalText(i, text, "Elements") } var _RuleTypesValues = []RuleTypes{0, 1, 2, 3, 4} -// RuleTypesN is the highest valid value -// for type RuleTypes, plus one. +// RuleTypesN is the highest valid value for type RuleTypes, plus one. const RuleTypesN RuleTypes = 5 -// An "invalid array index" compiler error signifies that the constant values have changed. -// Re-run the enumgen command to generate them again. -func _RuleTypesNoOp() { - var x [1]struct{} - _ = x[UniformItems-(0)] - _ = x[ProbItems-(1)] - _ = x[CondItems-(2)] - _ = x[SequentialItems-(3)] - _ = x[PermutedItems-(4)] -} - -var _RuleTypesNameToValueMap = map[string]RuleTypes{ - `UniformItems`: 0, - `uniformitems`: 0, - `ProbItems`: 1, - `probitems`: 1, - `CondItems`: 2, - `conditems`: 2, - `SequentialItems`: 3, - `sequentialitems`: 3, - `PermutedItems`: 4, - `permuteditems`: 4, -} +var _RuleTypesValueMap = map[string]RuleTypes{`UniformItems`: 0, `ProbItems`: 1, `CondItems`: 2, `SequentialItems`: 3, `PermutedItems`: 4} -var _RuleTypesDescMap = map[RuleTypes]string{ - 0: `UniformItems is the default mutually exclusive items chosen at uniform random`, - 1: `ProbItems has specific probabilities for each item`, - 2: `CondItems has conditionals for each item, indicated by ?`, - 3: `SequentialItems progresses through items in sequential order, indicated by |`, - 4: `PermutedItems progresses through items in permuted order, indicated by $`, -} +var _RuleTypesDescMap = map[RuleTypes]string{0: `UniformItems is the default mutually exclusive items chosen at uniform random`, 1: `ProbItems has specific probabilities for each item`, 2: `CondItems has conditionals for each item, indicated by ?`, 3: `SequentialItems progresses through items in sequential order, indicated by |`, 4: `PermutedItems progresses through items in permuted order, indicated by $`} -var _RuleTypesMap = map[RuleTypes]string{ - 0: `UniformItems`, - 1: `ProbItems`, - 2: `CondItems`, - 3: `SequentialItems`, - 4: `PermutedItems`, -} +var _RuleTypesMap = map[RuleTypes]string{0: `UniformItems`, 1: `ProbItems`, 2: `CondItems`, 3: `SequentialItems`, 4: `PermutedItems`} -// String returns the string representation -// of this RuleTypes value. -func (i RuleTypes) String() string { - if str, ok := _RuleTypesMap[i]; ok { - return str - } - return strconv.FormatInt(int64(i), 10) -} +// String returns the string representation of this RuleTypes value. +func (i RuleTypes) String() string { return enums.String(i, _RuleTypesMap) } -// SetString sets the RuleTypes value from its -// string representation, and returns an -// error if the string is invalid. +// SetString sets the RuleTypes value from its string representation, +// and returns an error if the string is invalid. func (i *RuleTypes) SetString(s string) error { - if val, ok := _RuleTypesNameToValueMap[s]; ok { - *i = val - return nil - } - if val, ok := _RuleTypesNameToValueMap[strings.ToLower(s)]; ok { - *i = val - return nil - } - return errors.New(s + " is not a valid value for type RuleTypes") + return enums.SetString(i, s, _RuleTypesValueMap, "RuleTypes") } // Int64 returns the RuleTypes value as an int64. -func (i RuleTypes) Int64() int64 { - return int64(i) -} +func (i RuleTypes) Int64() int64 { return int64(i) } // SetInt64 sets the RuleTypes value from an int64. -func (i *RuleTypes) SetInt64(in int64) { - *i = RuleTypes(in) -} +func (i *RuleTypes) SetInt64(in int64) { *i = RuleTypes(in) } // Desc returns the description of the RuleTypes value. -func (i RuleTypes) Desc() string { - if str, ok := _RuleTypesDescMap[i]; ok { - return str - } - return i.String() -} +func (i RuleTypes) Desc() string { return enums.Desc(i, _RuleTypesDescMap) } -// RuleTypesValues returns all possible values -// for the type RuleTypes. -func RuleTypesValues() []RuleTypes { - return _RuleTypesValues -} +// RuleTypesValues returns all possible values for the type RuleTypes. +func RuleTypesValues() []RuleTypes { return _RuleTypesValues } -// Values returns all possible values -// for the type RuleTypes. -func (i RuleTypes) Values() []enums.Enum { - res := make([]enums.Enum, len(_RuleTypesValues)) - for i, d := range _RuleTypesValues { - res[i] = d - } - return res -} - -// IsValid returns whether the value is a -// valid option for type RuleTypes. -func (i RuleTypes) IsValid() bool { - _, ok := _RuleTypesMap[i] - return ok -} +// Values returns all possible values for the type RuleTypes. +func (i RuleTypes) Values() []enums.Enum { return enums.Values(_RuleTypesValues) } // MarshalText implements the [encoding.TextMarshaler] interface. -func (i RuleTypes) MarshalText() ([]byte, error) { - return []byte(i.String()), nil -} +func (i RuleTypes) MarshalText() ([]byte, error) { return []byte(i.String()), nil } // UnmarshalText implements the [encoding.TextUnmarshaler] interface. func (i *RuleTypes) UnmarshalText(text []byte) error { - if err := i.SetString(string(text)); err != nil { - log.Println("RuleTypes.UnmarshalText:", err) - } - return nil + return enums.UnmarshalText(i, text, "RuleTypes") } diff --git a/esg/gtigen.go b/esg/gtigen.go index 21cc1822..2c6e4b57 100644 --- a/esg/gtigen.go +++ b/esg/gtigen.go @@ -10,17 +10,17 @@ var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/esg.Conds", IDN var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/esg.Cond", IDName: "cond", Doc: "Cond is one element of a conditional", Fields: []gti.Field{{Name: "El", Doc: "what type of conditional element is this"}, {Name: "Rule", Doc: "name of rule or token to evaluate for CRule"}, {Name: "Conds", Doc: "sub-conditions for SubCond"}}}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/esg.CondEls", IDName: "cond-els", Doc: "CondEls are different types of conditional elements", Directives: []gti.Directive{{Tool: "enums", Directive: "enum"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/esg.CondEls", IDName: "cond-els", Doc: "CondEls are different types of conditional elements"}) var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/esg.Item", IDName: "item", Doc: "Item is one item within a rule", Directives: []gti.Directive{{Tool: "git", Directive: "add"}}, Fields: []gti.Field{{Name: "Prob", Doc: "probability for choosing this item -- 0 if uniform random"}, {Name: "Elems", Doc: "elements of the rule -- for non-Cond rules"}, {Name: "Cond", Doc: "conditions for this item -- specified by ?"}, {Name: "SubRule", Doc: "for conditional, this is the sub-rule that is run with sub-items"}, {Name: "State", Doc: "state update name=value to set for rule"}}}) var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/esg.Elem", IDName: "elem", Doc: "Elem is one elemenent in a concrete Item: either rule or token", Directives: []gti.Directive{{Tool: "git", Directive: "add"}}, Fields: []gti.Field{{Name: "El", Doc: "type of element: Rule, Token, or SubItems"}, {Name: "Value", Doc: "value of the token: name of Rule or Token"}}}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/esg.Elements", IDName: "elements", Doc: "Elements are different types of elements", Directives: []gti.Directive{{Tool: "enums", Directive: "enum"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/esg.Elements", IDName: "elements", Doc: "Elements are different types of elements"}) var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/esg.State", IDName: "state", Doc: "State holds the name=value state settings associated with rule or item\nas a string, string map"}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/esg.RuleTypes", IDName: "rule-types", Doc: "RuleTypes are different types of rules (i.e., how the items are selected)", Directives: []gti.Directive{{Tool: "enums", Directive: "enum"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/esg.RuleTypes", IDName: "rule-types", Doc: "RuleTypes are different types of rules (i.e., how the items are selected)"}) var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/esg.Rule", IDName: "rule", Doc: "Rule is one rule containing some number of items", Directives: []gti.Directive{{Tool: "git", Directive: "add"}}, Fields: []gti.Field{{Name: "Name", Doc: "name of rule"}, {Name: "Desc", Doc: "description / notes on rule"}, {Name: "Type", Doc: "type of rule -- how to choose the items"}, {Name: "Items", Doc: "items in rule"}, {Name: "State", Doc: "state update for rule"}, {Name: "PrevIdx", Doc: "previously selected item (from perspective of current rule)"}, {Name: "CurIdx", Doc: "current index in Items (what will be used next)"}, {Name: "RepeatP", Doc: "probability of repeating same item -- signaled by =%p"}, {Name: "Order", Doc: "permuted order if doing that"}}}) diff --git a/etime/enumgen.go b/etime/enumgen.go index b483069d..dc4693f6 100644 --- a/etime/enumgen.go +++ b/etime/enumgen.go @@ -3,343 +3,83 @@ package etime import ( - "errors" - "log" - "strconv" - "strings" - "cogentcore.org/core/enums" ) var _ModesValues = []Modes{0, 1, 2, 3, 4, 5, 6} -// ModesN is the highest valid value -// for type Modes, plus one. +// ModesN is the highest valid value for type Modes, plus one. const ModesN Modes = 7 -// An "invalid array index" compiler error signifies that the constant values have changed. -// Re-run the enumgen command to generate them again. -func _ModesNoOp() { - var x [1]struct{} - _ = x[NoEvalMode-(0)] - _ = x[AllModes-(1)] - _ = x[Train-(2)] - _ = x[Test-(3)] - _ = x[Validate-(4)] - _ = x[Analyze-(5)] - _ = x[Debug-(6)] -} - -var _ModesNameToValueMap = map[string]Modes{ - `NoEvalMode`: 0, - `noevalmode`: 0, - `AllModes`: 1, - `allmodes`: 1, - `Train`: 2, - `train`: 2, - `Test`: 3, - `test`: 3, - `Validate`: 4, - `validate`: 4, - `Analyze`: 5, - `analyze`: 5, - `Debug`: 6, - `debug`: 6, -} +var _ModesValueMap = map[string]Modes{`NoEvalMode`: 0, `AllModes`: 1, `Train`: 2, `Test`: 3, `Validate`: 4, `Analyze`: 5, `Debug`: 6} -var _ModesDescMap = map[Modes]string{ - 0: ``, - 1: `AllModes indicates that the log should occur over all modes present in other items.`, - 2: `Train is when the network is learning`, - 3: `Test is when testing, typically without learning`, - 4: `Validate is typically for a special held-out testing set`, - 5: `Analyze is when analyzing the representations and behavior of the network`, - 6: `Debug is for recording info particularly useful for debugging`, -} +var _ModesDescMap = map[Modes]string{0: ``, 1: `AllModes indicates that the log should occur over all modes present in other items.`, 2: `Train is when the network is learning`, 3: `Test is when testing, typically without learning`, 4: `Validate is typically for a special held-out testing set`, 5: `Analyze is when analyzing the representations and behavior of the network`, 6: `Debug is for recording info particularly useful for debugging`} -var _ModesMap = map[Modes]string{ - 0: `NoEvalMode`, - 1: `AllModes`, - 2: `Train`, - 3: `Test`, - 4: `Validate`, - 5: `Analyze`, - 6: `Debug`, -} +var _ModesMap = map[Modes]string{0: `NoEvalMode`, 1: `AllModes`, 2: `Train`, 3: `Test`, 4: `Validate`, 5: `Analyze`, 6: `Debug`} -// String returns the string representation -// of this Modes value. -func (i Modes) String() string { - if str, ok := _ModesMap[i]; ok { - return str - } - return strconv.FormatInt(int64(i), 10) -} +// String returns the string representation of this Modes value. +func (i Modes) String() string { return enums.String(i, _ModesMap) } -// SetString sets the Modes value from its -// string representation, and returns an -// error if the string is invalid. -func (i *Modes) SetString(s string) error { - if val, ok := _ModesNameToValueMap[s]; ok { - *i = val - return nil - } - if val, ok := _ModesNameToValueMap[strings.ToLower(s)]; ok { - *i = val - return nil - } - return errors.New(s + " is not a valid value for type Modes") -} +// SetString sets the Modes value from its string representation, +// and returns an error if the string is invalid. +func (i *Modes) SetString(s string) error { return enums.SetString(i, s, _ModesValueMap, "Modes") } // Int64 returns the Modes value as an int64. -func (i Modes) Int64() int64 { - return int64(i) -} +func (i Modes) Int64() int64 { return int64(i) } // SetInt64 sets the Modes value from an int64. -func (i *Modes) SetInt64(in int64) { - *i = Modes(in) -} +func (i *Modes) SetInt64(in int64) { *i = Modes(in) } // Desc returns the description of the Modes value. -func (i Modes) Desc() string { - if str, ok := _ModesDescMap[i]; ok { - return str - } - return i.String() -} - -// ModesValues returns all possible values -// for the type Modes. -func ModesValues() []Modes { - return _ModesValues -} +func (i Modes) Desc() string { return enums.Desc(i, _ModesDescMap) } -// Values returns all possible values -// for the type Modes. -func (i Modes) Values() []enums.Enum { - res := make([]enums.Enum, len(_ModesValues)) - for i, d := range _ModesValues { - res[i] = d - } - return res -} +// ModesValues returns all possible values for the type Modes. +func ModesValues() []Modes { return _ModesValues } -// IsValid returns whether the value is a -// valid option for type Modes. -func (i Modes) IsValid() bool { - _, ok := _ModesMap[i] - return ok -} +// Values returns all possible values for the type Modes. +func (i Modes) Values() []enums.Enum { return enums.Values(_ModesValues) } // MarshalText implements the [encoding.TextMarshaler] interface. -func (i Modes) MarshalText() ([]byte, error) { - return []byte(i.String()), nil -} +func (i Modes) MarshalText() ([]byte, error) { return []byte(i.String()), nil } // UnmarshalText implements the [encoding.TextUnmarshaler] interface. -func (i *Modes) UnmarshalText(text []byte) error { - if err := i.SetString(string(text)); err != nil { - log.Println("Modes.UnmarshalText:", err) - } - return nil -} +func (i *Modes) UnmarshalText(text []byte) error { return enums.UnmarshalText(i, text, "Modes") } var _TimesValues = []Times{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19} -// TimesN is the highest valid value -// for type Times, plus one. +// TimesN is the highest valid value for type Times, plus one. const TimesN Times = 20 -// An "invalid array index" compiler error signifies that the constant values have changed. -// Re-run the enumgen command to generate them again. -func _TimesNoOp() { - var x [1]struct{} - _ = x[NoTime-(0)] - _ = x[AllTimes-(1)] - _ = x[Cycle-(2)] - _ = x[FastSpike-(3)] - _ = x[GammaCycle-(4)] - _ = x[Phase-(5)] - _ = x[BetaCycle-(6)] - _ = x[AlphaCycle-(7)] - _ = x[ThetaCycle-(8)] - _ = x[Event-(9)] - _ = x[Trial-(10)] - _ = x[Tick-(11)] - _ = x[Sequence-(12)] - _ = x[Epoch-(13)] - _ = x[Block-(14)] - _ = x[Condition-(15)] - _ = x[Run-(16)] - _ = x[Expt-(17)] - _ = x[Scene-(18)] - _ = x[Episode-(19)] -} +var _TimesValueMap = map[string]Times{`NoTime`: 0, `AllTimes`: 1, `Cycle`: 2, `FastSpike`: 3, `GammaCycle`: 4, `Phase`: 5, `BetaCycle`: 6, `AlphaCycle`: 7, `ThetaCycle`: 8, `Event`: 9, `Trial`: 10, `Tick`: 11, `Sequence`: 12, `Epoch`: 13, `Block`: 14, `Condition`: 15, `Run`: 16, `Expt`: 17, `Scene`: 18, `Episode`: 19} -var _TimesNameToValueMap = map[string]Times{ - `NoTime`: 0, - `notime`: 0, - `AllTimes`: 1, - `alltimes`: 1, - `Cycle`: 2, - `cycle`: 2, - `FastSpike`: 3, - `fastspike`: 3, - `GammaCycle`: 4, - `gammacycle`: 4, - `Phase`: 5, - `phase`: 5, - `BetaCycle`: 6, - `betacycle`: 6, - `AlphaCycle`: 7, - `alphacycle`: 7, - `ThetaCycle`: 8, - `thetacycle`: 8, - `Event`: 9, - `event`: 9, - `Trial`: 10, - `trial`: 10, - `Tick`: 11, - `tick`: 11, - `Sequence`: 12, - `sequence`: 12, - `Epoch`: 13, - `epoch`: 13, - `Block`: 14, - `block`: 14, - `Condition`: 15, - `condition`: 15, - `Run`: 16, - `run`: 16, - `Expt`: 17, - `expt`: 17, - `Scene`: 18, - `scene`: 18, - `Episode`: 19, - `episode`: 19, -} +var _TimesDescMap = map[Times]string{0: `NoTime represents a non-initialized value, or a null result`, 1: `AllTimes indicates that the log should occur over all times present in other items.`, 2: `Cycle is the finest time scale -- typically 1 msec -- a single activation update.`, 3: `FastSpike is typically 10 cycles = 10 msec (100hz) = the fastest spiking time generally observed in the brain. This can be useful for visualizing updates at a granularity in between Cycle and GammaCycle.`, 4: `GammaCycle is typically 25 cycles = 25 msec (40hz)`, 5: `Phase is typically a Minus or Plus phase, where plus phase is bursting / outcome that drives positive learning relative to prediction in minus phase. It can also be used for other time scales involving multiple Cycles.`, 6: `BetaCycle is typically 50 cycles = 50 msec (20 hz) = one beta-frequency cycle. Gating in the basal ganglia and associated updating in prefrontal cortex occurs at this frequency.`, 7: `AlphaCycle is typically 100 cycles = 100 msec (10 hz) = one alpha-frequency cycle.`, 8: `ThetaCycle is typically 200 cycles = 200 msec (5 hz) = two alpha-frequency cycles. This is the modal duration of a saccade, the update frequency of medial temporal lobe episodic memory, and the minimal predictive learning cycle (perceive an Alpha 1, predict on 2).`, 9: `Event is the smallest unit of naturalistic experience that coheres unto itself (e.g., something that could be described in a sentence). Typically this is on the time scale of a few seconds: e.g., reaching for something, catching a ball.`, 10: `Trial is one unit of behavior in an experiment -- it is typically environmentally defined instead of endogenously defined in terms of basic brain rhythms. In the minimal case it could be one ThetaCycle, but could be multiple, and could encompass multiple Events (e.g., one event is fixation, next is stimulus, last is response)`, 11: `Tick is one step in a sequence -- often it is useful to have Trial count up throughout the entire Epoch but also include a Tick to count trials within a Sequence`, 12: `Sequence is a sequential group of Trials (not always needed).`, 13: `Epoch is used in two different contexts. In machine learning, it represents a collection of Trials, Sequences or Events that constitute a "representative sample" of the environment. In the simplest case, it is the entire collection of Trials used for training. In electrophysiology, it is a timing window used for organizing the analysis of electrode data.`, 14: `Block is a collection of Trials, Sequences or Events, often used in experiments when conditions are varied across blocks.`, 15: `Condition is a collection of Blocks that share the same set of parameters. This is intermediate between Block and Run levels. Aggregation of stats at this level is based on the last 5 rows by default.`, 16: `Run is a complete run of a model / subject, from training to testing, etc. Often multiple runs are done in an Expt to obtain statistics over initial random weights etc. Aggregation of stats at this level is based on the last 5 rows by default.`, 17: `Expt is an entire experiment -- multiple Runs through a given protocol / set of parameters.`, 18: `Scene is a sequence of events that constitutes the next larger-scale coherent unit of naturalistic experience corresponding e.g., to a scene in a movie. Typically consists of events that all take place in one location over e.g., a minute or so. This could be a paragraph or a page or so in a book.`, 19: `Episode is a sequence of scenes that constitutes the next larger-scale unit of naturalistic experience e.g., going to the grocery store or eating at a restaurant, attending a wedding or other "event". This could be a chapter in a book.`} -var _TimesDescMap = map[Times]string{ - 0: `NoTime represents a non-initialized value, or a null result`, - 1: `AllTimes indicates that the log should occur over all times present in other items.`, - 2: `Cycle is the finest time scale -- typically 1 msec -- a single activation update.`, - 3: `FastSpike is typically 10 cycles = 10 msec (100hz) = the fastest spiking time generally observed in the brain. This can be useful for visualizing updates at a granularity in between Cycle and GammaCycle.`, - 4: `GammaCycle is typically 25 cycles = 25 msec (40hz)`, - 5: `Phase is typically a Minus or Plus phase, where plus phase is bursting / outcome that drives positive learning relative to prediction in minus phase. It can also be used for other time scales involving multiple Cycles.`, - 6: `BetaCycle is typically 50 cycles = 50 msec (20 hz) = one beta-frequency cycle. Gating in the basal ganglia and associated updating in prefrontal cortex occurs at this frequency.`, - 7: `AlphaCycle is typically 100 cycles = 100 msec (10 hz) = one alpha-frequency cycle.`, - 8: `ThetaCycle is typically 200 cycles = 200 msec (5 hz) = two alpha-frequency cycles. This is the modal duration of a saccade, the update frequency of medial temporal lobe episodic memory, and the minimal predictive learning cycle (perceive an Alpha 1, predict on 2).`, - 9: `Event is the smallest unit of naturalistic experience that coheres unto itself (e.g., something that could be described in a sentence). Typically this is on the time scale of a few seconds: e.g., reaching for something, catching a ball.`, - 10: `Trial is one unit of behavior in an experiment -- it is typically environmentally defined instead of endogenously defined in terms of basic brain rhythms. In the minimal case it could be one ThetaCycle, but could be multiple, and could encompass multiple Events (e.g., one event is fixation, next is stimulus, last is response)`, - 11: `Tick is one step in a sequence -- often it is useful to have Trial count up throughout the entire Epoch but also include a Tick to count trials within a Sequence`, - 12: `Sequence is a sequential group of Trials (not always needed).`, - 13: `Epoch is used in two different contexts. In machine learning, it represents a collection of Trials, Sequences or Events that constitute a "representative sample" of the environment. In the simplest case, it is the entire collection of Trials used for training. In electrophysiology, it is a timing window used for organizing the analysis of electrode data.`, - 14: `Block is a collection of Trials, Sequences or Events, often used in experiments when conditions are varied across blocks.`, - 15: `Condition is a collection of Blocks that share the same set of parameters. This is intermediate between Block and Run levels. Aggregation of stats at this level is based on the last 5 rows by default.`, - 16: `Run is a complete run of a model / subject, from training to testing, etc. Often multiple runs are done in an Expt to obtain statistics over initial random weights etc. Aggregation of stats at this level is based on the last 5 rows by default.`, - 17: `Expt is an entire experiment -- multiple Runs through a given protocol / set of parameters.`, - 18: `Scene is a sequence of events that constitutes the next larger-scale coherent unit of naturalistic experience corresponding e.g., to a scene in a movie. Typically consists of events that all take place in one location over e.g., a minute or so. This could be a paragraph or a page or so in a book.`, - 19: `Episode is a sequence of scenes that constitutes the next larger-scale unit of naturalistic experience e.g., going to the grocery store or eating at a restaurant, attending a wedding or other "event". This could be a chapter in a book.`, -} +var _TimesMap = map[Times]string{0: `NoTime`, 1: `AllTimes`, 2: `Cycle`, 3: `FastSpike`, 4: `GammaCycle`, 5: `Phase`, 6: `BetaCycle`, 7: `AlphaCycle`, 8: `ThetaCycle`, 9: `Event`, 10: `Trial`, 11: `Tick`, 12: `Sequence`, 13: `Epoch`, 14: `Block`, 15: `Condition`, 16: `Run`, 17: `Expt`, 18: `Scene`, 19: `Episode`} -var _TimesMap = map[Times]string{ - 0: `NoTime`, - 1: `AllTimes`, - 2: `Cycle`, - 3: `FastSpike`, - 4: `GammaCycle`, - 5: `Phase`, - 6: `BetaCycle`, - 7: `AlphaCycle`, - 8: `ThetaCycle`, - 9: `Event`, - 10: `Trial`, - 11: `Tick`, - 12: `Sequence`, - 13: `Epoch`, - 14: `Block`, - 15: `Condition`, - 16: `Run`, - 17: `Expt`, - 18: `Scene`, - 19: `Episode`, -} +// String returns the string representation of this Times value. +func (i Times) String() string { return enums.String(i, _TimesMap) } -// String returns the string representation -// of this Times value. -func (i Times) String() string { - if str, ok := _TimesMap[i]; ok { - return str - } - return strconv.FormatInt(int64(i), 10) -} - -// SetString sets the Times value from its -// string representation, and returns an -// error if the string is invalid. -func (i *Times) SetString(s string) error { - if val, ok := _TimesNameToValueMap[s]; ok { - *i = val - return nil - } - if val, ok := _TimesNameToValueMap[strings.ToLower(s)]; ok { - *i = val - return nil - } - return errors.New(s + " is not a valid value for type Times") -} +// SetString sets the Times value from its string representation, +// and returns an error if the string is invalid. +func (i *Times) SetString(s string) error { return enums.SetString(i, s, _TimesValueMap, "Times") } // Int64 returns the Times value as an int64. -func (i Times) Int64() int64 { - return int64(i) -} +func (i Times) Int64() int64 { return int64(i) } // SetInt64 sets the Times value from an int64. -func (i *Times) SetInt64(in int64) { - *i = Times(in) -} +func (i *Times) SetInt64(in int64) { *i = Times(in) } // Desc returns the description of the Times value. -func (i Times) Desc() string { - if str, ok := _TimesDescMap[i]; ok { - return str - } - return i.String() -} - -// TimesValues returns all possible values -// for the type Times. -func TimesValues() []Times { - return _TimesValues -} +func (i Times) Desc() string { return enums.Desc(i, _TimesDescMap) } -// Values returns all possible values -// for the type Times. -func (i Times) Values() []enums.Enum { - res := make([]enums.Enum, len(_TimesValues)) - for i, d := range _TimesValues { - res[i] = d - } - return res -} +// TimesValues returns all possible values for the type Times. +func TimesValues() []Times { return _TimesValues } -// IsValid returns whether the value is a -// valid option for type Times. -func (i Times) IsValid() bool { - _, ok := _TimesMap[i] - return ok -} +// Values returns all possible values for the type Times. +func (i Times) Values() []enums.Enum { return enums.Values(_TimesValues) } // MarshalText implements the [encoding.TextMarshaler] interface. -func (i Times) MarshalText() ([]byte, error) { - return []byte(i.String()), nil -} +func (i Times) MarshalText() ([]byte, error) { return []byte(i.String()), nil } // UnmarshalText implements the [encoding.TextUnmarshaler] interface. -func (i *Times) UnmarshalText(text []byte) error { - if err := i.SetString(string(text)); err != nil { - log.Println("Times.UnmarshalText:", err) - } - return nil -} +func (i *Times) UnmarshalText(text []byte) error { return enums.UnmarshalText(i, text, "Times") } diff --git a/etime/gtigen.go b/etime/gtigen.go index 93d273e9..5f530e21 100644 --- a/etime/gtigen.go +++ b/etime/gtigen.go @@ -6,8 +6,8 @@ import ( "cogentcore.org/core/gti" ) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/etime.Modes", IDName: "modes", Doc: "Modes are evaluation modes (Training, Testing, etc)", Directives: []gti.Directive{{Tool: "go", Directive: "generate", Args: []string{"goki", "generate"}}, {Tool: "gosl", Directive: "start", Args: []string{"etime"}}, {Tool: "enums", Directive: "enum"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/etime.Modes", IDName: "modes", Doc: "Modes are evaluation modes (Training, Testing, etc)"}) var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/etime.ScopeKey", IDName: "scope-key", Doc: "ScopeKey the associated string representation of a scope or scopes.\nThey include one or more Modes and one or more Times.\nIt is fully extensible with arbitrary mode and time strings --\nthe enums are a convenience for standard cases.\nUltimately a single mode, time pair is used concretely, but the\nAll* cases and lists of multiple can be used as a convenience\nto specify ranges"}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/etime.Times", IDName: "times", Doc: "Times the enum", Directives: []gti.Directive{{Tool: "go", Directive: "generate", Args: []string{"goki", "generate", "-add-types"}}, {Tool: "enums", Directive: "enum"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/etime.Times", IDName: "times", Doc: "Times the enum"}) diff --git a/evec/enumgen.go b/evec/enumgen.go index 49fcae0f..fb22b7c4 100644 --- a/evec/enumgen.go +++ b/evec/enumgen.go @@ -3,129 +3,44 @@ package evec import ( - "errors" - "log" - "strconv" - "strings" - "cogentcore.org/core/enums" ) var _DimsValues = []Dims{0, 1, 2, 3} -// DimsN is the highest valid value -// for type Dims, plus one. +// DimsN is the highest valid value for type Dims, plus one. const DimsN Dims = 4 -// An "invalid array index" compiler error signifies that the constant values have changed. -// Re-run the enumgen command to generate them again. -func _DimsNoOp() { - var x [1]struct{} - _ = x[X-(0)] - _ = x[Y-(1)] - _ = x[Z-(2)] - _ = x[W-(3)] -} - -var _DimsNameToValueMap = map[string]Dims{ - `X`: 0, - `x`: 0, - `Y`: 1, - `y`: 1, - `Z`: 2, - `z`: 2, - `W`: 3, - `w`: 3, -} - -var _DimsDescMap = map[Dims]string{ - 0: ``, - 1: ``, - 2: ``, - 3: ``, -} - -var _DimsMap = map[Dims]string{ - 0: `X`, - 1: `Y`, - 2: `Z`, - 3: `W`, -} - -// String returns the string representation -// of this Dims value. -func (i Dims) String() string { - if str, ok := _DimsMap[i]; ok { - return str - } - return strconv.FormatInt(int64(i), 10) -} - -// SetString sets the Dims value from its -// string representation, and returns an -// error if the string is invalid. -func (i *Dims) SetString(s string) error { - if val, ok := _DimsNameToValueMap[s]; ok { - *i = val - return nil - } - if val, ok := _DimsNameToValueMap[strings.ToLower(s)]; ok { - *i = val - return nil - } - return errors.New(s + " is not a valid value for type Dims") -} +var _DimsValueMap = map[string]Dims{`X`: 0, `Y`: 1, `Z`: 2, `W`: 3} + +var _DimsDescMap = map[Dims]string{0: ``, 1: ``, 2: ``, 3: ``} + +var _DimsMap = map[Dims]string{0: `X`, 1: `Y`, 2: `Z`, 3: `W`} + +// String returns the string representation of this Dims value. +func (i Dims) String() string { return enums.String(i, _DimsMap) } + +// SetString sets the Dims value from its string representation, +// and returns an error if the string is invalid. +func (i *Dims) SetString(s string) error { return enums.SetString(i, s, _DimsValueMap, "Dims") } // Int64 returns the Dims value as an int64. -func (i Dims) Int64() int64 { - return int64(i) -} +func (i Dims) Int64() int64 { return int64(i) } // SetInt64 sets the Dims value from an int64. -func (i *Dims) SetInt64(in int64) { - *i = Dims(in) -} +func (i *Dims) SetInt64(in int64) { *i = Dims(in) } // Desc returns the description of the Dims value. -func (i Dims) Desc() string { - if str, ok := _DimsDescMap[i]; ok { - return str - } - return i.String() -} - -// DimsValues returns all possible values -// for the type Dims. -func DimsValues() []Dims { - return _DimsValues -} - -// Values returns all possible values -// for the type Dims. -func (i Dims) Values() []enums.Enum { - res := make([]enums.Enum, len(_DimsValues)) - for i, d := range _DimsValues { - res[i] = d - } - return res -} - -// IsValid returns whether the value is a -// valid option for type Dims. -func (i Dims) IsValid() bool { - _, ok := _DimsMap[i] - return ok -} +func (i Dims) Desc() string { return enums.Desc(i, _DimsDescMap) } + +// DimsValues returns all possible values for the type Dims. +func DimsValues() []Dims { return _DimsValues } + +// Values returns all possible values for the type Dims. +func (i Dims) Values() []enums.Enum { return enums.Values(_DimsValues) } // MarshalText implements the [encoding.TextMarshaler] interface. -func (i Dims) MarshalText() ([]byte, error) { - return []byte(i.String()), nil -} +func (i Dims) MarshalText() ([]byte, error) { return []byte(i.String()), nil } // UnmarshalText implements the [encoding.TextUnmarshaler] interface. -func (i *Dims) UnmarshalText(text []byte) error { - if err := i.SetString(string(text)); err != nil { - log.Println("Dims.UnmarshalText:", err) - } - return nil -} +func (i *Dims) UnmarshalText(text []byte) error { return enums.UnmarshalText(i, text, "Dims") } diff --git a/evec/gtigen.go b/evec/gtigen.go index 487546fa..38ee014c 100644 --- a/evec/gtigen.go +++ b/evec/gtigen.go @@ -6,6 +6,6 @@ import ( "cogentcore.org/core/gti" ) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/evec.Dims", IDName: "dims", Doc: "Dims is a list of vector dimension (component) names", Directives: []gti.Directive{{Tool: "go", Directive: "generate", Args: []string{"goki", "generate", "-add-types"}}, {Tool: "enums", Directive: "enum"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/evec.Dims", IDName: "dims", Doc: "Dims is a list of vector dimension (component) names"}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/evec.Vec2i", IDName: "vec-2-i", Doc: "Vec2i is a 2D vector/point with X and Y int components.", Fields: []gti.Field{{Name: "X"}, {Name: "Y"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/evec.Vec2i", IDName: "vec2i", Doc: "Vec2i is a 2D vector/point with X and Y int components.", Fields: []gti.Field{{Name: "X"}, {Name: "Y"}}}) diff --git a/netparams/gtigen.go b/netparams/gtigen.go index fb25c19c..e8eba635 100644 --- a/netparams/gtigen.go +++ b/netparams/gtigen.go @@ -6,4 +6,4 @@ import ( "cogentcore.org/core/gti" ) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/netparams.Sets", IDName: "sets", Doc: "Sets is a collection of Sheets that can be chosen among\ndepending on different desired configurations etc. Thus, each Set\nrepresents a collection of different possible specific configurations,\nand different such configurations can be chosen by name to apply as desired.", Directives: []gti.Directive{{Tool: "git", Directive: "add"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/netparams.Sets", IDName: "sets", Doc: "Sets is a collection of Sheets that can be chosen among\ndepending on different desired configurations etc. Thus, each Set\nrepresents a collection of different possible specific configurations,\nand different such configurations can be chosen by name to apply as desired."}) diff --git a/netview/netview.go b/netview/netview.go index 8cad51c0..75f12d87 100644 --- a/netview/netview.go +++ b/netview/netview.go @@ -513,7 +513,7 @@ func (nv *NetView) VarsUpdate() { vb := vbi.(*gi.Button) vb.SetSelected(vb.Text == nv.Var) } - nv.ColorMapVal.UpdateWidget() + nv.ColorMapVal.Update() vl.NeedsRender() } diff --git a/params/gtigen.go b/params/gtigen.go index 406fc9be..4f39a4e9 100644 --- a/params/gtigen.go +++ b/params/gtigen.go @@ -6,7 +6,7 @@ import ( "cogentcore.org/core/gti" ) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.FlexVal", IDName: "flex-val", Doc: "FlexVal is a specific flexible value for the Flex parameter map\nthat implements the StylerObj interface for CSS-style selection logic", Fields: []gti.Field{{Name: "Nm", Doc: "name of this specific object -- matches #Name selections"}, {Name: "Type", Doc: "type name of this object -- matches plain TypeName selections"}, {Name: "Cls", Doc: "space-separated list of class name(s) -- match the .Class selections"}, {Name: "Obj", Doc: "actual object with data that is set by the parameters"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.FlexVal", IDName: "flex-val", Doc: "FlexVal is a specific flexible value for the Flex parameter map\nthat implements the StylerObj interface for CSS-style selection logic.\nThe field names are abbreviated because full names are used in StylerObj.", Fields: []gti.Field{{Name: "Nm", Doc: "name of this specific object, matches #Name selections"}, {Name: "Type", Doc: "type name of this object, matches plain TypeName selections"}, {Name: "Cls", Doc: "space-separated list of class name(s), match the .Class selections"}, {Name: "Obj", Doc: "actual object with data that is set by the parameters"}, {Name: "History", Doc: "History of params applied"}}}) var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.Flex", IDName: "flex", Doc: "Flex supports arbitrary named parameter values that can be set\nby a Set of parameters, as a map of any objects.\nFirst initialize the map with set of names and a type to create\nblank values, then apply the Set to it."}) @@ -14,22 +14,26 @@ var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.History" var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.HistoryImpl", IDName: "history-impl", Doc: "HistoryImpl implements the History interface. Implementing object can\njust pass calls to a HistoryImpl field."}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.HyperVals", IDName: "hyper-vals", Doc: "HyperVals is a string-value map for storing hyperparameter values", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.HyperVals", IDName: "hyper-vals", Doc: "HyperVals is a string-value map for storing hyperparameter values"}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.Hypers", IDName: "hypers", Doc: "Hypers is a parallel structure to Params which stores information relevant\nto hyperparameter search as well as the values.\nUse the key \"Val\" for the default value. This is equivalant to the value in\nParams. \"Min\" and \"Max\" guid the range, and \"Sigma\" describes a Gaussian.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.Hypers", IDName: "hypers", Doc: "Hypers is a parallel structure to Params which stores information relevant\nto hyperparameter search as well as the values.\nUse the key \"Val\" for the default value. This is equivalant to the value in\nParams. \"Min\" and \"Max\" guid the range, and \"Sigma\" describes a Gaussian."}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.Params", IDName: "params", Doc: "Params is a name-value map for parameter values that can be applied\nto any numeric type in any object.\nThe name must be a dot-separated path to a specific parameter, e.g., Prjn.Learn.Lrate\nThe first part of the path is the overall target object type, e.g., \"Prjn\" or \"Layer\",\nwhich is used for determining if the parameter applies to a given object type.\n\nAll of the params in one map must apply to the same target type because\nonly the first item in the map (which could be any due to order randomization)\nis used for checking the type of the target. Also, they all fall within the same\nSel selector scope which is used to determine what specific objects to apply the\nparameters to.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.Params", IDName: "params", Doc: "Params is a name-value map for parameter values that can be applied\nto any numeric type in any object.\nThe name must be a dot-separated path to a specific parameter, e.g., Prjn.Learn.Lrate\nThe first part of the path is the overall target object type, e.g., \"Prjn\" or \"Layer\",\nwhich is used for determining if the parameter applies to a given object type.\n\nAll of the params in one map must apply to the same target type because\nonly the first item in the map (which could be any due to order randomization)\nis used for checking the type of the target. Also, they all fall within the same\nSel selector scope which is used to determine what specific objects to apply the\nparameters to."}) var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.Sel", IDName: "sel", Doc: "params.Sel specifies a selector for the scope of application of a set of\nparameters, using standard css selector syntax (. prefix = class, # prefix = name,\nand no prefix = type)", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Fields: []gti.Field{{Name: "Sel", Doc: "selector for what to apply the parameters to, using standard css selector syntax: .Example applies to anything with a Class tag of 'Example', #Example applies to anything with a Name of 'Example', and Example with no prefix applies to anything of type 'Example'"}, {Name: "Desc", Doc: "description of these parameter values -- what effect do they have? what range was explored? it is valuable to record this information as you explore the params."}, {Name: "Params", Doc: "parameter values to apply to whatever matches the selector"}, {Name: "Hypers", Doc: "Put your hyperparams here"}, {Name: "NMatch", Doc: "number of times this selector matched a target during the last Apply process -- a warning is issued for any that remain at 0 -- see Sheet SelMatchReset and SelNoMatchWarn methods"}, {Name: "SetName", Doc: "name of current Set being applied"}}}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.Sheet", IDName: "sheet", Doc: "Sheet is a CSS-like style-sheet of params.Sel values, each of which represents\na different set of specific parameter values applied according to the Sel selector:\n.Class #Name or Type.\n\nThe order of elements in the Sheet list is critical, as they are applied\nin the order given by the list (slice), and thus later Sel's can override\nthose applied earlier. Thus, you generally want to have more general Type-level\nparameters listed first, and then subsequently more specific ones (.Class and #Name)\n\nThis is the highest level of params that has an Apply method -- above this level\napplication must be done under explicit program control.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.Sheet", IDName: "sheet", Doc: "Sheet is a CSS-like style-sheet of params.Sel values, each of which represents\na different set of specific parameter values applied according to the Sel selector:\n.Class #Name or Type.\n\nThe order of elements in the Sheet list is critical, as they are applied\nin the order given by the list (slice), and thus later Sel's can override\nthose applied earlier. Thus, you generally want to have more general Type-level\nparameters listed first, and then subsequently more specific ones (.Class and #Name)\n\nThis is the highest level of params that has an Apply method -- above this level\napplication must be done under explicit program control."}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.Sheets", IDName: "sheets", Doc: "Sheets is a map of named sheets -- used in the Set", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.Sheets", IDName: "sheets", Doc: "Sheets is a map of named sheets -- used in the Set"}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.Set", IDName: "set", Doc: "Set is a collection of Sheets that constitute a coherent set of parameters --\na particular specific configuration of parameters, which the user selects to use.\nThe Set name is stored in the Sets map from which it is typically accessed.\nA good strategy is to have a \"Base\" set that has all the best parameters so far,\nand then other sets can modify relative to that one. It is up to the Sim code to\napply parameter sets in whatever order is desired.\n\nWithin a params.Set, multiple different params.Sheets can be organized,\nwith each CSS-style sheet achieving a relatively complete parameter styling\nof a given element of the overal model, e.g., \"Network\", \"Sim\", \"Env\".\nOr Network could be further broken down into \"Learn\" vs. \"Act\" etc,\nor according to different brain areas (\"Hippo\", \"PFC\", \"BG\", etc).\nAgain, this is entirely at the discretion of the modeler and must be\nperformed under explict program control, especially because order is so critical.\n\nNote that there is NO deterministic ordering of the Sheets due to the use of\na Go map structure, which specifically randomizes order, so simply iterating over them\nand applying may produce unexpected results -- it is better to lookup by name.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Fields: []gti.Field{{Name: "Desc", Doc: "description of this param set -- when should it be used? how is it different from the other sets?"}, {Name: "Sheets", Doc: "Sheet's grouped according to their target and / or function, e.g.,"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.Set", IDName: "set", Doc: "Set is a collection of Sheets that constitute a coherent set of parameters --\na particular specific configuration of parameters, which the user selects to use.\nThe Set name is stored in the Sets map from which it is typically accessed.\nA good strategy is to have a \"Base\" set that has all the best parameters so far,\nand then other sets can modify relative to that one. It is up to the Sim code to\napply parameter sets in whatever order is desired.\n\nWithin a params.Set, multiple different params.Sheets can be organized,\nwith each CSS-style sheet achieving a relatively complete parameter styling\nof a given element of the overal model, e.g., \"Network\", \"Sim\", \"Env\".\nOr Network could be further broken down into \"Learn\" vs. \"Act\" etc,\nor according to different brain areas (\"Hippo\", \"PFC\", \"BG\", etc).\nAgain, this is entirely at the discretion of the modeler and must be\nperformed under explict program control, especially because order is so critical.\n\nNote that there is NO deterministic ordering of the Sheets due to the use of\na Go map structure, which specifically randomizes order, so simply iterating over them\nand applying may produce unexpected results -- it is better to lookup by name.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Fields: []gti.Field{{Name: "Desc", Doc: "description of this param set -- when should it be used? how is it different from the other sets?"}, {Name: "Sheets", Doc: "Sheet's grouped according to their target and / or function. For example,\n\"Network\" for all the network params (or \"Learn\" vs. \"Act\" for more fine-grained), and \"Sim\" for overall simulation control parameters, \"Env\" for environment parameters, etc. It is completely up to your program to lookup these names and apply them as appropriate."}}}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.Sets", IDName: "sets", Doc: "Sets is a collection of Set's that can be chosen among\ndepending on different desired configurations etc. Thus, each Set\nrepresents a collection of different possible specific configurations,\nand different such configurations can be chosen by name to apply as desired.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.Sets", IDName: "sets", Doc: "Sets is a collection of Set's that can be chosen among\ndepending on different desired configurations etc. Thus, each Set\nrepresents a collection of different possible specific configurations,\nand different such configurations can be chosen by name to apply as desired."}) + +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.SearchValues", IDName: "search-values", Doc: "SearchValues is a list of parameter values to search for one parameter\non a given object (specified by Name), for float-valued params.", Fields: []gti.Field{{Name: "Name", Doc: "name of object with the parameter"}, {Name: "Type", Doc: "type of object with the parameter. This is a Base type name (e.g., Layer, Prjn),\nthat is at the start of the path in Network params."}, {Name: "Path", Doc: "path to the parameter within the object"}, {Name: "Start", Doc: "starting value, e.g., for restoring after searching\nbefore moving on to another parameter, for grid search."}, {Name: "Values", Doc: "values of the parameter to search"}}}) var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.Styler", IDName: "styler", Doc: "The params.Styler interface exposes TypeName, Class, and Name methods\nthat allow the params.Sel CSS-style selection specifier to determine\nwhether a given parameter applies.\nAdding Set versions of Name and Class methods is a good idea but not\nneeded for this interface, so they are not included here."}) var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.StylerObj", IDName: "styler-obj", Doc: "The params.StylerObj interface extends Styler to include an arbitary\nfunction to access the underlying object type."}) + +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/params.Tweaks", IDName: "tweaks", Doc: "Tweaks holds parameter tweak values associated with one parameter selector.\nHas all the object values affected for a given parameter within one\nselector, that has a tweak hyperparameter set.", Fields: []gti.Field{{Name: "Param", Doc: "the parameter path for this param"}, {Name: "Sel", Doc: "the param selector that set the specific value upon which tweak is based"}, {Name: "Search", Doc: "the search values for all objects covered by this selector"}}}) diff --git a/relpos/enumgen.go b/relpos/enumgen.go index de0a6b54..51a80124 100644 --- a/relpos/enumgen.go +++ b/relpos/enumgen.go @@ -3,372 +3,130 @@ package relpos import ( - "errors" - "log" - "strconv" - "strings" - "cogentcore.org/core/enums" ) var _RelationsValues = []Relations{0, 1, 2, 3, 4, 5, 6} -// RelationsN is the highest valid value -// for type Relations, plus one. +// RelationsN is the highest valid value for type Relations, plus one. const RelationsN Relations = 7 -// An "invalid array index" compiler error signifies that the constant values have changed. -// Re-run the enumgen command to generate them again. -func _RelationsNoOp() { - var x [1]struct{} - _ = x[NoRel-(0)] - _ = x[RightOf-(1)] - _ = x[LeftOf-(2)] - _ = x[Behind-(3)] - _ = x[FrontOf-(4)] - _ = x[Above-(5)] - _ = x[Below-(6)] -} - -var _RelationsNameToValueMap = map[string]Relations{ - `NoRel`: 0, - `norel`: 0, - `RightOf`: 1, - `rightof`: 1, - `LeftOf`: 2, - `leftof`: 2, - `Behind`: 3, - `behind`: 3, - `FrontOf`: 4, - `frontof`: 4, - `Above`: 5, - `above`: 5, - `Below`: 6, - `below`: 6, -} +var _RelationsValueMap = map[string]Relations{`NoRel`: 0, `RightOf`: 1, `LeftOf`: 2, `Behind`: 3, `FrontOf`: 4, `Above`: 5, `Below`: 6} -var _RelationsDescMap = map[Relations]string{ - 0: ``, - 1: ``, - 2: ``, - 3: ``, - 4: ``, - 5: ``, - 6: ``, -} +var _RelationsDescMap = map[Relations]string{0: ``, 1: ``, 2: ``, 3: ``, 4: ``, 5: ``, 6: ``} -var _RelationsMap = map[Relations]string{ - 0: `NoRel`, - 1: `RightOf`, - 2: `LeftOf`, - 3: `Behind`, - 4: `FrontOf`, - 5: `Above`, - 6: `Below`, -} +var _RelationsMap = map[Relations]string{0: `NoRel`, 1: `RightOf`, 2: `LeftOf`, 3: `Behind`, 4: `FrontOf`, 5: `Above`, 6: `Below`} -// String returns the string representation -// of this Relations value. -func (i Relations) String() string { - if str, ok := _RelationsMap[i]; ok { - return str - } - return strconv.FormatInt(int64(i), 10) -} +// String returns the string representation of this Relations value. +func (i Relations) String() string { return enums.String(i, _RelationsMap) } -// SetString sets the Relations value from its -// string representation, and returns an -// error if the string is invalid. +// SetString sets the Relations value from its string representation, +// and returns an error if the string is invalid. func (i *Relations) SetString(s string) error { - if val, ok := _RelationsNameToValueMap[s]; ok { - *i = val - return nil - } - if val, ok := _RelationsNameToValueMap[strings.ToLower(s)]; ok { - *i = val - return nil - } - return errors.New(s + " is not a valid value for type Relations") + return enums.SetString(i, s, _RelationsValueMap, "Relations") } // Int64 returns the Relations value as an int64. -func (i Relations) Int64() int64 { - return int64(i) -} +func (i Relations) Int64() int64 { return int64(i) } // SetInt64 sets the Relations value from an int64. -func (i *Relations) SetInt64(in int64) { - *i = Relations(in) -} +func (i *Relations) SetInt64(in int64) { *i = Relations(in) } // Desc returns the description of the Relations value. -func (i Relations) Desc() string { - if str, ok := _RelationsDescMap[i]; ok { - return str - } - return i.String() -} +func (i Relations) Desc() string { return enums.Desc(i, _RelationsDescMap) } -// RelationsValues returns all possible values -// for the type Relations. -func RelationsValues() []Relations { - return _RelationsValues -} +// RelationsValues returns all possible values for the type Relations. +func RelationsValues() []Relations { return _RelationsValues } -// Values returns all possible values -// for the type Relations. -func (i Relations) Values() []enums.Enum { - res := make([]enums.Enum, len(_RelationsValues)) - for i, d := range _RelationsValues { - res[i] = d - } - return res -} - -// IsValid returns whether the value is a -// valid option for type Relations. -func (i Relations) IsValid() bool { - _, ok := _RelationsMap[i] - return ok -} +// Values returns all possible values for the type Relations. +func (i Relations) Values() []enums.Enum { return enums.Values(_RelationsValues) } // MarshalText implements the [encoding.TextMarshaler] interface. -func (i Relations) MarshalText() ([]byte, error) { - return []byte(i.String()), nil -} +func (i Relations) MarshalText() ([]byte, error) { return []byte(i.String()), nil } // UnmarshalText implements the [encoding.TextUnmarshaler] interface. func (i *Relations) UnmarshalText(text []byte) error { - if err := i.SetString(string(text)); err != nil { - log.Println("Relations.UnmarshalText:", err) - } - return nil + return enums.UnmarshalText(i, text, "Relations") } var _XAlignsValues = []XAligns{0, 1, 2} -// XAlignsN is the highest valid value -// for type XAligns, plus one. +// XAlignsN is the highest valid value for type XAligns, plus one. const XAlignsN XAligns = 3 -// An "invalid array index" compiler error signifies that the constant values have changed. -// Re-run the enumgen command to generate them again. -func _XAlignsNoOp() { - var x [1]struct{} - _ = x[Left-(0)] - _ = x[Middle-(1)] - _ = x[Right-(2)] -} +var _XAlignsValueMap = map[string]XAligns{`Left`: 0, `Middle`: 1, `Right`: 2} -var _XAlignsNameToValueMap = map[string]XAligns{ - `Left`: 0, - `left`: 0, - `Middle`: 1, - `middle`: 1, - `Right`: 2, - `right`: 2, -} +var _XAlignsDescMap = map[XAligns]string{0: ``, 1: ``, 2: ``} -var _XAlignsDescMap = map[XAligns]string{ - 0: ``, - 1: ``, - 2: ``, -} +var _XAlignsMap = map[XAligns]string{0: `Left`, 1: `Middle`, 2: `Right`} -var _XAlignsMap = map[XAligns]string{ - 0: `Left`, - 1: `Middle`, - 2: `Right`, -} - -// String returns the string representation -// of this XAligns value. -func (i XAligns) String() string { - if str, ok := _XAlignsMap[i]; ok { - return str - } - return strconv.FormatInt(int64(i), 10) -} +// String returns the string representation of this XAligns value. +func (i XAligns) String() string { return enums.String(i, _XAlignsMap) } -// SetString sets the XAligns value from its -// string representation, and returns an -// error if the string is invalid. +// SetString sets the XAligns value from its string representation, +// and returns an error if the string is invalid. func (i *XAligns) SetString(s string) error { - if val, ok := _XAlignsNameToValueMap[s]; ok { - *i = val - return nil - } - if val, ok := _XAlignsNameToValueMap[strings.ToLower(s)]; ok { - *i = val - return nil - } - return errors.New(s + " is not a valid value for type XAligns") + return enums.SetString(i, s, _XAlignsValueMap, "XAligns") } // Int64 returns the XAligns value as an int64. -func (i XAligns) Int64() int64 { - return int64(i) -} +func (i XAligns) Int64() int64 { return int64(i) } // SetInt64 sets the XAligns value from an int64. -func (i *XAligns) SetInt64(in int64) { - *i = XAligns(in) -} +func (i *XAligns) SetInt64(in int64) { *i = XAligns(in) } // Desc returns the description of the XAligns value. -func (i XAligns) Desc() string { - if str, ok := _XAlignsDescMap[i]; ok { - return str - } - return i.String() -} - -// XAlignsValues returns all possible values -// for the type XAligns. -func XAlignsValues() []XAligns { - return _XAlignsValues -} +func (i XAligns) Desc() string { return enums.Desc(i, _XAlignsDescMap) } -// Values returns all possible values -// for the type XAligns. -func (i XAligns) Values() []enums.Enum { - res := make([]enums.Enum, len(_XAlignsValues)) - for i, d := range _XAlignsValues { - res[i] = d - } - return res -} +// XAlignsValues returns all possible values for the type XAligns. +func XAlignsValues() []XAligns { return _XAlignsValues } -// IsValid returns whether the value is a -// valid option for type XAligns. -func (i XAligns) IsValid() bool { - _, ok := _XAlignsMap[i] - return ok -} +// Values returns all possible values for the type XAligns. +func (i XAligns) Values() []enums.Enum { return enums.Values(_XAlignsValues) } // MarshalText implements the [encoding.TextMarshaler] interface. -func (i XAligns) MarshalText() ([]byte, error) { - return []byte(i.String()), nil -} +func (i XAligns) MarshalText() ([]byte, error) { return []byte(i.String()), nil } // UnmarshalText implements the [encoding.TextUnmarshaler] interface. -func (i *XAligns) UnmarshalText(text []byte) error { - if err := i.SetString(string(text)); err != nil { - log.Println("XAligns.UnmarshalText:", err) - } - return nil -} +func (i *XAligns) UnmarshalText(text []byte) error { return enums.UnmarshalText(i, text, "XAligns") } var _YAlignsValues = []YAligns{0, 1, 2} -// YAlignsN is the highest valid value -// for type YAligns, plus one. +// YAlignsN is the highest valid value for type YAligns, plus one. const YAlignsN YAligns = 3 -// An "invalid array index" compiler error signifies that the constant values have changed. -// Re-run the enumgen command to generate them again. -func _YAlignsNoOp() { - var x [1]struct{} - _ = x[Front-(0)] - _ = x[Center-(1)] - _ = x[Back-(2)] -} +var _YAlignsValueMap = map[string]YAligns{`Front`: 0, `Center`: 1, `Back`: 2} -var _YAlignsNameToValueMap = map[string]YAligns{ - `Front`: 0, - `front`: 0, - `Center`: 1, - `center`: 1, - `Back`: 2, - `back`: 2, -} - -var _YAlignsDescMap = map[YAligns]string{ - 0: ``, - 1: ``, - 2: ``, -} +var _YAlignsDescMap = map[YAligns]string{0: ``, 1: ``, 2: ``} -var _YAlignsMap = map[YAligns]string{ - 0: `Front`, - 1: `Center`, - 2: `Back`, -} +var _YAlignsMap = map[YAligns]string{0: `Front`, 1: `Center`, 2: `Back`} -// String returns the string representation -// of this YAligns value. -func (i YAligns) String() string { - if str, ok := _YAlignsMap[i]; ok { - return str - } - return strconv.FormatInt(int64(i), 10) -} +// String returns the string representation of this YAligns value. +func (i YAligns) String() string { return enums.String(i, _YAlignsMap) } -// SetString sets the YAligns value from its -// string representation, and returns an -// error if the string is invalid. +// SetString sets the YAligns value from its string representation, +// and returns an error if the string is invalid. func (i *YAligns) SetString(s string) error { - if val, ok := _YAlignsNameToValueMap[s]; ok { - *i = val - return nil - } - if val, ok := _YAlignsNameToValueMap[strings.ToLower(s)]; ok { - *i = val - return nil - } - return errors.New(s + " is not a valid value for type YAligns") + return enums.SetString(i, s, _YAlignsValueMap, "YAligns") } // Int64 returns the YAligns value as an int64. -func (i YAligns) Int64() int64 { - return int64(i) -} +func (i YAligns) Int64() int64 { return int64(i) } // SetInt64 sets the YAligns value from an int64. -func (i *YAligns) SetInt64(in int64) { - *i = YAligns(in) -} +func (i *YAligns) SetInt64(in int64) { *i = YAligns(in) } // Desc returns the description of the YAligns value. -func (i YAligns) Desc() string { - if str, ok := _YAlignsDescMap[i]; ok { - return str - } - return i.String() -} +func (i YAligns) Desc() string { return enums.Desc(i, _YAlignsDescMap) } -// YAlignsValues returns all possible values -// for the type YAligns. -func YAlignsValues() []YAligns { - return _YAlignsValues -} +// YAlignsValues returns all possible values for the type YAligns. +func YAlignsValues() []YAligns { return _YAlignsValues } -// Values returns all possible values -// for the type YAligns. -func (i YAligns) Values() []enums.Enum { - res := make([]enums.Enum, len(_YAlignsValues)) - for i, d := range _YAlignsValues { - res[i] = d - } - return res -} - -// IsValid returns whether the value is a -// valid option for type YAligns. -func (i YAligns) IsValid() bool { - _, ok := _YAlignsMap[i] - return ok -} +// Values returns all possible values for the type YAligns. +func (i YAligns) Values() []enums.Enum { return enums.Values(_YAlignsValues) } // MarshalText implements the [encoding.TextMarshaler] interface. -func (i YAligns) MarshalText() ([]byte, error) { - return []byte(i.String()), nil -} +func (i YAligns) MarshalText() ([]byte, error) { return []byte(i.String()), nil } // UnmarshalText implements the [encoding.TextUnmarshaler] interface. -func (i *YAligns) UnmarshalText(text []byte) error { - if err := i.SetString(string(text)); err != nil { - log.Println("YAligns.UnmarshalText:", err) - } - return nil -} +func (i *YAligns) UnmarshalText(text []byte) error { return enums.UnmarshalText(i, text, "YAligns") } diff --git a/relpos/gtigen.go b/relpos/gtigen.go index b60cd25d..17494b7d 100644 --- a/relpos/gtigen.go +++ b/relpos/gtigen.go @@ -8,8 +8,8 @@ import ( var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/relpos.Rel", IDName: "rel", Doc: "Rel defines a position relationship among layers, in terms of X,Y width and height of layer\nand associated position within a given X-Y plane,\nand Z vertical stacking of layers above and below each other.", Directives: []gti.Directive{{Tool: "git", Directive: "add"}}, Fields: []gti.Field{{Name: "Rel", Doc: "spatial relationship between this layer and the other layer"}, {Name: "XAlign", Doc: "] horizontal (x-axis) alignment relative to other"}, {Name: "YAlign", Doc: "] vertical (y-axis) alignment relative to other"}, {Name: "Other", Doc: "name of the other layer we are in relationship to"}, {Name: "Scale", Doc: "scaling factor applied to layer size for displaying"}, {Name: "Space", Doc: "number of unit-spaces between us"}, {Name: "XOffset", Doc: "for vertical (y-axis) alignment, amount we are offset relative to perfect alignment"}, {Name: "YOffset", Doc: "for horizontial (x-axis) alignment, amount we are offset relative to perfect alignment"}}}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/relpos.Relations", IDName: "relations", Doc: "Relations are different spatial relationships (of layers)", Directives: []gti.Directive{{Tool: "enums", Directive: "enum"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/relpos.Relations", IDName: "relations", Doc: "Relations are different spatial relationships (of layers)"}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/relpos.XAligns", IDName: "x-aligns", Doc: "XAligns are different horizontal alignments", Directives: []gti.Directive{{Tool: "enums", Directive: "enum"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/relpos.XAligns", IDName: "x-aligns", Doc: "XAligns are different horizontal alignments"}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/relpos.YAligns", IDName: "y-aligns", Doc: "YAligns are different vertical alignments", Directives: []gti.Directive{{Tool: "enums", Directive: "enum"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/relpos.YAligns", IDName: "y-aligns", Doc: "YAligns are different vertical alignments"}) diff --git a/ringidx/gtigen.go b/ringidx/gtigen.go index 870809bf..7be09ea6 100644 --- a/ringidx/gtigen.go +++ b/ringidx/gtigen.go @@ -8,4 +8,4 @@ import ( var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/ringidx.FIx", IDName: "f-ix", Doc: "FIx is a fixed-length ring index structure -- does not grow\nor shrink dynamically.", Directives: []gti.Directive{{Tool: "gosl", Directive: "start", Args: []string{"ringidx"}}}, Fields: []gti.Field{{Name: "Zi", Doc: "the zero index position -- where logical 0 is in physical buffer"}, {Name: "Len", Doc: "the length of the buffer -- wraps around at this modulus"}, {Name: "pad"}, {Name: "pad1"}}}) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/ringidx.Idx", IDName: "idx", Doc: "Idx is the ring index structure, maintaining starting index and length\ninto a ring-buffer with maximum length Max. Max must be > 0 and Len <= Max.\nWhen adding new items would overflow Max, starting index is shifted over\nto overwrite the oldest items with the new ones. No moving is ever\nrequired -- just a fixed-length buffer of size Max.", Directives: []gti.Directive{{Tool: "go", Directive: "generate", Args: []string{"goki", "generate", "-add-types"}}}, Fields: []gti.Field{{Name: "StIdx", Doc: "the starting index where current data starts -- the oldest data is at this index, and continues for Len items, wrapping around at Max, coming back up at most to StIdx-1"}, {Name: "Len", Doc: "the number of items stored starting at StIdx. Capped at Max"}, {Name: "Max", Doc: "the maximum number of items that can be stored in this ring"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/ringidx.Idx", IDName: "idx", Doc: "Idx is the ring index structure, maintaining starting index and length\ninto a ring-buffer with maximum length Max. Max must be > 0 and Len <= Max.\nWhen adding new items would overflow Max, starting index is shifted over\nto overwrite the oldest items with the new ones. No moving is ever\nrequired -- just a fixed-length buffer of size Max.", Directives: []gti.Directive{{Tool: "go", Directive: "generate", Args: []string{"core", "generate", "-add-types"}}}, Fields: []gti.Field{{Name: "StIdx", Doc: "the starting index where current data starts -- the oldest data is at this index, and continues for Len items, wrapping around at Max, coming back up at most to StIdx-1"}, {Name: "Len", Doc: "the number of items stored starting at StIdx. Capped at Max"}, {Name: "Max", Doc: "the maximum number of items that can be stored in this ring"}}}) diff --git a/stepper/enumgen.go b/stepper/enumgen.go index a8a20408..b7260ba0 100644 --- a/stepper/enumgen.go +++ b/stepper/enumgen.go @@ -3,129 +3,46 @@ package stepper import ( - "errors" - "log" - "strconv" - "strings" - "cogentcore.org/core/enums" ) var _RunStateValues = []RunState{0, 1, 2, 3} -// RunStateN is the highest valid value -// for type RunState, plus one. +// RunStateN is the highest valid value for type RunState, plus one. const RunStateN RunState = 4 -// An "invalid array index" compiler error signifies that the constant values have changed. -// Re-run the enumgen command to generate them again. -func _RunStateNoOp() { - var x [1]struct{} - _ = x[Stopped-(0)] - _ = x[Paused-(1)] - _ = x[Stepping-(2)] - _ = x[Running-(3)] -} - -var _RunStateNameToValueMap = map[string]RunState{ - `execution is stopped. The Stepper is NOT waiting, so running again is basically a restart. The only way to go from Running or Stepping to Stopped is to explicitly call Stop(). Program state will not be preserved once the Stopped state is entered.`: 0, - `execution is stopped. the stepper is not waiting, so running again is basically a restart. the only way to go from running or stepping to stopped is to explicitly call stop(). program state will not be preserved once the stopped state is entered.`: 0, - `execution is paused. The sim is waiting for further instructions, and can continue, or stop.`: 1, - `execution is paused. the sim is waiting for further instructions, and can continue, or stop.`: 1, - `the application is running, but will pause if it hits a StepPoint that matches the current StepGrain.`: 2, - `the application is running, but will pause if it hits a steppoint that matches the current stepgrain.`: 2, - `the application is running, and will NOT pause at StepPoints. It will pause if a stop has been requested.`: 3, - `the application is running, and will not pause at steppoints. it will pause if a stop has been requested.`: 3, -} +var _RunStateValueMap = map[string]RunState{`Stopped`: 0, `Paused`: 1, `Stepping`: 2, `Running`: 3} -var _RunStateDescMap = map[RunState]string{ - 0: ``, - 1: ``, - 2: ``, - 3: ``, -} +var _RunStateDescMap = map[RunState]string{0: ``, 1: ``, 2: ``, 3: ``} -var _RunStateMap = map[RunState]string{ - 0: `execution is stopped. The Stepper is NOT waiting, so running again is basically a restart. The only way to go from Running or Stepping to Stopped is to explicitly call Stop(). Program state will not be preserved once the Stopped state is entered.`, - 1: `execution is paused. The sim is waiting for further instructions, and can continue, or stop.`, - 2: `the application is running, but will pause if it hits a StepPoint that matches the current StepGrain.`, - 3: `the application is running, and will NOT pause at StepPoints. It will pause if a stop has been requested.`, -} +var _RunStateMap = map[RunState]string{0: `Stopped`, 1: `Paused`, 2: `Stepping`, 3: `Running`} -// String returns the string representation -// of this RunState value. -func (i RunState) String() string { - if str, ok := _RunStateMap[i]; ok { - return str - } - return strconv.FormatInt(int64(i), 10) -} +// String returns the string representation of this RunState value. +func (i RunState) String() string { return enums.String(i, _RunStateMap) } -// SetString sets the RunState value from its -// string representation, and returns an -// error if the string is invalid. +// SetString sets the RunState value from its string representation, +// and returns an error if the string is invalid. func (i *RunState) SetString(s string) error { - if val, ok := _RunStateNameToValueMap[s]; ok { - *i = val - return nil - } - if val, ok := _RunStateNameToValueMap[strings.ToLower(s)]; ok { - *i = val - return nil - } - return errors.New(s + " is not a valid value for type RunState") + return enums.SetString(i, s, _RunStateValueMap, "RunState") } // Int64 returns the RunState value as an int64. -func (i RunState) Int64() int64 { - return int64(i) -} +func (i RunState) Int64() int64 { return int64(i) } // SetInt64 sets the RunState value from an int64. -func (i *RunState) SetInt64(in int64) { - *i = RunState(in) -} +func (i *RunState) SetInt64(in int64) { *i = RunState(in) } // Desc returns the description of the RunState value. -func (i RunState) Desc() string { - if str, ok := _RunStateDescMap[i]; ok { - return str - } - return i.String() -} - -// RunStateValues returns all possible values -// for the type RunState. -func RunStateValues() []RunState { - return _RunStateValues -} +func (i RunState) Desc() string { return enums.Desc(i, _RunStateDescMap) } -// Values returns all possible values -// for the type RunState. -func (i RunState) Values() []enums.Enum { - res := make([]enums.Enum, len(_RunStateValues)) - for i, d := range _RunStateValues { - res[i] = d - } - return res -} +// RunStateValues returns all possible values for the type RunState. +func RunStateValues() []RunState { return _RunStateValues } -// IsValid returns whether the value is a -// valid option for type RunState. -func (i RunState) IsValid() bool { - _, ok := _RunStateMap[i] - return ok -} +// Values returns all possible values for the type RunState. +func (i RunState) Values() []enums.Enum { return enums.Values(_RunStateValues) } // MarshalText implements the [encoding.TextMarshaler] interface. -func (i RunState) MarshalText() ([]byte, error) { - return []byte(i.String()), nil -} +func (i RunState) MarshalText() ([]byte, error) { return []byte(i.String()), nil } // UnmarshalText implements the [encoding.TextUnmarshaler] interface. -func (i *RunState) UnmarshalText(text []byte) error { - if err := i.SetString(string(text)); err != nil { - log.Println("RunState.UnmarshalText:", err) - } - return nil -} +func (i *RunState) UnmarshalText(text []byte) error { return enums.UnmarshalText(i, text, "RunState") } diff --git a/stepper/gtigen.go b/stepper/gtigen.go index 35e19b03..b79d9a1d 100644 --- a/stepper/gtigen.go +++ b/stepper/gtigen.go @@ -6,7 +6,7 @@ import ( "cogentcore.org/core/gti" ) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/stepper.RunState", IDName: "run-state", Directives: []gti.Directive{{Tool: "enums", Directive: "enum"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/stepper.RunState", IDName: "run-state"}) var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/stepper.StopCheckFn", IDName: "stop-check-fn", Doc: "A StopCheckFn is a callback to check whether an arbitrary condition has been matched.\nIf a StopCheckFn returns true, the program is suspended with a RunState of Paused,\nand will remain so until the RunState changes to Stepping, Running, or Stopped.\nAs noted below for the PauseNotifyFn, the StopCheckFn is called with the Stepper's lock held."}) diff --git a/weights/gtigen.go b/weights/gtigen.go index 4ff80852..a1a53657 100644 --- a/weights/gtigen.go +++ b/weights/gtigen.go @@ -6,7 +6,7 @@ import ( "cogentcore.org/core/gti" ) -var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/weights.Network", IDName: "network", Doc: "Network is temp structure for holding decoded weights", Directives: []gti.Directive{{Tool: "go", Directive: "generate", Args: []string{"goki", "generate", "-add-types"}}}, Fields: []gti.Field{{Name: "Network"}, {Name: "MetaData"}, {Name: "Layers"}}}) +var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/weights.Network", IDName: "network", Doc: "Network is temp structure for holding decoded weights", Directives: []gti.Directive{{Tool: "go", Directive: "generate", Args: []string{"core", "generate", "-add-types"}}}, Fields: []gti.Field{{Name: "Network"}, {Name: "MetaData"}, {Name: "Layers"}}}) var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/weights.Layer", IDName: "layer", Doc: "Layer is temp structure for holding decoded weights, one for each layer", Fields: []gti.Field{{Name: "Layer"}, {Name: "MetaData"}, {Name: "Units"}, {Name: "Prjns"}}})