From 93bde9387cd707221bbde2b5cb7174040af14fa7 Mon Sep 17 00:00:00 2001 From: Kai O'Reilly Date: Sat, 13 Apr 2024 23:31:03 -0700 Subject: [PATCH] more renaming of core packages --- README.md | 2 +- confusion/confusion.go | 22 +- econfig/README.md | 4 +- econfig/args.go | 28 +-- econfig/defaults.go | 4 +- econfig/include.go | 12 +- econfig/io.go | 12 +- econfig/usage.go | 10 +- egui/README.md | 8 +- egui/grids.go | 8 +- egui/gui.go | 50 ++--- egui/loopctrl.go | 12 +- egui/netview.go | 4 +- egui/toolbar.go | 6 +- emer/layer.go | 4 +- emer/network.go | 8 +- emer/prjn.go | 8 +- erand/distsplot/distsplot.go | 22 +- netparams/io.go | 76 +++---- netview/events.go | 10 +- netview/gtigen.go | 23 +- netview/netdata.go | 24 +- netview/netview.go | 198 ++++++++--------- netview/params.go | 8 +- netview/viewupdt.go | 4 +- params/apply.go | 20 +- params/applymap.go | 12 +- params/flex.go | 4 +- params/io.go | 412 +++++++++++++++++------------------ params/params.go | 4 +- params/tweak.go | 6 +- params/tweak_test.go | 6 +- patgen/reshape.go | 6 +- stepper/README.md | 16 +- 34 files changed, 526 insertions(+), 527 deletions(-) diff --git a/README.md b/README.md index d73cf77..daf65cd 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ See [python README](https://github.com/emer/leabra/blob/master/python/README.md) * The system is fully usable from within Python -- see the [Python Wiki](https://github.com/emer/emergent/wiki/Python). This includes interoperating with PyTorch via [eTorch](https://github.com/emer/etorch), and [PsyNeuLink](https://princetonuniversity.github.io/PsyNeuLink/) to make Leabra models accessible in that framework, and vice-versa. Furthermore, interactive, IDE-level tools such as `Jupyter` and `nteract` can be used to interactively develop and analyze the models, etc. -* We are leveraging the [GoGi Gui](https://cogentcore.org/core/gi/v2) to provide interactive 2D and 3D GUI interfaces to models, capturing the essential functionality of the original C++ emergent interface, but in a much more a-la-carte fashion. We also use and support the [GoNum](https://github.com/gonum) framework for analyzing and plotting results within Go. +* We are leveraging the [Cogent Core GUI](https://cogentcore.org/core) to provide interactive 2D and 3D GUI interfaces to models, capturing the essential functionality of the original C++ emergent interface, but in a much more a-la-carte fashion. We also use and support the [GoNum](https://github.com/gonum) framework for analyzing and plotting results within Go. # Design / Organization diff --git a/confusion/confusion.go b/confusion/confusion.go index 037b675..14435dd 100644 --- a/confusion/confusion.go +++ b/confusion/confusion.go @@ -10,7 +10,7 @@ import ( "fmt" "math" - "cogentcore.org/core/gi" + "cogentcore.org/core/core" "github.com/emer/etable/v2/etensor" "github.com/emer/etable/v2/simat" ) @@ -200,34 +200,34 @@ func (cm *Matrix) ScoreMatrix() { } // SaveCSV saves Prob result to a CSV file, comma separated -func (cm *Matrix) SaveCSV(fname gi.Filename) { +func (cm *Matrix) SaveCSV(fname core.Filename) { etensor.SaveCSV(&cm.Prob, fname, ',') } // OpenCSV opens Prob result from a CSV file, comma separated -func (cm *Matrix) OpenCSV(fname gi.Filename) { +func (cm *Matrix) OpenCSV(fname core.Filename) { etensor.OpenCSV(&cm.Prob, fname, ',') } /* -var MatrixProps = ki.Props{ - "ToolBar": ki.PropSlice{ - {"SaveCSV", ki.Props{ +var MatrixProps = tree.Props{ + "ToolBar": tree.PropSlice{ + {"SaveCSV", tree.Props{ "label": "Save CSV...", "icon": "file-save", "desc": "Save CSV-formatted confusion probabilities (Probs)", - "Args": ki.PropSlice{ - {"CSV File Name", ki.Props{ + "Args": tree.PropSlice{ + {"CSV File Name", tree.Props{ "ext": ".csv", }}, }, }}, - {"OpenCSV", ki.Props{ + {"OpenCSV", tree.Props{ "label": "Open CSV...", "icon": "file-open", "desc": "Open CSV-formatted confusion probabilities (Probs)", - "Args": ki.PropSlice{ - {"Weights File Name", ki.Props{ + "Args": tree.PropSlice{ + {"Weights File Name", tree.Props{ "ext": ".csv", }}, }, diff --git a/econfig/README.md b/econfig/README.md index c3416d4..a011b79 100644 --- a/econfig/README.md +++ b/econfig/README.md @@ -5,7 +5,7 @@ Docs: [GoDoc](https://pkg.go.dev/github.com/emer/emergent/econfig) * Standard usage: + `cfg := &ss.Config` + `cfg.Defaults()` -- sets hard-coded defaults -- user should define and call this method first. - + It is better to use the `def:` field tag however because it then shows in `-h` or `--help` usage and in the [GoGi](https://cogentcore.org/core/gi/v2) GUI. See [Default Tags](#def_default_tags) for how to specify def values for more complex types. + + It is better to use the `default:` field tag however because it then shows in `-h` or `--help` usage and in the [Cogent Core](https://cogentcore.org/core) GUI. See [Default Tags](#def_default_tags) for how to specify def values for more complex types. + `econfig.Config(cfg, "config.toml")` -- sets config values according to the standard order, with given file name specifying the default config file name. * Has support for nested `Include` paths, which are processed in the natural deepest-first order. The processed `Config` struct field will contain a list of all such files processed. There are two options for include file support: @@ -50,7 +50,7 @@ Docs: [GoDoc](https://pkg.go.dev/github.com/emer/emergent/econfig) "Prjn:Prjn.Learn.LRate.Base" = 0.05 ``` -* Field tag `def:"value"`, used in the [GoGi](https://cogentcore.org/core/gi/v2) GUI, sets the initial default value and is shown for the `-h` or `--help` usage info. +* Field tag `default:"value"`, used in the [Cogent Core](https://cogentcore.org/core) GUI, sets the initial default value and is shown for the `-h` or `--help` usage info. * [kit](https://cogentcore.org/core/ki) registered "enum" `const` types, with names automatically parsed from string values (including bit flags). Must use the [goki stringer](https://github.com/goki/stringer) version to generate `FromString()` method, and register the type like this: `var KitTestEnum = kit.Enums.AddEnum(TestEnumN, kit.NotBitFlag, nil)` -- see [enum.go](enum.go) file for example. diff --git a/econfig/args.go b/econfig/args.go index 4171aac..91f92eb 100644 --- a/econfig/args.go +++ b/econfig/args.go @@ -13,8 +13,8 @@ import ( "reflect" "strings" - "cogentcore.org/core/grows/tomls" - "cogentcore.org/core/laser" + "cogentcore.org/core/iox/tomlx" + "cogentcore.org/core/reflectx" "github.com/emer/empi/v2/mpi" "github.com/iancoleman/strcase" ) @@ -92,7 +92,7 @@ func ParseArg(s string, args []string, allArgs map[string]reflect.Value, errNotF return } - isbool := laser.NonPtrValue(fval).Kind() == reflect.Bool + isbool := reflectx.NonPtrValue(fval).Kind() == reflect.Bool var value string switch { @@ -134,7 +134,7 @@ func ParseArg(s string, args []string, allArgs map[string]reflect.Value, errNotF // SetArgValue sets given arg name to given value, into settable reflect.Value func SetArgValue(name string, fval reflect.Value, value string) error { - nptyp := laser.NonPtrType(fval.Type()) + nptyp := reflectx.NonPtrType(fval.Type()) vk := nptyp.Kind() switch { // todo: enum @@ -142,12 +142,12 @@ func SetArgValue(name string, fval reflect.Value, value string) error { // return kit.Enums.SetAnyEnumValueFromString(fval, value) case vk == reflect.Map: mval := make(map[string]any) - err := tomls.ReadBytes(&mval, []byte("tmp="+value)) // use toml decoder + err := tomlx.ReadBytes(&mval, []byte("tmp="+value)) // use toml decoder if err != nil { mpi.Println(err) return err } - err = laser.CopyMapRobust(fval.Interface(), mval["tmp"]) + err = reflectx.CopyMapRobust(fval.Interface(), mval["tmp"]) if err != nil { mpi.Println(err) err = fmt.Errorf("econfig.ParseArgs: not able to set map field from arg: %s val: %s", name, value) @@ -156,12 +156,12 @@ func SetArgValue(name string, fval reflect.Value, value string) error { } case vk == reflect.Slice: mval := make(map[string]any) - err := tomls.ReadBytes(&mval, []byte("tmp="+value)) // use toml decoder + err := tomlx.ReadBytes(&mval, []byte("tmp="+value)) // use toml decoder if err != nil { mpi.Println(err) return err } - err = laser.CopySliceRobust(fval.Interface(), mval["tmp"]) + err = reflectx.CopySliceRobust(fval.Interface(), mval["tmp"]) if err != nil { mpi.Println(err) err = fmt.Errorf("econfig.ParseArgs: not able to set slice field from arg: %s val: %s", name, value) @@ -169,7 +169,7 @@ func SetArgValue(name string, fval reflect.Value, value string) error { return err } default: - err := laser.SetRobust(fval.Interface(), value) // overkill but whatever + err := reflectx.SetRobust(fval.Interface(), value) // overkill but whatever if err != nil { err := fmt.Errorf("econfig.ParseArgs: not able to set field from arg: %s val: %s", name, value) mpi.Println(err) @@ -202,19 +202,19 @@ func addAllCases(nm, path string, pval reflect.Value, allArgs map[string]reflect // fieldArgNamesStruct returns map of all the different ways the field names // can be specified as arg flags, mapping to the reflect.Value func fieldArgNamesStruct(obj any, path string, nest bool, allArgs map[string]reflect.Value) { - if laser.AnyIsNil(obj) { + if reflectx.AnyIsNil(obj) { return } ov := reflect.ValueOf(obj) if ov.Kind() == reflect.Pointer && ov.IsNil() { return } - val := laser.NonPtrValue(ov) + val := reflectx.NonPtrValue(ov) typ := val.Type() for i := 0; i < typ.NumField(); i++ { f := typ.Field(i) fv := val.Field(i) - if laser.NonPtrType(f.Type).Kind() == reflect.Struct { + if reflectx.NonPtrType(f.Type).Kind() == reflect.Struct { nwPath := f.Name if path != "" { nwPath = path + "." + nwPath @@ -226,10 +226,10 @@ func fieldArgNamesStruct(obj any, path string, nest bool, allArgs map[string]ref nwNest = true } } - fieldArgNamesStruct(laser.PtrValue(fv).Interface(), nwPath, nwNest, allArgs) + fieldArgNamesStruct(reflectx.PtrValue(fv).Interface(), nwPath, nwNest, allArgs) continue } - pval := laser.PtrValue(fv) + pval := reflectx.PtrValue(fv) addAllCases(f.Name, path, pval, allArgs) if f.Type.Kind() == reflect.Bool { addAllCases("No"+f.Name, path, pval, allArgs) diff --git a/econfig/defaults.go b/econfig/defaults.go index cf1e50e..aa70e81 100644 --- a/econfig/defaults.go +++ b/econfig/defaults.go @@ -4,10 +4,10 @@ package econfig -import "cogentcore.org/core/laser" +import "cogentcore.org/core/reflectx" // SetFromDefaults sets Config values from field tag `def:` values. // Parsing errors are automatically logged. func SetFromDefaults(cfg any) error { - return laser.SetFromDefaultTags(cfg) + return reflectx.SetFromDefaultTags(cfg) } diff --git a/econfig/include.go b/econfig/include.go index d9de360..3667625 100644 --- a/econfig/include.go +++ b/econfig/include.go @@ -11,8 +11,8 @@ import ( "errors" "reflect" - "cogentcore.org/core/grows/tomls" - "cogentcore.org/core/laser" + "cogentcore.org/core/iox/tomlx" + "cogentcore.org/core/reflectx" ) // Includeser enables processing of Includes []string field with files to include in Config objects. @@ -35,7 +35,7 @@ type Includer interface { // Returns an error if any of the include files cannot be found on IncludePath. // Does not alter cfg. func IncludesStack(cfg Includeser) ([]string, error) { - clone := reflect.New(laser.NonPtrType(reflect.TypeOf(cfg))).Interface().(Includeser) + clone := reflect.New(reflectx.NonPtrType(reflect.TypeOf(cfg))).Interface().(Includeser) *clone.IncludesPtr() = *cfg.IncludesPtr() return includesStackImpl(clone, nil) } @@ -54,7 +54,7 @@ func includesStackImpl(clone Includeser, includes []string) ([]string, error) { var errs []error for _, inc := range incs { *clone.IncludesPtr() = nil - err := tomls.OpenFromPaths(clone, inc, IncludePaths) + err := tomlx.OpenFromPaths(clone, inc, IncludePaths) if err == nil { includes, err = includesStackImpl(clone, includes) if err != nil { @@ -73,7 +73,7 @@ func includesStackImpl(clone Includeser, includes []string) ([]string, error) { // Returns an error if any of the include files cannot be found on IncludePath. // Does not alter cfg. func IncludeStack(cfg Includer) ([]string, error) { - clone := reflect.New(laser.NonPtrType(reflect.TypeOf(cfg))).Interface().(Includer) + clone := reflect.New(reflectx.NonPtrType(reflect.TypeOf(cfg))).Interface().(Includer) *clone.IncludePtr() = *cfg.IncludePtr() return includeStackImpl(clone, nil) } @@ -88,7 +88,7 @@ func includeStackImpl(clone Includer, includes []string) ([]string, error) { includes = append(includes, inc) var errs []error *clone.IncludePtr() = "" - err := tomls.OpenFromPaths(clone, inc, IncludePaths) + err := tomlx.OpenFromPaths(clone, inc, IncludePaths) if err == nil { includes, err = includeStackImpl(clone, includes) if err != nil { diff --git a/econfig/io.go b/econfig/io.go index 32fdd54..a99ea62 100644 --- a/econfig/io.go +++ b/econfig/io.go @@ -8,7 +8,7 @@ import ( "io/fs" "strings" - "cogentcore.org/core/grows/tomls" + "cogentcore.org/core/iox/tomlx" "github.com/emer/empi/v2/mpi" ) @@ -19,7 +19,7 @@ import ( // Is equivalent to Open if there are no Includes. // Returns an error if any of the include files cannot be found on IncludePath. func OpenWithIncludes(cfg any, file string) error { - err := tomls.OpenFromPaths(cfg, file, IncludePaths) + err := tomlx.OpenFromPaths(cfg, file, IncludePaths) if err != nil { return err } @@ -40,13 +40,13 @@ func OpenWithIncludes(cfg any, file string) error { } for i := ni - 1; i >= 0; i-- { inc := incs[i] - err = tomls.OpenFromPaths(cfg, inc, IncludePaths) + err = tomlx.OpenFromPaths(cfg, inc, IncludePaths) if err != nil { mpi.Println(err) } } // reopen original - tomls.OpenFromPaths(cfg, file, IncludePaths) + tomlx.OpenFromPaths(cfg, file, IncludePaths) if hasIncludes { *incsObj.IncludesPtr() = incs } else { @@ -58,10 +58,10 @@ func OpenWithIncludes(cfg any, file string) error { // OpenFS reads config from given TOML file, // using the fs.FS filesystem -- e.g., for embed files. func OpenFS(cfg any, fsys fs.FS, file string) error { - return tomls.OpenFS(cfg, fsys, file) + return tomlx.OpenFS(cfg, fsys, file) } // Save writes TOML to given file. func Save(cfg any, file string) error { - return tomls.Save(cfg, file) + return tomlx.Save(cfg, file) } diff --git a/econfig/usage.go b/econfig/usage.go index 54203f1..decfcaf 100644 --- a/econfig/usage.go +++ b/econfig/usage.go @@ -9,7 +9,7 @@ import ( "reflect" "strings" - "cogentcore.org/core/laser" + "cogentcore.org/core/reflectx" ) // Usage returns the usage string for args based on given Config object @@ -28,17 +28,17 @@ func Usage(cfg any) string { // usageStruct adds usage info to given strings.Builder func usageStruct(obj any, path string, b *strings.Builder) { - typ := laser.NonPtrType(reflect.TypeOf(obj)) - val := laser.NonPtrValue(reflect.ValueOf(obj)) + typ := reflectx.NonPtrType(reflect.TypeOf(obj)) + val := reflectx.NonPtrValue(reflect.ValueOf(obj)) for i := 0; i < typ.NumField(); i++ { f := typ.Field(i) fv := val.Field(i) - if laser.NonPtrType(f.Type).Kind() == reflect.Struct { + if reflectx.NonPtrType(f.Type).Kind() == reflect.Struct { nwPath := f.Name if path != "" { nwPath = path + "." + nwPath } - usageStruct(laser.PtrValue(fv).Interface(), nwPath, b) + usageStruct(reflectx.PtrValue(fv).Interface(), nwPath, b) continue } nm := f.Name diff --git a/egui/README.md b/egui/README.md index 223362e..55f6e4c 100644 --- a/egui/README.md +++ b/egui/README.md @@ -10,7 +10,7 @@ Here's the start of the main ConfigGUI method: ```Go // ConfigGUI configures the Cogent Core GUI interface for this simulation. -func (ss *Sim) ConfigGUI() *gi.Window { +func (ss *Sim) ConfigGUI() *core.Window { title := "Leabra Random Associator" ss.GUI.MakeWindow(ss, "ra25", title, `This demonstrates a basic Leabra model. See emergent on GitHub.

`) ss.GUI.CycleUpdateInterval = 10 @@ -25,7 +25,7 @@ func (ss *Sim) ConfigGUI() *gi.Window { ## Toolbar Items -The `ToolbarItem` class provides toolbar configuration options, taking the place of `gi.ActOpts` from existing code that operates directly at the `GoGi` level. The main differences are +The `ToolbarItem` class provides toolbar configuration options, taking the place of `core.ActOpts` from existing code that operates directly at the `GoGi` level. The main differences are * The standard `UpdateFunc` options of either making the action active or inactive while the sim is running are now handled using `Active: equi.ActiveStopped` or `egui.ActiveRunning` or `egui.ActiveAlways` @@ -79,8 +79,8 @@ Here's an `ActiveRunning` case: ## Spike Rasters ```Go - stb := ss.GUI.TabView.AddNewTab(gi.KiT_Layout, "Spike Rasters").(*gi.Layout) - stb.Lay = gi.LayoutVert + stb := ss.GUI.TabView.AddNewTab(core.KiT_Layout, "Spike Rasters").(*core.Layout) + stb.Lay = core.LayoutVert stb.SetStretchMax() for _, lnm := range ss.Stats.Rasters { sr := ss.Stats.F32Tensor("Raster_" + lnm) diff --git a/egui/grids.go b/egui/grids.go index 5be2865..5138014 100644 --- a/egui/grids.go +++ b/egui/grids.go @@ -5,7 +5,7 @@ package egui import ( - "cogentcore.org/core/gi" + "cogentcore.org/core/core" "github.com/emer/emergent/v2/actrf" "github.com/emer/etable/v2/etensor" "github.com/emer/etable/v2/etview" @@ -34,12 +34,12 @@ func (gui *GUI) SetGrid(name string, tg *etview.TensorGrid) { // ConfigRasterGrid configures a raster grid for given layer name. // Uses Raster_laynm and given Tensor that has the raster data. -func (gui *GUI) ConfigRasterGrid(lay *gi.Layout, laynm string, rast *etensor.Float32) *etview.TensorGrid { +func (gui *GUI) ConfigRasterGrid(lay *core.Layout, laynm string, rast *etensor.Float32) *etview.TensorGrid { tg := gui.Grid(laynm) tg.SetName(laynm + "Raster") - gi.NewLabel(lay, laynm, laynm+":") + core.NewLabel(lay, laynm, laynm+":") lay.AddChild(tg) - gi.NewSpace(lay, laynm+"_spc") + core.NewSpace(lay, laynm+"_spc") rast.SetMetaData("grid-fill", "1") tg.SetTensor(rast) return tg diff --git a/egui/gui.go b/egui/gui.go index 8dd7a76..0a58bd4 100644 --- a/egui/gui.go +++ b/egui/gui.go @@ -7,8 +7,8 @@ package egui //go:generate core generate -add-types import ( - "cogentcore.org/core/gi" - "cogentcore.org/core/giv" + "cogentcore.org/core/core" + "cogentcore.org/core/views" "github.com/emer/emergent/v2/etime" "github.com/emer/emergent/v2/netview" "github.com/emer/etable/v2/eplot" @@ -47,13 +47,13 @@ type GUI struct { NetData *netview.NetData `view:"-"` // displays Sim fields on left - StructView *giv.StructView `view:"-"` + StructView *views.StructView `view:"-"` // tabs for different view elements: plots, rasters - Tabs *gi.Tabs `view:"-"` + Tabs *core.Tabs `view:"-"` // Body is the content of the sim window - Body *gi.Body `view:"-"` + Body *core.Body `view:"-"` } // UpdateWindow triggers an update on window body, @@ -98,16 +98,16 @@ func (gui *GUI) Stopped() { // MakeBody returns default window Body content func (gui *GUI) MakeBody(sim any, appname, title, about string) { - giv.NoSentenceCaseFor = append(giv.NoSentenceCaseFor, "github.com/emer") + views.NoSentenceCaseFor = append(views.NoSentenceCaseFor, "github.com/emer") - gui.Body = gi.NewBody(appname).SetTitle(title) + gui.Body = core.NewBody(appname).SetTitle(title) // gui.Body.App().About = about - split := gi.NewSplits(gui.Body, "split") - gui.StructView = giv.NewStructView(split, "sv").SetStruct(sim) - if tb, ok := sim.(gi.Toolbarer); ok { + split := core.NewSplits(gui.Body, "split") + gui.StructView = views.NewStructView(split, "sv").SetStruct(sim) + if tb, ok := sim.(core.Toolbarer); ok { gui.Body.AddAppBar(tb.ConfigToolbar) } - gui.Tabs = gi.NewTabs(split, "tv") + gui.Tabs = core.NewTabs(split, "tv") split.SetSplits(.2, .8) } @@ -124,16 +124,16 @@ func (gui *GUI) FinalizeGUI(closePrompt bool) { if closePrompt { /* inQuitPrompt := false - gi.SetQuitReqFunc(func() { + core.SetQuitReqFunc(func() { if inQuitPrompt { return } inQuitPrompt = true - gi.PromptDialog(vp, gi.DlgOpts{Title: "Really Quit?", - Prompt: "Are you sure you want to quit and lose any unsaved params, weights, logs, etc?"}, gi.AddOk, gi.AddCancel, - gui.Win.This(), func(recv, send ki.Ki, sig int64, data any) { - if sig == int64(gi.DialogAccepted) { - gi.Quit() + core.PromptDialog(vp, core.DlgOpts{Title: "Really Quit?", + Prompt: "Are you sure you want to quit and lose any unsaved params, weights, logs, etc?"}, core.AddOk, core.AddCancel, + gui.Win.This(), func(recv, send tree.Ki, sig int64, data any) { + if sig == int64(core.DialogAccepted) { + core.Quit() } else { inQuitPrompt = false } @@ -141,16 +141,16 @@ func (gui *GUI) FinalizeGUI(closePrompt bool) { }) inClosePrompt := false - gui.Win.SetCloseReqFunc(func(w *gi.Window) { + gui.Win.SetCloseReqFunc(func(w *core.Window) { if inClosePrompt { return } inClosePrompt = true - gi.PromptDialog(vp, gi.DlgOpts{Title: "Really Close gui.Window?", - Prompt: "Are you sure you want to close the gui.Window? This will Quit the App as well, losing all unsaved params, weights, logs, etc"}, gi.AddOk, gi.AddCancel, - gui.Win.This(), func(recv, send ki.Ki, sig int64, data any) { - if sig == int64(gi.DialogAccepted) { - gi.Quit() + core.PromptDialog(vp, core.DlgOpts{Title: "Really Close gui.Window?", + Prompt: "Are you sure you want to close the gui.Window? This will Quit the App as well, losing all unsaved params, weights, logs, etc"}, core.AddOk, core.AddCancel, + gui.Win.This(), func(recv, send tree.Ki, sig int64, data any) { + if sig == int64(core.DialogAccepted) { + core.Quit() } else { inClosePrompt = false } @@ -159,8 +159,8 @@ func (gui *GUI) FinalizeGUI(closePrompt bool) { */ } - // gui.Win.SetCloseCleanFunc(func(w *gi.Window) { - // go gi.Quit() // once main gui.Window is closed, quit + // gui.Win.SetCloseCleanFunc(func(w *core.Window) { + // go core.Quit() // once main gui.Window is closed, quit // }) gui.Active = true diff --git a/egui/loopctrl.go b/egui/loopctrl.go index e389490..d95112e 100644 --- a/egui/loopctrl.go +++ b/egui/loopctrl.go @@ -6,8 +6,8 @@ package egui import ( "cogentcore.org/core/abilities" + "cogentcore.org/core/core" "cogentcore.org/core/events" - "cogentcore.org/core/gi" "cogentcore.org/core/icons" "cogentcore.org/core/styles" "github.com/emer/emergent/v2/etime" @@ -16,7 +16,7 @@ import ( // AddLooperCtrl adds toolbar control for looper.Stack // with Run, Step controls. -func (gui *GUI) AddLooperCtrl(tb *gi.Toolbar, loops *looper.Manager, modes []etime.Modes) { +func (gui *GUI) AddLooperCtrl(tb *core.Toolbar, loops *looper.Manager, modes []etime.Modes) { gui.AddToolbarItem(tb, ToolbarItem{Label: "Stop", Icon: icons.Stop, Tooltip: "Interrupts running. running / stepping picks back up where it left off.", @@ -30,7 +30,7 @@ func (gui *GUI) AddLooperCtrl(tb *gi.Toolbar, loops *looper.Manager, modes []eti for _, m := range modes { mode := m - gi.NewButton(tb).SetText(mode.String() + " Run").SetIcon(icons.PlayArrow). + core.NewButton(tb).SetText(mode.String() + " Run").SetIcon(icons.PlayArrow). SetTooltip("Run the " + mode.String() + " process"). StyleFirst(func(s *styles.Style) { s.SetEnabled(!gui.IsRunning) }). OnClick(func(e events.Event) { @@ -52,7 +52,7 @@ func (gui *GUI) AddLooperCtrl(tb *gi.Toolbar, loops *looper.Manager, modes []eti stepN[st.String()] = 1 stringToEnumTime[st.String()] = st } - gi.NewButton(tb).SetText("Step").SetIcon(icons.SkipNext). + core.NewButton(tb).SetText("Step").SetIcon(icons.SkipNext). SetTooltip("Step the " + mode.String() + " process according to the following step level and N"). StyleFirst(func(s *styles.Style) { s.SetEnabled(!gui.IsRunning) @@ -70,7 +70,7 @@ func (gui *GUI) AddLooperCtrl(tb *gi.Toolbar, loops *looper.Manager, modes []eti } }) - scb := gi.NewChooser(tb, "step") + scb := core.NewChooser(tb, "step") stepStrs := []string{} for _, s := range steps { stepStrs = append(stepStrs, s.String()) @@ -79,7 +79,7 @@ func (gui *GUI) AddLooperCtrl(tb *gi.Toolbar, loops *looper.Manager, modes []eti stack := loops.Stacks[mode] scb.SetCurrentValue(stack.StepLevel.String()) - sb := gi.NewSpinner(tb, "step-n").SetTooltip("number of iterations per step"). + sb := core.NewSpinner(tb, "step-n").SetTooltip("number of iterations per step"). SetStep(1).SetMin(1).SetValue(1) sb.OnChange(func(e events.Event) { stepN[scb.CurrentItem.Value.(string)] = int(sb.Value) diff --git a/egui/netview.go b/egui/netview.go index 3b00335..47082f7 100644 --- a/egui/netview.go +++ b/egui/netview.go @@ -5,7 +5,7 @@ package egui import ( - "cogentcore.org/core/gi" + "cogentcore.org/core/core" "github.com/emer/emergent/v2/emer" "github.com/emer/emergent/v2/netview" ) @@ -49,5 +49,5 @@ func (gui *GUI) SaveNetData(extra string) { return } ndfn := gui.NetData.Net.Name() + "_" + extra + ".netdata.gz" - gui.NetData.SaveJSON(gi.Filename(ndfn)) + gui.NetData.SaveJSON(core.Filename(ndfn)) } diff --git a/egui/toolbar.go b/egui/toolbar.go index 7b3cb69..531af2e 100644 --- a/egui/toolbar.go +++ b/egui/toolbar.go @@ -5,8 +5,8 @@ package egui import ( + "cogentcore.org/core/core" "cogentcore.org/core/events" - "cogentcore.org/core/gi" "cogentcore.org/core/icons" "cogentcore.org/core/styles" ) @@ -21,8 +21,8 @@ type ToolbarItem struct { } // AddToolbarItem adds a toolbar item but also checks when it be active in the UI -func (gui *GUI) AddToolbarItem(tb *gi.Toolbar, item ToolbarItem) { - itm := gi.NewButton(tb).SetText(item.Label).SetIcon(item.Icon). +func (gui *GUI) AddToolbarItem(tb *core.Toolbar, item ToolbarItem) { + itm := core.NewButton(tb).SetText(item.Label).SetIcon(item.Icon). SetTooltip(item.Tooltip).OnClick(func(e events.Event) { item.Func() }) diff --git a/emer/layer.go b/emer/layer.go index 0b7f6da..00746f5 100644 --- a/emer/layer.go +++ b/emer/layer.go @@ -30,7 +30,7 @@ type Layer interface { // the parent network that this layer belongs to (which layers may want to retain). InitName(lay Layer, name string, net Network) - // Label satisfies the gi.Labeler interface for getting the name of objects generically + // Label satisfies the core.Labeler interface for getting the name of objects generically Label() string // SetName sets name of layer @@ -354,7 +354,7 @@ func Layer2DRepIndexes(ly Layer, maxSize int) (idxs, shape []int) { // Layers is a slice of layers type Layers []Layer -// ElemLabel satisfies the gi.SliceLabeler interface to provide labels for slice elements +// ElemLabel satisfies the core.SliceLabeler interface to provide labels for slice elements func (ls *Layers) ElemLabel(idx int) string { return (*ls)[idx].Name() } diff --git a/emer/network.go b/emer/network.go index c9080e7..a3f72de 100644 --- a/emer/network.go +++ b/emer/network.go @@ -9,7 +9,7 @@ package emer import ( "io" - "cogentcore.org/core/gi" + "cogentcore.org/core/core" "cogentcore.org/core/math32" "github.com/emer/emergent/v2/params" "github.com/emer/emergent/v2/weights" @@ -25,7 +25,7 @@ type Network interface { // Name() returns name of the network Name() string - // Label satisfies the gi.Labeler interface for getting the name of objects generically + // Label satisfies the core.Labeler interface for getting the name of objects generically Label() string // NLayers returns the number of layers in the network @@ -127,11 +127,11 @@ type Network interface { // SaveWtsJSON saves network weights (and any other state that adapts with learning) // to a JSON-formatted file. If filename has .gz extension, then file is gzip compressed. - SaveWtsJSON(filename gi.Filename) error + SaveWtsJSON(filename core.Filename) error // OpenWtsJSON opens network weights (and any other state that adapts with learning) // from a JSON-formatted file. If filename has .gz extension, then file is gzip uncompressed. - OpenWtsJSON(filename gi.Filename) error + OpenWtsJSON(filename core.Filename) error // Bounds returns the minimum and maximum display coordinates of the network for 3D display Bounds() (min, max math32.Vec3) diff --git a/emer/prjn.go b/emer/prjn.go index 752f400..5267904 100644 --- a/emer/prjn.go +++ b/emer/prjn.go @@ -8,7 +8,7 @@ import ( "fmt" "io" - "cogentcore.org/core/laser" + "cogentcore.org/core/reflectx" "github.com/emer/emergent/v2/params" "github.com/emer/emergent/v2/prjn" "github.com/emer/emergent/v2/weights" @@ -57,7 +57,7 @@ type Prjn interface { // Returns Prjn so it can be chained to set other properties too AddClass(cls ...string) Prjn - // Label satisfies the gi.Labeler interface for getting the name of objects generically + // Label satisfies the core.Labeler interface for getting the name of objects generically Label() string // IsOff returns true if projection or either send or recv layer has been turned Off. @@ -172,7 +172,7 @@ type Prjn interface { // Prjns is a slice of projections type Prjns []Prjn -// ElemLabel satisfies the gi.SliceLabeler interface to provide labels for slice elements +// ElemLabel satisfies the core.SliceLabeler interface to provide labels for slice elements func (pl *Prjns) ElemLabel(idx int) string { if len(*pl) == 0 { return "(empty)" @@ -181,7 +181,7 @@ func (pl *Prjns) ElemLabel(idx int) string { return "" } pj := (*pl)[idx] - if laser.AnyIsNil(pj) { + if reflectx.AnyIsNil(pj) { return "nil" } return pj.Name() diff --git a/erand/distsplot/distsplot.go b/erand/distsplot/distsplot.go index 917d084..19367a5 100644 --- a/erand/distsplot/distsplot.go +++ b/erand/distsplot/distsplot.go @@ -10,10 +10,10 @@ package main import ( "strconv" + "cogentcore.org/core/core" "cogentcore.org/core/events" - "cogentcore.org/core/gi" - "cogentcore.org/core/giv" "cogentcore.org/core/icons" + "cogentcore.org/core/views" "github.com/emer/emergent/v2/erand" "github.com/emer/etable/v2/eplot" "github.com/emer/etable/v2/etable" @@ -119,15 +119,15 @@ func (ss *Sim) ConfigPlot(plt *eplot.Plot2D, dt *etable.Table) *eplot.Plot2D { } // ConfigGUI configures the Cogent Core GUI interface for this simulation. -func (ss *Sim) ConfigGUI() *gi.Body { - b := gi.NewBody("distplot") +func (ss *Sim) ConfigGUI() *core.Body { + b := core.NewBody("distplot") - split := gi.NewSplits(b, "split") + split := core.NewSplits(b, "split") - sv := giv.NewStructView(split, "sv") + sv := views.NewStructView(split, "sv") sv.SetStruct(ss) - tv := gi.NewTabs(split, "tv") + tv := core.NewTabs(split, "tv") pt := tv.NewTab("Histogram") plt := eplot.NewPlot2D(pt) @@ -135,16 +135,16 @@ func (ss *Sim) ConfigGUI() *gi.Body { split.SetSplits(.3, .7) - b.AddAppBar(func(tb *gi.Toolbar) { - gi.NewButton(tb).SetText("Run").SetIcon(icons.Update). + b.AddAppBar(func(tb *core.Toolbar) { + core.NewButton(tb).SetText("Run").SetIcon(icons.Update). SetTooltip("Generate data and plot histogram."). OnClick(func(e events.Event) { ss.Run() }) - gi.NewButton(tb).SetText("README").SetIcon(icons.FileMarkdown). + core.NewButton(tb).SetText("README").SetIcon(icons.FileMarkdown). SetTooltip("Opens your browser on the README file that contains instructions for how to run this model."). OnClick(func(e events.Event) { - gi.TheApp.OpenURL("https://github.com/emer/emergent/v2/blob/master/erand/distplot/README.md") + core.TheApp.OpenURL("https://github.com/emer/emergent/v2/blob/master/erand/distplot/README.md") }) }) b.RunMainWindow() diff --git a/netparams/io.go b/netparams/io.go index df227a4..1f097c6 100644 --- a/netparams/io.go +++ b/netparams/io.go @@ -12,13 +12,13 @@ import ( "log" "os" - "cogentcore.org/core/gi" + "cogentcore.org/core/core" "cogentcore.org/core/gox/indent" - "cogentcore.org/core/grows" - "cogentcore.org/core/grows/jsons" - "cogentcore.org/core/grows/tomls" + "cogentcore.org/core/iox/jsonx" + "cogentcore.org/core/iox/tomlx" "github.com/BurntSushi/toml" "github.com/emer/emergent/v2/params" + "goki.dev/grows" ) // WriteGoPrelude writes the start of a go file in package main that starts a @@ -32,7 +32,7 @@ func WriteGoPrelude(w io.Writer, varNm string) { } // OpenJSON opens params from a JSON-formatted file. -func (pr *Sets) OpenJSON(filename gi.Filename) error { +func (pr *Sets) OpenJSON(filename core.Filename) error { *pr = make(Sets) // reset b, err := ioutil.ReadFile(string(filename)) if err != nil { @@ -43,19 +43,19 @@ func (pr *Sets) OpenJSON(filename gi.Filename) error { } // SaveJSON saves params to a JSON-formatted file. -func (pr *Sets) SaveJSON(filename gi.Filename) error { - return jsons.Save(pr, string(filename)) +func (pr *Sets) SaveJSON(filename core.Filename) error { + return jsonx.Save(pr, string(filename)) } // OpenTOML opens params from a TOML-formatted file. -func (pr *Sets) OpenTOML(filename gi.Filename) error { +func (pr *Sets) OpenTOML(filename core.Filename) error { *pr = make(Sets) // reset - return tomls.Open(pr, string(filename)) + return tomlx.Open(pr, string(filename)) } // SaveTOML saves params to a TOML-formatted file. -func (pr *Sets) SaveTOML(filename gi.Filename) error { - // return tomls.Save(pr, string(filename)) // pelletier/go-toml produces bad output on maps +func (pr *Sets) SaveTOML(filename core.Filename) error { + // return tomlx.Save(pr, string(filename)) // pelletier/go-toml produces bad output on maps return grows.Save(pr, string(filename), func(w io.Writer) grows.Encoder { return toml.NewEncoder(w) }) @@ -83,7 +83,7 @@ func (pr *Sets) StringGoCode() []byte { } // SaveGoCode saves params to corresponding Go initializer code. -func (pr *Sets) SaveGoCode(filename gi.Filename) error { +func (pr *Sets) SaveGoCode(filename core.Filename) error { fp, err := os.Create(string(filename)) defer fp.Close() if err != nil { @@ -96,85 +96,85 @@ func (pr *Sets) SaveGoCode(filename gi.Filename) error { } /* -var SetsProps = ki.Props{ - "ToolBar": ki.PropSlice{ - {"Save", ki.PropSlice{ - {"SaveTOML", ki.Props{ +var SetsProps = tree.Props{ + "ToolBar": tree.PropSlice{ + {"Save", tree.PropSlice{ + {"SaveTOML", tree.Props{ "label": "Save As TOML...", "desc": "save to TOML formatted file", "icon": "file-save", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".toml", }}, }, }}, - {"SaveJSON", ki.Props{ + {"SaveJSON", tree.Props{ "label": "Save As JSON...", "desc": "save to JSON formatted file", "icon": "file-save", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".json", }}, }, }}, - {"SaveGoCode", ki.Props{ + {"SaveGoCode", tree.Props{ "label": "Save Code As...", "desc": "save to Go-formatted initializer code in file", "icon": "go", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".go", }}, }, }}, }}, - {"Open", ki.PropSlice{ - {"OpenTOML", ki.Props{ + {"Open", tree.PropSlice{ + {"OpenTOML", tree.Props{ "label": "Open...", "desc": "open from TOML formatted file", "icon": "file-open", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".toml", }}, }, }}, - {"OpenJSON", ki.Props{ + {"OpenJSON", tree.Props{ "label": "Open...", "desc": "open from JSON formatted file", "icon": "file-open", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".json", }}, }, }}, }}, - {"StringGoCode", ki.Props{ + {"StringGoCode", tree.Props{ "label": "Show Code", "desc": "shows the Go-formatted initializer code, can be copy / pasted into program", "icon": "go", "show-return": true, }}, - {"sep-diffs", ki.BlankProp{}}, - {"DiffsAll", ki.Props{ + {"sep-diffs", tree.BlankProp{}}, + {"DiffsAll", tree.Props{ "desc": "between all sets, reports where the same param path is being set to different values", "icon": "search", "show-return": true, }}, - {"DiffsFirst", ki.Props{ + {"DiffsFirst", tree.Props{ "desc": "between first set (e.g., the Base set) and rest of sets, reports where the same param path is being set to different values", "icon": "search", "show-return": true, }}, - {"DiffsWithin", ki.Props{ + {"DiffsWithin", tree.Props{ "desc": "reports all the cases where the same param path is being set to different values within different sheets in given set", "icon": "search", "show-return": true, - "Args": ki.PropSlice{ - {"Set Name", ki.Props{}}, + "Args": tree.PropSlice{ + {"Set Name", tree.Props{}}, }, }}, }, diff --git a/netview/events.go b/netview/events.go index 5b0cbc4..07984e6 100644 --- a/netview/events.go +++ b/netview/events.go @@ -7,10 +7,10 @@ package netview import ( "fmt" + "cogentcore.org/core/core" "cogentcore.org/core/events" - "cogentcore.org/core/gi" - "cogentcore.org/core/giv" "cogentcore.org/core/math32" + "cogentcore.org/core/views" "cogentcore.org/core/xyz" "cogentcore.org/core/xyzv" "github.com/emer/emergent/v2/emer" @@ -60,7 +60,7 @@ func (sw *Scene) MouseDownEvent(e events.Event) { if ok { lay := ln.NetView.Net.LayerByName(ln.Text) if lay != nil { - giv.StructViewDialog(sw, lay, "Layer: "+lay.Name(), true) + views.StructViewDialog(sw, lay, "Layer: "+lay.Name(), true) } e.SetHandled() return @@ -108,7 +108,7 @@ func (sw *Scene) LongHoverEvent(e events.Event) { } else { return // not supported } - gi.NewTooltipTextAt(sw, sval, e.WindowPos(), lay.Size().ToPoint()).Run() + core.NewTooltipTextAt(sw, sval, e.WindowPos(), lay.Size().ToPoint()).Run() e.SetHandled() } @@ -128,7 +128,7 @@ func (sw *Scene) LayerUnitAtPoint(e events.Event) (lay emer.Layer, lx, ly, unInd poff.Y = -0.5 for li, lgi := range *laysGp.Children() { lay = nv.Net.Layer(li) - lg := lgi.(*xyz.Group) + lg := lcore.(*xyz.Group) lp := lay.Pos() lp.Y = -lp.Y // reverse direction lp = lp.Sub(nmin).Mul(nsc).Sub(poff) diff --git a/netview/gtigen.go b/netview/gtigen.go index d76474c..0762212 100644 --- a/netview/gtigen.go +++ b/netview/gtigen.go @@ -6,9 +6,8 @@ import ( "sync" "cogentcore.org/core/colors/colormap" - "cogentcore.org/core/giv" "cogentcore.org/core/gti" - "cogentcore.org/core/ki" + "cogentcore.org/core/views" "cogentcore.org/core/xyz" "cogentcore.org/core/xyzv" ) @@ -22,7 +21,7 @@ var SceneType = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/netview // NewScene adds a new [Scene] with the given name to the given parent: // Scene is a Widget for managing the 3D Scene of the NetView -func NewScene(parent ki.Ki, name ...string) *Scene { +func NewScene(parent tree.Ki, name ...string) *Scene { return parent.NewChild(SceneType, name...).(*Scene) } @@ -30,7 +29,7 @@ func NewScene(parent ki.Ki, name ...string) *Scene { func (t *Scene) KiType() *gti.Type { return SceneType } // New returns a new [*Scene] value -func (t *Scene) New() ki.Ki { return &Scene{} } +func (t *Scene) New() tree.Ki { return &Scene{} } // SetNetView sets the [Scene.NetView] func (t *Scene) SetNetView(v *NetView) *Scene { t.NetView = v; return t } @@ -57,7 +56,7 @@ var LayObjType = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/netvie // NewLayObj adds a new [LayObj] with the given name to the given parent: // LayObj is the Layer 3D object within the NetView -func NewLayObj(parent ki.Ki, name ...string) *LayObj { +func NewLayObj(parent tree.Ki, name ...string) *LayObj { return parent.NewChild(LayObjType, name...).(*LayObj) } @@ -65,7 +64,7 @@ func NewLayObj(parent ki.Ki, name ...string) *LayObj { func (t *LayObj) KiType() *gti.Type { return LayObjType } // New returns a new [*LayObj] value -func (t *LayObj) New() ki.Ki { return &LayObj{} } +func (t *LayObj) New() tree.Ki { return &LayObj{} } // SetLayName sets the [LayObj.LayName]: // name of the layer we represent @@ -83,7 +82,7 @@ var LayNameType = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/netvi // NewLayName adds a new [LayName] with the given name to the given parent: // LayName is the Layer name as a Text2D within the NetView -func NewLayName(parent ki.Ki, name ...string) *LayName { +func NewLayName(parent tree.Ki, name ...string) *LayName { return parent.NewChild(LayNameType, name...).(*LayName) } @@ -91,7 +90,7 @@ func NewLayName(parent ki.Ki, name ...string) *LayName { func (t *LayName) KiType() *gti.Type { return LayNameType } // New returns a new [*LayName] value -func (t *LayName) New() ki.Ki { return &LayName{} } +func (t *LayName) New() tree.Ki { return &LayName{} } // SetNetView sets the [LayName.NetView]: // our netview @@ -106,12 +105,12 @@ func (t *LayName) SetText(v string) *LayName { t.Text = v; return t } var _ = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/netview.NetData", IDName: "net-data", Doc: "NetData maintains a record of all the network data that has been displayed\nup to a given maximum number of records (updates), using efficient ring index logic\nwith no copying to store in fixed-sized buffers.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Methods: []gti.Method{{Name: "OpenJSON", Doc: "OpenJSON opens colors from a JSON-formatted file.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Args: []string{"filename"}, Returns: []string{"error"}}, {Name: "SaveJSON", Doc: "SaveJSON saves colors to a JSON-formatted file.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Args: []string{"filename"}, Returns: []string{"error"}}}, Fields: []gti.Field{{Name: "Net", Doc: "the network that we're viewing"}, {Name: "NoSynData", Doc: "copied from Params -- do not record synapse level data -- turn this on for very large networks where recording the entire synaptic state would be prohibitive"}, {Name: "PrjnLay", Doc: "name of the layer with unit for viewing projections (connection / synapse-level values)"}, {Name: "PrjnUnIndex", Doc: "1D index of unit within PrjnLay for for viewing projections"}, {Name: "PrjnType", Doc: "copied from NetView Params: if non-empty, this is the type projection to show when there are multiple projections from the same layer -- e.g., Inhib, Lateral, Forward, etc"}, {Name: "UnVars", Doc: "the list of unit variables saved"}, {Name: "UnVarIndexes", Doc: "index of each variable in the Vars slice"}, {Name: "SynVars", Doc: "the list of synaptic variables saved"}, {Name: "SynVarIndexes", Doc: "index of synaptic variable in the SynVars slice"}, {Name: "Ring", Doc: "the circular ring index -- Max here is max number of values to store, Len is number stored, and Index(Len-1) is the most recent one, etc"}, {Name: "MaxData", Doc: "max data parallel data per unit"}, {Name: "LayData", Doc: "the layer data -- map keyed by layer name"}, {Name: "UnMinPer", Doc: "unit var min values for each Ring.Max * variable"}, {Name: "UnMaxPer", Doc: "unit var max values for each Ring.Max * variable"}, {Name: "UnMinVar", Doc: "min values for unit variables"}, {Name: "UnMaxVar", Doc: "max values for unit variables"}, {Name: "SynMinVar", Doc: "min values for syn variables"}, {Name: "SynMaxVar", Doc: "max values for syn variables"}, {Name: "Counters", Doc: "counter strings"}, {Name: "RasterCtrs", Doc: "raster counter values"}, {Name: "RasterMap", Doc: "map of raster counter values to record numbers"}, {Name: "RastCtr", Doc: "dummy raster counter when passed a -1 -- increments and wraps around"}}}) // NetViewType is the [gti.Type] for [NetView] -var NetViewType = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/netview.NetView", IDName: "net-view", Doc: "NetView is a Cogent Core Widget that provides a 3D network view using the Cogent Core gi3d\n3D framework.", Methods: []gti.Method{{Name: "PlotSelectedUnit", Doc: "PlotSelectedUnit opens a window with a plot of all the data for the\ncurrently-selected unit.\nUseful for replaying detailed trace for units of interest.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Returns: []string{"Table", "Plot2D"}}, {Name: "Current", Doc: "Current records the current state of the network, including synaptic values,\nand updates the display. Use this when switching to NetView tab after network\nhas been running while viewing another tab, because the network state\nis typically not recored then.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}}, {Name: "SaveWeights", Doc: "SaveWeights saves the network weights -- when called with giv.CallMethod\nit will auto-prompt for filename", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Args: []string{"filename"}}, {Name: "OpenWeights", Doc: "OpenWeights opens the network weights -- when called with giv.CallMethod\nit will auto-prompt for filename", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Args: []string{"filename"}}, {Name: "ShowNonDefaultParams", Doc: "ShowNonDefaultParams shows a dialog of all the parameters that\nare not at their default values in the network. Useful for setting params.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Returns: []string{"string"}}, {Name: "ShowAllParams", Doc: "ShowAllParams shows a dialog of all the parameters in the network.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Returns: []string{"string"}}, {Name: "ShowKeyLayerParams", Doc: "ShowKeyLayerParams shows a dialog with a listing for all layers in the network,\nof the most important layer-level params (specific to each algorithm)", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Returns: []string{"string"}}, {Name: "ShowKeyPrjnParams", Doc: "ShowKeyPrjnParams shows a dialog with a listing for all Recv projections in the network,\nof the most important projection-level params (specific to each algorithm)", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Returns: []string{"string"}}}, Embeds: []gti.Field{{Name: "Layout"}}, Fields: []gti.Field{{Name: "Net", Doc: "the network that we're viewing"}, {Name: "Var", Doc: "current variable that we're viewing"}, {Name: "Di", Doc: "current data parallel index di, for networks capable of processing input patterns in parallel."}, {Name: "Vars", Doc: "the list of variables to view"}, {Name: "SynVars", Doc: "list of synaptic variables"}, {Name: "SynVarsMap", Doc: "map of synaptic variable names to index"}, {Name: "VarParams", Doc: "parameters for the list of variables to view"}, {Name: "CurVarParams", Doc: "current var params -- only valid during Update of display"}, {Name: "Params", Doc: "parameters controlling how the view is rendered"}, {Name: "ColorMap", Doc: "color map for mapping values to colors -- set by name in Params"}, {Name: "ColorMapVal", Doc: "color map value representing ColorMap"}, {Name: "RecNo", Doc: "record number to display -- use -1 to always track latest, otherwise in range"}, {Name: "LastCtrs", Doc: "last non-empty counters string provided -- re-used if no new one"}, {Name: "Data", Doc: "contains all the network data with history"}, {Name: "DataMu", Doc: "mutex on data access"}}, Instance: &NetView{}}) +var NetViewType = gti.AddType(>i.Type{Name: "github.com/emer/emergent/v2/netview.NetView", IDName: "net-view", Doc: "NetView is a Cogent Core Widget that provides a 3D network view using the Cogent Core gi3d\n3D framework.", Methods: []gti.Method{{Name: "PlotSelectedUnit", Doc: "PlotSelectedUnit opens a window with a plot of all the data for the\ncurrently-selected unit.\nUseful for replaying detailed trace for units of interest.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Returns: []string{"Table", "Plot2D"}}, {Name: "Current", Doc: "Current records the current state of the network, including synaptic values,\nand updates the display. Use this when switching to NetView tab after network\nhas been running while viewing another tab, because the network state\nis typically not recored then.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}}, {Name: "SaveWeights", Doc: "SaveWeights saves the network weights -- when called with views.CallMethod\nit will auto-prompt for filename", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Args: []string{"filename"}}, {Name: "OpenWeights", Doc: "OpenWeights opens the network weights -- when called with views.CallMethod\nit will auto-prompt for filename", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Args: []string{"filename"}}, {Name: "ShowNonDefaultParams", Doc: "ShowNonDefaultParams shows a dialog of all the parameters that\nare not at their default values in the network. Useful for setting params.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Returns: []string{"string"}}, {Name: "ShowAllParams", Doc: "ShowAllParams shows a dialog of all the parameters in the network.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Returns: []string{"string"}}, {Name: "ShowKeyLayerParams", Doc: "ShowKeyLayerParams shows a dialog with a listing for all layers in the network,\nof the most important layer-level params (specific to each algorithm)", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Returns: []string{"string"}}, {Name: "ShowKeyPrjnParams", Doc: "ShowKeyPrjnParams shows a dialog with a listing for all Recv projections in the network,\nof the most important projection-level params (specific to each algorithm)", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Returns: []string{"string"}}}, Embeds: []gti.Field{{Name: "Layout"}}, Fields: []gti.Field{{Name: "Net", Doc: "the network that we're viewing"}, {Name: "Var", Doc: "current variable that we're viewing"}, {Name: "Di", Doc: "current data parallel index di, for networks capable of processing input patterns in parallel."}, {Name: "Vars", Doc: "the list of variables to view"}, {Name: "SynVars", Doc: "list of synaptic variables"}, {Name: "SynVarsMap", Doc: "map of synaptic variable names to index"}, {Name: "VarParams", Doc: "parameters for the list of variables to view"}, {Name: "CurVarParams", Doc: "current var params -- only valid during Update of display"}, {Name: "Params", Doc: "parameters controlling how the view is rendered"}, {Name: "ColorMap", Doc: "color map for mapping values to colors -- set by name in Params"}, {Name: "ColorMapVal", Doc: "color map value representing ColorMap"}, {Name: "RecNo", Doc: "record number to display -- use -1 to always track latest, otherwise in range"}, {Name: "LastCtrs", Doc: "last non-empty counters string provided -- re-used if no new one"}, {Name: "Data", Doc: "contains all the network data with history"}, {Name: "DataMu", Doc: "mutex on data access"}}, Instance: &NetView{}}) // NewNetView adds a new [NetView] with the given name to the given parent: // NetView is a Cogent Core Widget that provides a 3D network view using the Cogent Core gi3d // 3D framework. -func NewNetView(parent ki.Ki, name ...string) *NetView { +func NewNetView(parent tree.Ki, name ...string) *NetView { return parent.NewChild(NetViewType, name...).(*NetView) } @@ -119,7 +118,7 @@ func NewNetView(parent ki.Ki, name ...string) *NetView { func (t *NetView) KiType() *gti.Type { return NetViewType } // New returns a new [*NetView] value -func (t *NetView) New() ki.Ki { return &NetView{} } +func (t *NetView) New() tree.Ki { return &NetView{} } // SetDi sets the [NetView.Di]: // current data parallel index di, for networks capable of processing input patterns in parallel. @@ -155,7 +154,7 @@ func (t *NetView) SetColorMap(v *colormap.Map) *NetView { t.ColorMap = v; return // SetColorMapVal sets the [NetView.ColorMapVal]: // color map value representing ColorMap -func (t *NetView) SetColorMapVal(v *giv.ColorMapValue) *NetView { t.ColorMapVal = v; return t } +func (t *NetView) SetColorMapVal(v *views.ColorMapValue) *NetView { t.ColorMapVal = v; return t } // SetRecNo sets the [NetView.RecNo]: // record number to display -- use -1 to always track latest, otherwise in range diff --git a/netview/netdata.go b/netview/netdata.go index c043ac4..8d3ef62 100644 --- a/netview/netdata.go +++ b/netview/netdata.go @@ -17,7 +17,7 @@ import ( "strconv" "strings" - "cogentcore.org/core/gi" + "cogentcore.org/core/core" "cogentcore.org/core/math32" "github.com/emer/emergent/v2/emer" "github.com/emer/emergent/v2/ringidx" @@ -536,7 +536,7 @@ func (nd *NetData) SendUnitValue(laynm string, vnm string, uidx1d int) (float32, // IO // OpenJSON opens colors from a JSON-formatted file. -func (nd *NetData) OpenJSON(filename gi.Filename) error { //gti:add +func (nd *NetData) OpenJSON(filename core.Filename) error { //gti:add fp, err := os.Open(string(filename)) defer fp.Close() if err != nil { @@ -558,7 +558,7 @@ func (nd *NetData) OpenJSON(filename gi.Filename) error { //gti:add } // SaveJSON saves colors to a JSON-formatted file. -func (nd *NetData) SaveJSON(filename gi.Filename) error { //gti:add +func (nd *NetData) SaveJSON(filename core.Filename) error { //gti:add fp, err := os.Create(string(filename)) defer fp.Close() if err != nil { @@ -634,7 +634,7 @@ func (nv *NetView) PlotSelectedUnit() (*etable.Table, *eplot.Plot2D) { //gti:add selnm := nd.PrjnLay + fmt.Sprintf("[%d]", nd.PrjnUnIndex) - b := gi.NewBody("netview-selectedunit").SetTitle("NetView SelectedUnit Plot: " + selnm) + b := core.NewBody("netview-selectedunit").SetTitle("NetView SelectedUnit Plot: " + selnm) plt := eplot.NewPlot2D(b) plt.Params.Title = "NetView " + selnm plt.Params.XAxisCol = "Rec" @@ -709,22 +709,22 @@ func (nd *NetData) SelectedUnitTable(di int) *etable.Table { } /* -var NetDataProps = ki.Props{ - "CallMethods": ki.PropSlice{ - {"SaveJSON", ki.Props{ +var NetDataProps = tree.Props{ + "CallMethods": tree.PropSlice{ + {"SaveJSON", tree.Props{ "desc": "save recorded network view data to file", "icon": "file-save", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".netdat,.netdat.gz", }}, }, }}, - {"OpenJSON", ki.Props{ + {"OpenJSON", tree.Props{ "desc": "open recorded network view data from file", "icon": "file-open", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".netdat,.netdat.gz", }}, }, diff --git a/netview/netview.go b/netview/netview.go index a24aedf..e0d62fd 100644 --- a/netview/netview.go +++ b/netview/netview.go @@ -20,15 +20,15 @@ import ( "cogentcore.org/core/abilities" "cogentcore.org/core/colors" "cogentcore.org/core/colors/colormap" + "cogentcore.org/core/core" "cogentcore.org/core/events" "cogentcore.org/core/events/key" - "cogentcore.org/core/gi" - "cogentcore.org/core/giv" "cogentcore.org/core/icons" - "cogentcore.org/core/ki" "cogentcore.org/core/math32" "cogentcore.org/core/styles" "cogentcore.org/core/texteditor" + "cogentcore.org/core/tree" + "cogentcore.org/core/views" "cogentcore.org/core/xyz" "github.com/emer/emergent/v2/emer" "github.com/emer/etable/v2/minmax" @@ -37,7 +37,7 @@ import ( // NetView is a Cogent Core Widget that provides a 3D network view using the Cogent Core gi3d // 3D framework. type NetView struct { - gi.Layout + core.Layout // the network that we're viewing Net emer.Network `set:"-"` @@ -70,7 +70,7 @@ type NetView struct { ColorMap *colormap.Map // color map value representing ColorMap - ColorMapVal *giv.ColorMapValue + ColorMapVal *views.ColorMapValue // record number to display -- use -1 to always track latest, otherwise in range RecNo int @@ -274,16 +274,16 @@ func (nv *NetView) ConfigNetView() { log.Printf("NetView: %v ColorMap named: %v not found in colormap.AvailMaps\n", nv.Nm, nv.Params.ColorMap) } if !nv.HasChildren() { - tb := gi.NewToolbar(nv, "tbar") - nlay := gi.NewLayout(nv, "net") + tb := core.NewToolbar(nv, "tbar") + nlay := core.NewLayout(nv, "net") nlay.Style(func(s *styles.Style) { s.Direction = styles.Row s.Grow.Set(1, 1) }) - gi.NewLabel(nv, "counters").SetText(strings.Repeat(" ", 200)) - vb := gi.NewToolbar(nv, "vbar") + core.NewLabel(nv, "counters").SetText(strings.Repeat(" ", 200)) + vb := core.NewToolbar(nv, "vbar") - vlay := gi.NewFrame(nlay, "vars") + vlay := core.NewFrame(nlay, "vars") vlay.Style(func(s *styles.Style) { s.Display = styles.Grid s.Columns = nv.Params.NVarCols @@ -320,20 +320,20 @@ func (nv *NetView) ReconfigMeshes() { } } -func (nv *NetView) Toolbar() *gi.Toolbar { - return nv.ChildByName("tbar", 0).(*gi.Toolbar) +func (nv *NetView) Toolbar() *core.Toolbar { + return nv.ChildByName("tbar", 0).(*core.Toolbar) } -func (nv *NetView) NetLay() *gi.Layout { - return nv.ChildByName("net", 1).(*gi.Layout) +func (nv *NetView) NetLay() *core.Layout { + return nv.ChildByName("net", 1).(*core.Layout) } -func (nv *NetView) Counters() *gi.Label { - return nv.ChildByName("counters", 2).(*gi.Label) +func (nv *NetView) Counters() *core.Label { + return nv.ChildByName("counters", 2).(*core.Label) } -func (nv *NetView) Viewbar() *gi.Toolbar { - return nv.ChildByName("vbar", 3).(*gi.Toolbar) +func (nv *NetView) Viewbar() *core.Toolbar { + return nv.ChildByName("vbar", 3).(*core.Toolbar) } func (nv *NetView) SceneWidget() *Scene { @@ -345,8 +345,8 @@ func (nv *NetView) SceneXYZ() *xyz.Scene { } -func (nv *NetView) VarsLay() *gi.Frame { - return nv.NetLay().ChildByName("vars", 0).(*gi.Frame) +func (nv *NetView) VarsLay() *core.Frame { + return nv.NetLay().ChildByName("vars", 0).(*core.Frame) } // SetCounters sets the counters widget view display at bottom of netview @@ -360,7 +360,7 @@ func (nv *NetView) SetCounters(ctrs string) { // UpdateRecNo updates the record number viewing func (nv *NetView) UpdateRecNo() { vbar := nv.Viewbar() - rlbl := vbar.ChildByName("rec", 10).(*gi.Label) + rlbl := vbar.ChildByName("rec", 10).(*core.Label) rlbl.SetText(fmt.Sprintf("%4d ", nv.RecNo)).Update() } @@ -511,7 +511,7 @@ func (nv *NetView) VarsListUpdate() { func (nv *NetView) VarsUpdate() { vl := nv.VarsLay() for _, vbi := range *vl.Children() { - vb := vbi.(*gi.Button) + vb := vbi.(*core.Button) vb.SetSelected(vb.Text == nv.Var) } nv.ColorMapVal.Update() @@ -528,7 +528,7 @@ func (nv *NetView) VarScaleUpdate(varNm string) bool { mod := false if ci := tb.ChildByName("mnsw", 4); ci != nil { - sw := ci.(*gi.Switch) + sw := ci.(*core.Switch) if sw.IsChecked() != vp.Range.FixMin { mod = true sw.SetChecked(vp.Range.FixMin) @@ -536,7 +536,7 @@ func (nv *NetView) VarScaleUpdate(varNm string) bool { } } if ci := tb.ChildByName("mxsw", 6); ci != nil { - sw := ci.(*gi.Switch) + sw := ci.(*core.Switch) if sw.IsChecked() != vp.Range.FixMax { mod = true sw.SetChecked(vp.Range.FixMax) @@ -544,7 +544,7 @@ func (nv *NetView) VarScaleUpdate(varNm string) bool { } } if ci := tb.ChildByName("mnsp", 5); ci != nil { - sp := ci.(*gi.Spinner) + sp := ci.(*core.Spinner) mnv := vp.Range.Min if sp.Value != mnv { mod = true @@ -553,7 +553,7 @@ func (nv *NetView) VarScaleUpdate(varNm string) bool { } } if ci := tb.ChildByName("mxsp", 7); ci != nil { - sp := ci.(*gi.Spinner) + sp := ci.(*core.Spinner) mxv := vp.Range.Max if sp.Value != mxv { mod = true @@ -562,7 +562,7 @@ func (nv *NetView) VarScaleUpdate(varNm string) bool { } } if ci := tb.ChildByName("zcsw", 8); ci != nil { - sw := ci.(*gi.Switch) + sw := ci.(*core.Switch) if sw.IsChecked() != vp.ZeroCtr { mod = true sw.SetChecked(vp.ZeroCtr) @@ -587,7 +587,7 @@ func (nv *NetView) VarsConfig() { prjnprops := nv.Net.SynVarProps() for _, vn := range nv.Vars { vn := vn - vb := gi.NewButton(vl).SetText(vn).SetType(gi.ButtonAction) + vb := core.NewButton(vl).SetText(vn).SetType(core.ButtonAction) pstr := "" if strings.HasPrefix(vn, "r.") || strings.HasPrefix(vn, "s.") { pstr = prjnprops[vn[2:]] @@ -621,13 +621,13 @@ func (nv *NetView) ViewConfig() { nv.ViewDefaults() } // todo: - // vs.BgColor = gi.Prefs.Colors.Background // reset in case user changes + // vs.BgColor = core.Prefs.Colors.Background // reset in case user changes nlay := nv.Net.NLayers() laysGp := se.ChildByName("Layers", 0) if laysGp == nil { laysGp = xyz.NewGroup(se, "Layers") } - layConfig := ki.Config{} + layConfig := tree.Config{} for li := 0; li < nlay; li++ { lay := nv.Net.Layer(li) lmesh := se.MeshByName(lay.Name()) @@ -638,7 +638,7 @@ func (nv *NetView) ViewConfig() { } layConfig.Add(xyz.GroupType, lay.Name()) } - gpConfig := ki.Config{} + gpConfig := tree.Config{} gpConfig.Add(LayObjType, "layer") gpConfig.Add(LayNameType, "name") @@ -652,7 +652,7 @@ func (nv *NetView) ViewConfig() { poff.Y = -0.5 for li, lgi := range *laysGp.Children() { ly := nv.Net.Layer(li) - lg := lgi.(*xyz.Group) + lg := lcore.(*xyz.Group) lg.ConfigChildren(gpConfig) // won't do update b/c of above lp := ly.Pos() lp.Y = -lp.Y // reverse direction @@ -696,7 +696,7 @@ func (nv *NetView) ViewDefaults() { se.Camera.Near = 0.1 se.Camera.LookAt(math32.V3(0, 0, 0), math32.V3(0, 1, 0)) // todo: - // vs.BgColor = gi.Prefs.Colors.Background + // vs.BgColor = core.Prefs.Colors.Background xyz.NewAmbientLight(se, "ambient", 0.1, xyz.DirectSun) dir := xyz.NewDirLight(se, "dirUp", 0.3, xyz.DirectSun) dir.Pos.Set(0, 1, 0) @@ -805,7 +805,7 @@ func (nv *NetView) ConfigLabels(labs []string) bool { lgp = xyz.NewGroup(se, "Labels") } - lbConfig := ki.Config{} + lbConfig := tree.Config{} for _, ls := range labs { lbConfig.Add(xyz.Text2DType, ls) } @@ -854,37 +854,37 @@ func (nv *NetView) LayerByName(lay string) *xyz.Group { return ly.(*xyz.Group) } -func (nv *NetView) ConfigToolbar(tb *gi.Toolbar) { - giv.NewFuncButton(tb, nv.Update).SetText("Init").SetIcon(icons.Update) - giv.NewFuncButton(tb, nv.Current).SetIcon(icons.Update) - gi.NewButton(tb).SetText("Config").SetIcon(icons.Settings). +func (nv *NetView) ConfigToolbar(tb *core.Toolbar) { + views.NewFuncButton(tb, nv.Update).SetText("Init").SetIcon(icons.Update) + views.NewFuncButton(tb, nv.Current).SetIcon(icons.Update) + core.NewButton(tb).SetText("Config").SetIcon(icons.Settings). SetTooltip("set parameters that control display (font size etc)"). OnClick(func(e events.Event) { - giv.StructViewDialog(nv, &nv.Params, nv.Nm+" Params", true) + views.StructViewDialog(nv, &nv.Params, nv.Nm+" Params", true) }) - gi.NewSeparator(tb) - gi.NewButton(tb).SetText("Weights").SetType(gi.ButtonAction).SetMenu(func(m *gi.Scene) { - fb := giv.NewFuncButton(m, nv.SaveWeights).SetIcon(icons.Save) + core.NewSeparator(tb) + core.NewButton(tb).SetText("Weights").SetType(core.ButtonAction).SetMenu(func(m *core.Scene) { + fb := views.NewFuncButton(m, nv.SaveWeights).SetIcon(icons.Save) fb.Args[0].SetTag("ext", ".wts,.wts.gz") - fb = giv.NewFuncButton(m, nv.OpenWeights).SetIcon(icons.Open) + fb = views.NewFuncButton(m, nv.OpenWeights).SetIcon(icons.Open) fb.Args[0].SetTag("ext", ".wts,.wts.gz") }) - gi.NewButton(tb).SetText("Params").SetIcon(icons.Info).SetMenu(func(m *gi.Scene) { - giv.NewFuncButton(m, nv.ShowNonDefaultParams).SetIcon(icons.Info) - giv.NewFuncButton(m, nv.ShowAllParams).SetIcon(icons.Info) - giv.NewFuncButton(m, nv.ShowKeyLayerParams).SetIcon(icons.Info) - giv.NewFuncButton(m, nv.ShowKeyPrjnParams).SetIcon(icons.Info) + core.NewButton(tb).SetText("Params").SetIcon(icons.Info).SetMenu(func(m *core.Scene) { + views.NewFuncButton(m, nv.ShowNonDefaultParams).SetIcon(icons.Info) + views.NewFuncButton(m, nv.ShowAllParams).SetIcon(icons.Info) + views.NewFuncButton(m, nv.ShowKeyLayerParams).SetIcon(icons.Info) + views.NewFuncButton(m, nv.ShowKeyPrjnParams).SetIcon(icons.Info) }) - gi.NewButton(tb).SetText("Net Data").SetIcon(icons.Save).SetMenu(func(m *gi.Scene) { - giv.NewFuncButton(m, nv.Data.SaveJSON).SetText("Save Net Data").SetIcon(icons.Save) - giv.NewFuncButton(m, nv.Data.OpenJSON).SetText("Open Net Data").SetIcon(icons.Open) - gi.NewSeparator(m) - giv.NewFuncButton(m, nv.PlotSelectedUnit).SetIcon(icons.Open) + core.NewButton(tb).SetText("Net Data").SetIcon(icons.Save).SetMenu(func(m *core.Scene) { + views.NewFuncButton(m, nv.Data.SaveJSON).SetText("Save Net Data").SetIcon(icons.Save) + views.NewFuncButton(m, nv.Data.OpenJSON).SetText("Open Net Data").SetIcon(icons.Open) + core.NewSeparator(m) + views.NewFuncButton(m, nv.PlotSelectedUnit).SetIcon(icons.Open) }) - gi.NewSeparator(tb) + core.NewSeparator(tb) ditp := "data parallel index -- for models running multiple input patterns in parallel, this selects which one is viewed" - gi.NewLabel(tb).SetText("Di:").SetTooltip(ditp) - dis := gi.NewSpinner(tb).SetTooltip(ditp).SetMin(0).SetStep(1).SetValue(float32(nv.Di)) + core.NewLabel(tb).SetText("Di:").SetTooltip(ditp) + dis := core.NewSpinner(tb).SetTooltip(ditp).SetMin(0).SetStep(1).SetValue(float32(nv.Di)) dis.OnChange(func(e events.Event) { maxData := nv.Net.MaxParallelData() md := int(dis.Value) @@ -894,8 +894,8 @@ func (nv *NetView) ConfigToolbar(tb *gi.Toolbar) { dis.SetValue(float32(nv.Di)) nv.UpdateView() }) - gi.NewSeparator(tb) - rchk := gi.NewSwitch(tb).SetText("Raster"). + core.NewSeparator(tb) + rchk := core.NewSwitch(tb).SetText("Raster"). SetTooltip("Toggles raster plot mode -- displays values on one axis (Z by default) and raster counter (time) along the other (X by default)"). SetChecked(nv.Params.Raster.On) rchk.OnChange(func(e events.Event) { @@ -903,7 +903,7 @@ func (nv *NetView) ConfigToolbar(tb *gi.Toolbar) { nv.ReconfigMeshes() nv.UpdateView() }) - xchk := gi.NewSwitch(tb).SetText("X").SetType(gi.SwitchCheckbox). + xchk := core.NewSwitch(tb).SetText("X").SetType(core.SwitchCheckbox). SetTooltip("If checked, the raster (time) dimension is plotted along the X (horizontal) axis of the layers, otherwise it goes in the depth (Z) dimension"). SetChecked(nv.Params.Raster.XAxis) xchk.OnChange(func(e events.Event) { @@ -917,8 +917,8 @@ func (nv *NetView) ConfigToolbar(tb *gi.Toolbar) { vp.Defaults() } - gi.NewSeparator(tb) - mnsw := gi.NewSwitch(tb, "mnsw").SetText("Min").SetType(gi.SwitchCheckbox). + core.NewSeparator(tb) + mnsw := core.NewSwitch(tb, "mnsw").SetText("Min").SetType(core.SwitchCheckbox). SetTooltip("Fix the minimum end of the displayed value range to value shown in next box. Having both min and max fixed is recommended where possible for speed and consistent interpretability of the colors."). SetChecked(vp.Range.FixMin) mnsw.OnChange(func(e events.Event) { @@ -927,7 +927,7 @@ func (nv *NetView) ConfigToolbar(tb *gi.Toolbar) { nv.VarScaleUpdate(nv.Var) // todo: before update? nv.UpdateView() }) - mnsp := gi.NewSpinner(tb, "mnsp").SetValue(vp.Range.Min) + mnsp := core.NewSpinner(tb, "mnsp").SetValue(vp.Range.Min) mnsp.OnChange(func(e events.Event) { vp := nv.VarParams[nv.Var] vp.Range.SetMin(mnsp.Value) @@ -938,7 +938,7 @@ func (nv *NetView) ConfigToolbar(tb *gi.Toolbar) { nv.UpdateView() }) - nv.ColorMapVal = giv.NewValue(tb, &nv.Params.ColorMap, "cmap").(*giv.ColorMapValue) + nv.ColorMapVal = views.NewValue(tb, &nv.Params.ColorMap, "cmap").(*views.ColorMapValue) cmap := nv.ColorMapVal.AsWidget() cmap.AsWidget().SetTooltip("Color map for translating values into colors -- click to select alternative."). Style(func(s *styles.Style) { @@ -954,7 +954,7 @@ func (nv *NetView) ConfigToolbar(tb *gi.Toolbar) { nv.UpdateView() }) - mxsw := gi.NewSwitch(tb, "mxsw").SetText("Max").SetType(gi.SwitchCheckbox). + mxsw := core.NewSwitch(tb, "mxsw").SetText("Max").SetType(core.SwitchCheckbox). SetTooltip("Fix the maximum end of the displayed value range to value shown in next box. Having both min and max fixed is recommended where possible for speed and consistent interpretability of the colors."). SetChecked(vp.Range.FixMax) mxsw.OnChange(func(e events.Event) { @@ -963,7 +963,7 @@ func (nv *NetView) ConfigToolbar(tb *gi.Toolbar) { nv.VarScaleUpdate(nv.Var) nv.UpdateView() }) - mxsp := gi.NewSpinner(tb, "mxsp").SetValue(vp.Range.Max) + mxsp := core.NewSpinner(tb, "mxsp").SetValue(vp.Range.Max) mxsp.OnChange(func(e events.Event) { vp := nv.VarParams[nv.Var] vp.Range.SetMax(mxsp.Value) @@ -973,7 +973,7 @@ func (nv *NetView) ConfigToolbar(tb *gi.Toolbar) { nv.VarScaleUpdate(nv.Var) nv.UpdateView() }) - zcsw := gi.NewSwitch(tb, "zcsw").SetText("ZeroCtr"). + zcsw := core.NewSwitch(tb, "zcsw").SetText("ZeroCtr"). SetTooltip("keep Min - Max centered around 0, and use negative heights for units -- else use full min-max range for height (no negative heights)"). SetChecked(vp.ZeroCtr) zcsw.OnChange(func(e events.Event) { @@ -984,13 +984,13 @@ func (nv *NetView) ConfigToolbar(tb *gi.Toolbar) { }) } -func (nv *NetView) ConfigViewbar(tb *gi.Toolbar) { - gi.NewButton(tb).SetIcon(icons.Update).SetTooltip("reset to default initial display"). +func (nv *NetView) ConfigViewbar(tb *core.Toolbar) { + core.NewButton(tb).SetIcon(icons.Update).SetTooltip("reset to default initial display"). OnClick(func(e events.Event) { nv.SceneXYZ().SetCamera("default") nv.UpdateView() }) - gi.NewButton(tb).SetIcon(icons.ZoomIn).SetTooltip("zoom in"). + core.NewButton(tb).SetIcon(icons.ZoomIn).SetTooltip("zoom in"). Style(func(s *styles.Style) { s.SetAbilities(true, abilities.RepeatClickable) }). @@ -998,7 +998,7 @@ func (nv *NetView) ConfigViewbar(tb *gi.Toolbar) { nv.SceneXYZ().Camera.Zoom(-.05) nv.UpdateView() }) - gi.NewButton(tb).SetIcon(icons.ZoomOut).SetTooltip("zoom out"). + core.NewButton(tb).SetIcon(icons.ZoomOut).SetTooltip("zoom out"). Style(func(s *styles.Style) { s.SetAbilities(true, abilities.RepeatClickable) }). @@ -1006,9 +1006,9 @@ func (nv *NetView) ConfigViewbar(tb *gi.Toolbar) { nv.SceneXYZ().Camera.Zoom(.05) nv.UpdateView() }) - gi.NewSeparator(tb) - gi.NewLabel(tb).SetText("Rot:").SetTooltip("rotate display") - gi.NewButton(tb).SetIcon(icons.KeyboardArrowLeft). + core.NewSeparator(tb) + core.NewLabel(tb).SetText("Rot:").SetTooltip("rotate display") + core.NewButton(tb).SetIcon(icons.KeyboardArrowLeft). Style(func(s *styles.Style) { s.SetAbilities(true, abilities.RepeatClickable) }). @@ -1016,7 +1016,7 @@ func (nv *NetView) ConfigViewbar(tb *gi.Toolbar) { nv.SceneXYZ().Camera.Orbit(5, 0) nv.UpdateView() }) - gi.NewButton(tb).SetIcon(icons.KeyboardArrowUp). + core.NewButton(tb).SetIcon(icons.KeyboardArrowUp). Style(func(s *styles.Style) { s.SetAbilities(true, abilities.RepeatClickable) }). @@ -1024,7 +1024,7 @@ func (nv *NetView) ConfigViewbar(tb *gi.Toolbar) { nv.SceneXYZ().Camera.Orbit(0, 5) nv.UpdateView() }) - gi.NewButton(tb).SetIcon(icons.KeyboardArrowDown). + core.NewButton(tb).SetIcon(icons.KeyboardArrowDown). Style(func(s *styles.Style) { s.SetAbilities(true, abilities.RepeatClickable) }). @@ -1032,7 +1032,7 @@ func (nv *NetView) ConfigViewbar(tb *gi.Toolbar) { nv.SceneXYZ().Camera.Orbit(0, -5) nv.UpdateView() }) - gi.NewButton(tb).SetIcon(icons.KeyboardArrowRight). + core.NewButton(tb).SetIcon(icons.KeyboardArrowRight). Style(func(s *styles.Style) { s.SetAbilities(true, abilities.RepeatClickable) }). @@ -1040,10 +1040,10 @@ func (nv *NetView) ConfigViewbar(tb *gi.Toolbar) { nv.SceneXYZ().Camera.Orbit(-5, 0) nv.UpdateView() }) - gi.NewSeparator(tb) + core.NewSeparator(tb) - gi.NewLabel(tb).SetText("Pan:").SetTooltip("pan display") - gi.NewButton(tb).SetIcon(icons.KeyboardArrowLeft). + core.NewLabel(tb).SetText("Pan:").SetTooltip("pan display") + core.NewButton(tb).SetIcon(icons.KeyboardArrowLeft). Style(func(s *styles.Style) { s.SetAbilities(true, abilities.RepeatClickable) }). @@ -1051,7 +1051,7 @@ func (nv *NetView) ConfigViewbar(tb *gi.Toolbar) { nv.SceneXYZ().Camera.Pan(-.2, 0) nv.UpdateView() }) - gi.NewButton(tb).SetIcon(icons.KeyboardArrowUp). + core.NewButton(tb).SetIcon(icons.KeyboardArrowUp). Style(func(s *styles.Style) { s.SetAbilities(true, abilities.RepeatClickable) }). @@ -1059,7 +1059,7 @@ func (nv *NetView) ConfigViewbar(tb *gi.Toolbar) { nv.SceneXYZ().Camera.Pan(0, .2) nv.UpdateView() }) - gi.NewButton(tb).SetIcon(icons.KeyboardArrowDown). + core.NewButton(tb).SetIcon(icons.KeyboardArrowDown). Style(func(s *styles.Style) { s.SetAbilities(true, abilities.RepeatClickable) }). @@ -1067,7 +1067,7 @@ func (nv *NetView) ConfigViewbar(tb *gi.Toolbar) { nv.SceneXYZ().Camera.Pan(0, -.2) nv.UpdateView() }) - gi.NewButton(tb).SetIcon(icons.KeyboardArrowRight). + core.NewButton(tb).SetIcon(icons.KeyboardArrowRight). Style(func(s *styles.Style) { s.SetAbilities(true, abilities.RepeatClickable) }). @@ -1075,13 +1075,13 @@ func (nv *NetView) ConfigViewbar(tb *gi.Toolbar) { nv.SceneXYZ().Camera.Pan(.2, 0) nv.UpdateView() }) - gi.NewSeparator(tb) + core.NewSeparator(tb) - gi.NewLabel(tb).SetText("Save:") + core.NewLabel(tb).SetText("Save:") for i := 1; i <= 4; i++ { i := i nm := fmt.Sprintf("%d", i) - gi.NewButton(tb).SetText(nm). + core.NewButton(tb).SetText(nm). SetTooltip("first click (or + Shift) saves current view, second click restores to saved state"). OnClick(func(e events.Event) { sc := nv.SceneXYZ() @@ -1098,20 +1098,20 @@ func (nv *NetView) ConfigViewbar(tb *gi.Toolbar) { nv.UpdateView() }) } - gi.NewSeparator(tb) + core.NewSeparator(tb) - gi.NewLabel(tb).SetText("Time:"). + core.NewLabel(tb).SetText("Time:"). SetTooltip("states are recorded over time -- last N can be reviewed using these buttons") - gi.NewLabel(tb, "rec").SetText(fmt.Sprintf("%4d ", nv.RecNo)). + core.NewLabel(tb, "rec").SetText(fmt.Sprintf("%4d ", nv.RecNo)). SetTooltip("current view record: -1 means latest, 0 = earliest") - gi.NewButton(tb).SetIcon(icons.FirstPage).SetTooltip("move to first record (start of history)"). + core.NewButton(tb).SetIcon(icons.FirstPage).SetTooltip("move to first record (start of history)"). OnClick(func(e events.Event) { if nv.RecFullBkwd() { nv.UpdateView() } }) - gi.NewButton(tb).SetIcon(icons.FastRewind).SetTooltip("move earlier by N records (default 10)"). + core.NewButton(tb).SetIcon(icons.FastRewind).SetTooltip("move earlier by N records (default 10)"). Style(func(s *styles.Style) { s.SetAbilities(true, abilities.RepeatClickable) }). @@ -1120,7 +1120,7 @@ func (nv *NetView) ConfigViewbar(tb *gi.Toolbar) { nv.UpdateView() } }) - gi.NewButton(tb).SetIcon(icons.SkipPrevious).SetTooltip("move earlier by 1"). + core.NewButton(tb).SetIcon(icons.SkipPrevious).SetTooltip("move earlier by 1"). Style(func(s *styles.Style) { s.SetAbilities(true, abilities.RepeatClickable) }). @@ -1129,13 +1129,13 @@ func (nv *NetView) ConfigViewbar(tb *gi.Toolbar) { nv.UpdateView() } }) - gi.NewButton(tb).SetIcon(icons.PlayArrow).SetTooltip("move to latest and always display latest (-1)"). + core.NewButton(tb).SetIcon(icons.PlayArrow).SetTooltip("move to latest and always display latest (-1)"). OnClick(func(e events.Event) { if nv.RecTrackLatest() { nv.UpdateView() } }) - gi.NewButton(tb).SetIcon(icons.SkipNext).SetTooltip("move later by 1"). + core.NewButton(tb).SetIcon(icons.SkipNext).SetTooltip("move later by 1"). Style(func(s *styles.Style) { s.SetAbilities(true, abilities.RepeatClickable) }). @@ -1144,7 +1144,7 @@ func (nv *NetView) ConfigViewbar(tb *gi.Toolbar) { nv.UpdateView() } }) - gi.NewButton(tb).SetIcon(icons.FastForward).SetTooltip("move later by N (default 10)"). + core.NewButton(tb).SetIcon(icons.FastForward).SetTooltip("move later by N (default 10)"). Style(func(s *styles.Style) { s.SetAbilities(true, abilities.RepeatClickable) }). @@ -1153,7 +1153,7 @@ func (nv *NetView) ConfigViewbar(tb *gi.Toolbar) { nv.UpdateView() } }) - gi.NewButton(tb).SetIcon(icons.LastPage).SetTooltip("move to end (current time, tracking latest updates)"). + core.NewButton(tb).SetIcon(icons.LastPage).SetTooltip("move to end (current time, tracking latest updates)"). OnClick(func(e events.Event) { if nv.RecTrackLatest() { nv.UpdateView() @@ -1161,15 +1161,15 @@ func (nv *NetView) ConfigViewbar(tb *gi.Toolbar) { }) } -// SaveWeights saves the network weights -- when called with giv.CallMethod +// SaveWeights saves the network weights -- when called with views.CallMethod // it will auto-prompt for filename -func (nv *NetView) SaveWeights(filename gi.Filename) { //gti:add +func (nv *NetView) SaveWeights(filename core.Filename) { //gti:add nv.Net.SaveWtsJSON(filename) } -// OpenWeights opens the network weights -- when called with giv.CallMethod +// OpenWeights opens the network weights -- when called with views.CallMethod // it will auto-prompt for filename -func (nv *NetView) OpenWeights(filename gi.Filename) { //gti:add +func (nv *NetView) OpenWeights(filename core.Filename) { //gti:add nv.Net.OpenWtsJSON(filename) } diff --git a/netview/params.go b/netview/params.go index c43d787..2a08a30 100644 --- a/netview/params.go +++ b/netview/params.go @@ -9,7 +9,7 @@ import ( "reflect" "strconv" - "cogentcore.org/core/giv" + "cogentcore.org/core/views" "github.com/emer/etable/v2/minmax" ) @@ -72,7 +72,7 @@ type Params struct { //gti:add LayNmSize float32 `min:"0.01" max:".1" step:"0.01" default:"0.05"` // name of color map to use - ColorMap giv.ColorMapName + ColorMap views.ColorMapName // opacity (0-1) of zero values -- greater magnitude values become increasingly opaque on either side of this minimum ZeroAlpha float32 `min:"0" max:"1" step:"0.1" default:"0.5"` @@ -102,14 +102,14 @@ func (nv *Params) Defaults() { nv.ZeroAlpha = 0.5 } if nv.ColorMap == "" { - nv.ColorMap = giv.ColorMapName("ColdHot") + nv.ColorMap = views.ColorMapName("ColdHot") } if nv.NFastSteps == 0 { nv.NFastSteps = 10 } } -// Update satisfies the gi.Updater interface and will trigger display update on edits +// Update satisfies the core.Updater interface and will trigger display update on edits func (nv *Params) Update() { if nv.NetView != nil { nv.NetView.Config() diff --git a/netview/viewupdt.go b/netview/viewupdt.go index d0ac6c6..72b6e48 100644 --- a/netview/viewupdt.go +++ b/netview/viewupdt.go @@ -7,7 +7,7 @@ package netview import ( "strings" - "cogentcore.org/core/gi" + "cogentcore.org/core/core" "github.com/emer/emergent/v2/etime" ) @@ -107,7 +107,7 @@ func (vu *ViewUpdate) UpdateWhenStopped() { if !vu.View.Params.Raster.On { // always record when not in raster mode vu.View.Record(vu.Text, -1) // -1 = use a dummy counter } - if vu.View.Scene.Is(gi.ScUpdating) { + if vu.View.Scene.Is(core.ScUpdating) { return } vu.View.GoUpdateView() diff --git a/params/apply.go b/params/apply.go index c478743..ce667a0 100644 --- a/params/apply.go +++ b/params/apply.go @@ -12,8 +12,8 @@ import ( "reflect" "strings" - "cogentcore.org/core/gi" - "cogentcore.org/core/laser" + "cogentcore.org/core/core" + "cogentcore.org/core/reflectx" ) // PathAfterType returns the portion of a path string after the initial @@ -51,7 +51,7 @@ func (pr *Params) Apply(obj any, setMsg bool) error { if styob, has := obj.(StylerObj); has { obj = styob.Object() } - } else if lblr, has := obj.(gi.Labeler); has { + } else if lblr, has := obj.(core.Labeler); has { objNm = lblr.Label() } var errs []error @@ -109,7 +109,7 @@ func (pr *Hypers) Apply(obj any, setMsg bool) error { if styob, has := obj.(StylerObj); has { obj = styob.Object() } - } else if lblr, has := obj.(gi.Labeler); has { + } else if lblr, has := obj.(core.Labeler); has { objNm = lblr.Label() } if hv, ok := obj.(Hypers); ok { @@ -175,7 +175,7 @@ func (ps *Sel) TargetTypeMatch(obj any) bool { return true } } - tnm := laser.NonPtrType(reflect.TypeOf(obj)).Name() + tnm := reflectx.NonPtrType(reflect.TypeOf(obj)).Name() return tnm == trg || tnm == trgh } @@ -188,7 +188,7 @@ func (ps *Sel) SelMatch(obj any) bool { if styob, has := obj.(StylerObj); has { obj = styob.Object() } - gotyp := laser.NonPtrType(reflect.TypeOf(obj)).Name() + gotyp := reflectx.NonPtrType(reflect.TypeOf(obj)).Name() return SelMatch(ps.Sel, stylr.Name(), stylr.Class(), stylr.TypeName(), gotyp) } @@ -285,7 +285,7 @@ func (ps *Sheet) SelNoMatchWarn(setName, objName string) error { // the target type should already have been identified and this should only // be called when there is an expectation of the path working. func FindParam(val reflect.Value, path string) (reflect.Value, error) { - npv := laser.NonPtrValue(val) + npv := reflectx.NonPtrValue(val) if npv.Kind() != reflect.Struct { if !npv.IsValid() { err := fmt.Errorf("params.FindParam: object is nil -- must Build *before* applying params! path: %v\n", path) @@ -314,7 +314,7 @@ func FindParam(val reflect.Value, path string) (reflect.Value, error) { // converts the string param val as appropriate for target type. // returns error if path not found or cannot set (always logged). func SetParam(obj any, path string, val string) error { - npv := laser.NonPtrValue(reflect.ValueOf(obj)) + npv := reflectx.NonPtrValue(reflect.ValueOf(obj)) if npv.Kind() == reflect.Map { // only for string maps npv.SetMapIndex(reflect.ValueOf(path), reflect.ValueOf(val)) return nil @@ -324,7 +324,7 @@ func SetParam(obj any, path string, val string) error { if err != nil { return err } - err = laser.SetRobust(fld.Interface(), val) + err = reflectx.SetRobust(fld.Interface(), val) if err != nil { slog.Error("params.SetParam: field could not be set", "path", path, "value", val, "err", err) return err @@ -340,7 +340,7 @@ func GetParam(obj any, path string) (float64, error) { if err != nil { return 0, err } - npf := laser.NonPtrValue(fld) + npf := reflectx.NonPtrValue(fld) switch npf.Kind() { case reflect.Float64, reflect.Float32: return npf.Float(), nil diff --git a/params/applymap.go b/params/applymap.go index 7b8808a..404a6bd 100644 --- a/params/applymap.go +++ b/params/applymap.go @@ -11,7 +11,7 @@ import ( "reflect" "strings" - "cogentcore.org/core/laser" + "cogentcore.org/core/reflectx" ) // ApplyMap applies given map[string]any values, where the map keys @@ -21,9 +21,9 @@ import ( // It always prints a message if a parameter fails to be set, and returns an error. func ApplyMap(obj any, vals map[string]any, setMsg bool) error { objv := reflect.ValueOf(obj) - npv := laser.NonPtrValue(objv) + npv := reflectx.NonPtrValue(objv) if npv.Kind() == reflect.Map { - err := laser.CopyMapRobust(obj, vals) + err := reflectx.CopyMapRobust(obj, vals) if err != nil { log.Println(err) return err @@ -38,14 +38,14 @@ func ApplyMap(obj any, vals map[string]any, setMsg bool) error { if err != nil { errs = append(errs, err) } - err = laser.SetRobust(fld.Interface(), v) + err = reflectx.SetRobust(fld.Interface(), v) if err != nil { err = fmt.Errorf("ApplyMap: was not able to apply value: %v to field: %s", v, k) log.Println(err) errs = append(errs, err) } if setMsg { - log.Printf("ApplyMap: set field: %s = %#v\n", k, laser.NonPtrValue(fld).Interface()) + log.Printf("ApplyMap: set field: %s = %#v\n", k, reflectx.NonPtrValue(fld).Interface()) } } return errors.Join(errs...) @@ -66,7 +66,7 @@ func MapToSheet(vals map[string]any) (*Sheet, error) { errs = append(errs, err) continue } - vstr := laser.ToString(v) + vstr := reflectx.ToString(v) sl := &Sel{Sel: fld[0], SetName: "ApplyMap"} sl.Params = make(Params) diff --git a/params/flex.go b/params/flex.go index a120c8b..876f7a6 100644 --- a/params/flex.go +++ b/params/flex.go @@ -11,7 +11,7 @@ import ( "io/ioutil" "log" - "cogentcore.org/core/gi" + "cogentcore.org/core/core" ) // FlexVal is a specific flexible value for the Flex parameter map @@ -149,7 +149,7 @@ func (fl *Flex) JSONString() string { } // SaveJSON saves hypers to a JSON-formatted file. -func (fl *Flex) SaveJSON(filename gi.Filename) error { +func (fl *Flex) SaveJSON(filename core.Filename) error { b, err := json.MarshalIndent(fl, "", " ") if err != nil { log.Println(err) // unlikely diff --git a/params/io.go b/params/io.go index 5a788e4..97da9b0 100644 --- a/params/io.go +++ b/params/io.go @@ -14,12 +14,12 @@ import ( "os" "sort" - "cogentcore.org/core/gi" + "cogentcore.org/core/core" "cogentcore.org/core/gox/indent" - "cogentcore.org/core/grows" - "cogentcore.org/core/grows/jsons" - "cogentcore.org/core/grows/tomls" + "cogentcore.org/core/iox/jsonx" + "cogentcore.org/core/iox/tomlx" "github.com/BurntSushi/toml" + "goki.dev/grows" "golang.org/x/exp/maps" ) @@ -33,25 +33,25 @@ func WriteGoPrelude(w io.Writer, varNm string) { } // OpenJSON opens params from a JSON-formatted file. -func (pr *Params) OpenJSON(filename gi.Filename) error { +func (pr *Params) OpenJSON(filename core.Filename) error { *pr = make(Params) // reset - return jsons.Open(pr, string(filename)) + return jsonx.Open(pr, string(filename)) } // SaveJSON saves params to a JSON-formatted file. -func (pr *Params) SaveJSON(filename gi.Filename) error { - return jsons.Save(pr, string(filename)) +func (pr *Params) SaveJSON(filename core.Filename) error { + return jsonx.Save(pr, string(filename)) } // OpenTOML opens params from a TOML-formatted file. -func (pr *Params) OpenTOML(filename gi.Filename) error { +func (pr *Params) OpenTOML(filename core.Filename) error { *pr = make(Params) // reset - return tomls.Open(pr, string(filename)) + return tomlx.Open(pr, string(filename)) } // SaveTOML saves params to a TOML-formatted file. -func (pr *Params) SaveTOML(filename gi.Filename) error { - // return tomls.Save(pr, string(filename)) // pelletier/go-toml produces bad output on maps +func (pr *Params) SaveTOML(filename core.Filename) error { + // return tomlx.Save(pr, string(filename)) // pelletier/go-toml produces bad output on maps return grows.Save(pr, string(filename), func(w io.Writer) grows.Encoder { return toml.NewEncoder(w) }) @@ -86,7 +86,7 @@ func (pr *Params) StringGoCode() []byte { } // SaveGoCode saves params to corresponding Go initializer code. -func (pr *Params) SaveGoCode(filename gi.Filename) error { +func (pr *Params) SaveGoCode(filename core.Filename) error { fp, err := os.Create(string(filename)) defer fp.Close() if err != nil { @@ -102,7 +102,7 @@ func (pr *Params) SaveGoCode(filename gi.Filename) error { // Hypers // OpenJSON opens hypers from a JSON-formatted file. -func (pr *Hypers) OpenJSON(filename gi.Filename) error { +func (pr *Hypers) OpenJSON(filename core.Filename) error { *pr = make(Hypers) // reset b, err := ioutil.ReadFile(string(filename)) if err != nil { @@ -113,19 +113,19 @@ func (pr *Hypers) OpenJSON(filename gi.Filename) error { } // SaveJSON saves hypers to a JSON-formatted file. -func (pr *Hypers) SaveJSON(filename gi.Filename) error { - return jsons.Save(pr, string(filename)) +func (pr *Hypers) SaveJSON(filename core.Filename) error { + return jsonx.Save(pr, string(filename)) } // OpenTOML opens params from a TOML-formatted file. -func (pr *Hypers) OpenTOML(filename gi.Filename) error { +func (pr *Hypers) OpenTOML(filename core.Filename) error { *pr = make(Hypers) // reset - return tomls.Open(pr, string(filename)) + return tomlx.Open(pr, string(filename)) } // SaveTOML saves params to a TOML-formatted file. -func (pr *Hypers) SaveTOML(filename gi.Filename) error { - // return tomls.Save(pr, string(filename)) +func (pr *Hypers) SaveTOML(filename core.Filename) error { + // return tomlx.Save(pr, string(filename)) return grows.Save(pr, string(filename), func(w io.Writer) grows.Encoder { return toml.NewEncoder(w) }) @@ -162,7 +162,7 @@ func (pr *Hypers) StringGoCode() []byte { } // SaveGoCode saves hypers to corresponding Go initializer code. -func (pr *Hypers) SaveGoCode(filename gi.Filename) error { +func (pr *Hypers) SaveGoCode(filename core.Filename) error { fp, err := os.Create(string(filename)) defer fp.Close() if err != nil { @@ -178,7 +178,7 @@ func (pr *Hypers) SaveGoCode(filename gi.Filename) error { // Sel // OpenJSON opens params from a JSON-formatted file. -func (pr *Sel) OpenJSON(filename gi.Filename) error { +func (pr *Sel) OpenJSON(filename core.Filename) error { b, err := ioutil.ReadFile(string(filename)) if err != nil { log.Println(err) @@ -188,18 +188,18 @@ func (pr *Sel) OpenJSON(filename gi.Filename) error { } // SaveJSON saves params to a JSON-formatted file. -func (pr *Sel) SaveJSON(filename gi.Filename) error { - return jsons.Save(pr, string(filename)) +func (pr *Sel) SaveJSON(filename core.Filename) error { + return jsonx.Save(pr, string(filename)) } // OpenTOML opens params from a TOML-formatted file. -func (pr *Sel) OpenTOML(filename gi.Filename) error { - return tomls.Open(pr, string(filename)) +func (pr *Sel) OpenTOML(filename core.Filename) error { + return tomlx.Open(pr, string(filename)) } // SaveTOML saves params to a TOML-formatted file. -func (pr *Sel) SaveTOML(filename gi.Filename) error { - // return tomls.Save(pr, string(filename)) +func (pr *Sel) SaveTOML(filename core.Filename) error { + // return tomlx.Save(pr, string(filename)) return grows.Save(pr, string(filename), func(w io.Writer) grows.Encoder { return toml.NewEncoder(w) }) @@ -226,7 +226,7 @@ func (pr *Sel) StringGoCode() []byte { } // SaveGoCode saves params to corresponding Go initializer code. -func (pr *Sel) SaveGoCode(filename gi.Filename) error { +func (pr *Sel) SaveGoCode(filename core.Filename) error { fp, err := os.Create(string(filename)) defer fp.Close() if err != nil { @@ -242,7 +242,7 @@ func (pr *Sel) SaveGoCode(filename gi.Filename) error { // Sheet // OpenJSON opens params from a JSON-formatted file. -func (pr *Sheet) OpenJSON(filename gi.Filename) error { +func (pr *Sheet) OpenJSON(filename core.Filename) error { *pr = make(Sheet, 0) // reset b, err := ioutil.ReadFile(string(filename)) if err != nil { @@ -253,19 +253,19 @@ func (pr *Sheet) OpenJSON(filename gi.Filename) error { } // SaveJSON saves params to a JSON-formatted file. -func (pr *Sheet) SaveJSON(filename gi.Filename) error { - return jsons.Save(pr, string(filename)) +func (pr *Sheet) SaveJSON(filename core.Filename) error { + return jsonx.Save(pr, string(filename)) } // OpenTOML opens params from a TOML-formatted file. -func (pr *Sheet) OpenTOML(filename gi.Filename) error { +func (pr *Sheet) OpenTOML(filename core.Filename) error { *pr = make(Sheet, 0) // reset - return tomls.Open(pr, string(filename)) + return tomlx.Open(pr, string(filename)) } // SaveTOML saves params to a TOML-formatted file. -func (pr *Sheet) SaveTOML(filename gi.Filename) error { - // return tomls.Save(pr, string(filename)) +func (pr *Sheet) SaveTOML(filename core.Filename) error { + // return tomlx.Save(pr, string(filename)) return grows.Save(pr, string(filename), func(w io.Writer) grows.Encoder { return toml.NewEncoder(w) }) @@ -294,7 +294,7 @@ func (pr *Sheet) StringGoCode() []byte { } // SaveGoCode saves params to corresponding Go initializer code. -func (pr *Sheet) SaveGoCode(filename gi.Filename) error { +func (pr *Sheet) SaveGoCode(filename core.Filename) error { fp, err := os.Create(string(filename)) defer fp.Close() if err != nil { @@ -310,7 +310,7 @@ func (pr *Sheet) SaveGoCode(filename gi.Filename) error { // Sheets // OpenJSON opens params from a JSON-formatted file. -func (pr *Sheets) OpenJSON(filename gi.Filename) error { +func (pr *Sheets) OpenJSON(filename core.Filename) error { *pr = make(Sheets) // reset b, err := ioutil.ReadFile(string(filename)) if err != nil { @@ -321,19 +321,19 @@ func (pr *Sheets) OpenJSON(filename gi.Filename) error { } // SaveJSON saves params to a JSON-formatted file. -func (pr *Sheets) SaveJSON(filename gi.Filename) error { - return jsons.Save(pr, string(filename)) +func (pr *Sheets) SaveJSON(filename core.Filename) error { + return jsonx.Save(pr, string(filename)) } // OpenTOML opens params from a TOML-formatted file. -func (pr *Sheets) OpenTOML(filename gi.Filename) error { +func (pr *Sheets) OpenTOML(filename core.Filename) error { *pr = make(Sheets) // reset - return tomls.Open(pr, string(filename)) + return tomlx.Open(pr, string(filename)) } // SaveTOML saves params to a TOML-formatted file. -func (pr *Sheets) SaveTOML(filename gi.Filename) error { - // return tomls.Save(pr, string(filename)) +func (pr *Sheets) SaveTOML(filename core.Filename) error { + // return tomlx.Save(pr, string(filename)) return grows.Save(pr, string(filename), func(w io.Writer) grows.Encoder { return toml.NewEncoder(w) }) @@ -369,7 +369,7 @@ func (pr *Sheets) StringGoCode() []byte { } // SaveGoCode saves params to corresponding Go initializer code. -func (pr *Sheets) SaveGoCode(filename gi.Filename) error { +func (pr *Sheets) SaveGoCode(filename core.Filename) error { fp, err := os.Create(string(filename)) defer fp.Close() if err != nil { @@ -385,7 +385,7 @@ func (pr *Sheets) SaveGoCode(filename gi.Filename) error { // Set // OpenJSON opens params from a JSON-formatted file. -func (pr *Set) OpenJSON(filename gi.Filename) error { +func (pr *Set) OpenJSON(filename core.Filename) error { b, err := ioutil.ReadFile(string(filename)) if err != nil { log.Println(err) @@ -395,18 +395,18 @@ func (pr *Set) OpenJSON(filename gi.Filename) error { } // SaveJSON saves params to a JSON-formatted file. -func (pr *Set) SaveJSON(filename gi.Filename) error { - return jsons.Save(pr, string(filename)) +func (pr *Set) SaveJSON(filename core.Filename) error { + return jsonx.Save(pr, string(filename)) } // OpenTOML opens params from a TOML-formatted file. -func (pr *Set) OpenTOML(filename gi.Filename) error { - return tomls.Open(pr, string(filename)) +func (pr *Set) OpenTOML(filename core.Filename) error { + return tomlx.Open(pr, string(filename)) } // SaveTOML saves params to a TOML-formatted file. -func (pr *Set) SaveTOML(filename gi.Filename) error { - // return tomls.Save(pr, string(filename)) +func (pr *Set) SaveTOML(filename core.Filename) error { + // return tomlx.Save(pr, string(filename)) return grows.Save(pr, string(filename), func(w io.Writer) grows.Encoder { return toml.NewEncoder(w) }) @@ -422,7 +422,7 @@ func (pr *Set) WriteGoCode(w io.Writer, depth int, name string) { // Sets // OpenJSON opens params from a JSON-formatted file. -func (pr *Sets) OpenJSON(filename gi.Filename) error { +func (pr *Sets) OpenJSON(filename core.Filename) error { *pr = make(Sets) // reset b, err := ioutil.ReadFile(string(filename)) if err != nil { @@ -433,19 +433,19 @@ func (pr *Sets) OpenJSON(filename gi.Filename) error { } // SaveJSON saves params to a JSON-formatted file. -func (pr *Sets) SaveJSON(filename gi.Filename) error { - return jsons.Save(pr, string(filename)) +func (pr *Sets) SaveJSON(filename core.Filename) error { + return jsonx.Save(pr, string(filename)) } // OpenTOML opens params from a TOML-formatted file. -func (pr *Sets) OpenTOML(filename gi.Filename) error { +func (pr *Sets) OpenTOML(filename core.Filename) error { *pr = make(Sets) // reset - return tomls.Open(pr, string(filename)) + return tomlx.Open(pr, string(filename)) } // SaveTOML saves params to a TOML-formatted file. -func (pr *Sets) SaveTOML(filename gi.Filename) error { - // return tomls.Save(pr, string(filename)) +func (pr *Sets) SaveTOML(filename core.Filename) error { + // return tomlx.Save(pr, string(filename)) return grows.Save(pr, string(filename), func(w io.Writer) grows.Encoder { return toml.NewEncoder(w) }) @@ -474,7 +474,7 @@ func (pr *Sets) StringGoCode() []byte { } // SaveGoCode saves params to corresponding Go initializer code. -func (pr *Sets) SaveGoCode(filename gi.Filename) error { +func (pr *Sets) SaveGoCode(filename core.Filename) error { fp, err := os.Create(string(filename)) defer fp.Close() if err != nil { @@ -487,63 +487,63 @@ func (pr *Sets) SaveGoCode(filename gi.Filename) error { } /* -var ParamsProps = ki.Props{ - "ToolBar": ki.PropSlice{ - {"Save", ki.PropSlice{ - {"SaveTOML", ki.Props{ +var ParamsProps = tree.Props{ + "ToolBar": tree.PropSlice{ + {"Save", tree.PropSlice{ + {"SaveTOML", tree.Props{ "label": "Save As TOML...", "desc": "save to TOML formatted file", "icon": "file-save", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".toml", }}, }, }}, - {"SaveJSON", ki.Props{ + {"SaveJSON", tree.Props{ "label": "Save As JSON...", "desc": "save to JSON formatted file", "icon": "file-save", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".json", }}, }, }}, - {"SaveGoCode", ki.Props{ + {"SaveGoCode", tree.Props{ "label": "Save Code As...", "desc": "save to Go-formatted initializer code in file", "icon": "go", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".go", }}, }, }}, }}, - {"Open", ki.PropSlice{ - {"OpenTOML", ki.Props{ + {"Open", tree.PropSlice{ + {"OpenTOML", tree.Props{ "label": "Open...", "desc": "open from TOML formatted file", "icon": "file-open", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".toml", }}, }, }}, - {"OpenJSON", ki.Props{ + {"OpenJSON", tree.Props{ "label": "Open...", "desc": "open from JSON formatted file", "icon": "file-open", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".json", }}, }, }}, }}, - {"StringGoCode", ki.Props{ + {"StringGoCode", tree.Props{ "label": "Show Code", "desc": "shows the Go-formatted initializer code, can be copy / pasted into program", "icon": "go", @@ -552,63 +552,63 @@ var ParamsProps = ki.Props{ }, } -var HypersProps = ki.Props{ - "ToolBar": ki.PropSlice{ - {"Save", ki.PropSlice{ - {"SaveTOML", ki.Props{ +var HypersProps = tree.Props{ + "ToolBar": tree.PropSlice{ + {"Save", tree.PropSlice{ + {"SaveTOML", tree.Props{ "label": "Save As TOML...", "desc": "save to TOML formatted file", "icon": "file-save", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".toml", }}, }, }}, - {"SaveJSON", ki.Props{ + {"SaveJSON", tree.Props{ "label": "Save As JSON...", "desc": "save to JSON formatted file", "icon": "file-save", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".json", }}, }, }}, - {"SaveGoCode", ki.Props{ + {"SaveGoCode", tree.Props{ "label": "Save Code As...", "desc": "save to Go-formatted initializer code in file", "icon": "go", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".go", }}, }, }}, }}, - {"Open", ki.PropSlice{ - {"OpenTOML", ki.Props{ + {"Open", tree.PropSlice{ + {"OpenTOML", tree.Props{ "label": "Open...", "desc": "open from TOML formatted file", "icon": "file-open", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".toml", }}, }, }}, - {"OpenJSON", ki.Props{ + {"OpenJSON", tree.Props{ "label": "Open...", "desc": "open from JSON formatted file", "icon": "file-open", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".json", }}, }, }}, }}, - {"StringGoCode", ki.Props{ + {"StringGoCode", tree.Props{ "label": "Show Code", "desc": "shows the Go-formatted initializer code, can be copy / pasted into program", "icon": "go", @@ -617,63 +617,63 @@ var HypersProps = ki.Props{ }, } -var SelProps = ki.Props{ - "ToolBar": ki.PropSlice{ - {"Save", ki.PropSlice{ - {"SaveTOML", ki.Props{ +var SelProps = tree.Props{ + "ToolBar": tree.PropSlice{ + {"Save", tree.PropSlice{ + {"SaveTOML", tree.Props{ "label": "Save As TOML...", "desc": "save to TOML formatted file", "icon": "file-save", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".toml", }}, }, }}, - {"SaveJSON", ki.Props{ + {"SaveJSON", tree.Props{ "label": "Save As JSON...", "desc": "save to JSON formatted file", "icon": "file-save", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".json", }}, }, }}, - {"SaveGoCode", ki.Props{ + {"SaveGoCode", tree.Props{ "label": "Save Code As...", "desc": "save to Go-formatted initializer code in file", "icon": "go", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".go", }}, }, }}, }}, - {"Open", ki.PropSlice{ - {"OpenTOML", ki.Props{ + {"Open", tree.PropSlice{ + {"OpenTOML", tree.Props{ "label": "Open...", "desc": "open from TOML formatted file", "icon": "file-open", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".toml", }}, }, }}, - {"OpenJSON", ki.Props{ + {"OpenJSON", tree.Props{ "label": "Open...", "desc": "open from JSON formatted file", "icon": "file-open", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".json", }}, }, }}, }}, - {"StringGoCode", ki.Props{ + {"StringGoCode", tree.Props{ "label": "Show Code", "desc": "shows the Go-formatted initializer code, can be copy / pasted into program", "icon": "go", @@ -682,63 +682,63 @@ var SelProps = ki.Props{ }, } -var SheetProps = ki.Props{ - "ToolBar": ki.PropSlice{ - {"Save", ki.PropSlice{ - {"SaveTOML", ki.Props{ +var SheetProps = tree.Props{ + "ToolBar": tree.PropSlice{ + {"Save", tree.PropSlice{ + {"SaveTOML", tree.Props{ "label": "Save As TOML...", "desc": "save to TOML formatted file", "icon": "file-save", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".toml", }}, }, }}, - {"SaveJSON", ki.Props{ + {"SaveJSON", tree.Props{ "label": "Save As JSON...", "desc": "save to JSON formatted file", "icon": "file-save", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".json", }}, }, }}, - {"SaveGoCode", ki.Props{ + {"SaveGoCode", tree.Props{ "label": "Save Code As...", "desc": "save to Go-formatted initializer code in file", "icon": "go", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".go", }}, }, }}, }}, - {"Open", ki.PropSlice{ - {"OpenTOML", ki.Props{ + {"Open", tree.PropSlice{ + {"OpenTOML", tree.Props{ "label": "Open...", "desc": "open from TOML formatted file", "icon": "file-open", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".toml", }}, }, }}, - {"OpenJSON", ki.Props{ + {"OpenJSON", tree.Props{ "label": "Open...", "desc": "open from JSON formatted file", "icon": "file-open", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".json", }}, }, }}, }}, - {"StringGoCode", ki.Props{ + {"StringGoCode", tree.Props{ "label": "Show Code", "desc": "shows the Go-formatted initializer code, can be copy / pasted into program", "icon": "go", @@ -747,70 +747,70 @@ var SheetProps = ki.Props{ }, } -var SheetsProps = ki.Props{ - "ToolBar": ki.PropSlice{ - {"Save", ki.PropSlice{ - {"SaveTOML", ki.Props{ +var SheetsProps = tree.Props{ + "ToolBar": tree.PropSlice{ + {"Save", tree.PropSlice{ + {"SaveTOML", tree.Props{ "label": "Save As TOML...", "desc": "save to TOML formatted file", "icon": "file-save", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".toml", }}, }, }}, - {"SaveJSON", ki.Props{ + {"SaveJSON", tree.Props{ "label": "Save As JSON...", "desc": "save to JSON formatted file", "icon": "file-save", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".json", }}, }, }}, - {"SaveGoCode", ki.Props{ + {"SaveGoCode", tree.Props{ "label": "Save Code As...", "desc": "save to Go-formatted initializer code in file", "icon": "go", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".go", }}, }, }}, }}, - {"Open", ki.PropSlice{ - {"OpenTOML", ki.Props{ + {"Open", tree.PropSlice{ + {"OpenTOML", tree.Props{ "label": "Open...", "desc": "open from TOML formatted file", "icon": "file-open", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".toml", }}, }, }}, - {"OpenJSON", ki.Props{ + {"OpenJSON", tree.Props{ "label": "Open...", "desc": "open from JSON formatted file", "icon": "file-open", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".json", }}, }, }}, }}, - {"StringGoCode", ki.Props{ + {"StringGoCode", tree.Props{ "label": "Show Code", "desc": "shows the Go-formatted initializer code, can be copy / pasted into program", "icon": "go", "show-return": true, }}, - {"sep-diffs", ki.BlankProp{}}, - {"DiffsWithin", ki.Props{ + {"sep-diffs", tree.BlankProp{}}, + {"DiffsWithin", tree.Props{ "desc": "reports where the same param path is being set to different values within this set (both within the same Sheet and betwen sheets)", "icon": "search", "show-return": true, @@ -818,54 +818,54 @@ var SheetsProps = ki.Props{ }, } -var SetProps = ki.Props{ - "ToolBar": ki.PropSlice{ - {"Save", ki.PropSlice{ - {"SaveTOML", ki.Props{ +var SetProps = tree.Props{ + "ToolBar": tree.PropSlice{ + {"Save", tree.PropSlice{ + {"SaveTOML", tree.Props{ "label": "Save As TOML...", "desc": "save to TOML formatted file", "icon": "file-save", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".toml", }}, }, }}, - {"SaveJSON", ki.Props{ + {"SaveJSON", tree.Props{ "label": "Save As JSON...", "desc": "save to JSON formatted file", "icon": "file-save", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".json", }}, }, }}, }}, - {"Open", ki.PropSlice{ - {"OpenTOML", ki.Props{ + {"Open", tree.PropSlice{ + {"OpenTOML", tree.Props{ "label": "Open...", "desc": "open from TOML formatted file", "icon": "file-open", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".toml", }}, }, }}, - {"OpenJSON", ki.Props{ + {"OpenJSON", tree.Props{ "label": "Open...", "desc": "open from JSON formatted file", "icon": "file-open", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".json", }}, }, }}, }}, - {"sep-diffs", ki.BlankProp{}}, - {"DiffsWithin", ki.Props{ + {"sep-diffs", tree.BlankProp{}}, + {"DiffsWithin", tree.Props{ "desc": "reports where the same param path is being set to different values within this set (both within the same Sheet and betwen sheets)", "icon": "search", "show-return": true, @@ -873,85 +873,85 @@ var SetProps = ki.Props{ }, } -var SetsProps = ki.Props{ - "ToolBar": ki.PropSlice{ - {"Save", ki.PropSlice{ - {"SaveTOML", ki.Props{ +var SetsProps = tree.Props{ + "ToolBar": tree.PropSlice{ + {"Save", tree.PropSlice{ + {"SaveTOML", tree.Props{ "label": "Save As TOML...", "desc": "save to TOML formatted file", "icon": "file-save", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".toml", }}, }, }}, - {"SaveJSON", ki.Props{ + {"SaveJSON", tree.Props{ "label": "Save As JSON...", "desc": "save to JSON formatted file", "icon": "file-save", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".json", }}, }, }}, - {"SaveGoCode", ki.Props{ + {"SaveGoCode", tree.Props{ "label": "Save Code As...", "desc": "save to Go-formatted initializer code in file", "icon": "go", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".go", }}, }, }}, }}, - {"Open", ki.PropSlice{ - {"OpenTOML", ki.Props{ + {"Open", tree.PropSlice{ + {"OpenTOML", tree.Props{ "label": "Open...", "desc": "open from TOML formatted file", "icon": "file-open", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".toml", }}, }, }}, - {"OpenJSON", ki.Props{ + {"OpenJSON", tree.Props{ "label": "Open...", "desc": "open from JSON formatted file", "icon": "file-open", - "Args": ki.PropSlice{ - {"File Name", ki.Props{ + "Args": tree.PropSlice{ + {"File Name", tree.Props{ "ext": ".json", }}, }, }}, }}, - {"StringGoCode", ki.Props{ + {"StringGoCode", tree.Props{ "label": "Show Code", "desc": "shows the Go-formatted initializer code, can be copy / pasted into program", "icon": "go", "show-return": true, }}, - {"sep-diffs", ki.BlankProp{}}, - {"DiffsAll", ki.Props{ + {"sep-diffs", tree.BlankProp{}}, + {"DiffsAll", tree.Props{ "desc": "between all sets, reports where the same param path is being set to different values", "icon": "search", "show-return": true, }}, - {"DiffsFirst", ki.Props{ + {"DiffsFirst", tree.Props{ "desc": "between first set (e.g., the Base set) and rest of sets, reports where the same param path is being set to different values", "icon": "search", "show-return": true, }}, - {"DiffsWithin", ki.Props{ + {"DiffsWithin", tree.Props{ "desc": "reports all the cases where the same param path is being set to different values within different sheets in given set", "icon": "search", "show-return": true, - "Args": ki.PropSlice{ - {"Set Name", ki.Props{}}, + "Args": tree.PropSlice{ + {"Set Name", tree.Props{}}, }, }}, }, diff --git a/params/params.go b/params/params.go index a4ed17d..285ec8f 100644 --- a/params/params.go +++ b/params/params.go @@ -110,7 +110,7 @@ func NewSheet() *Sheet { return &sh } -// ElemLabel satisfies the gi.SliceLabeler interface to provide labels for slice elements +// ElemLabel satisfies the core.SliceLabeler interface to provide labels for slice elements func (sh *Sheet) ElemLabel(idx int) string { return (*sh)[idx].Sel } @@ -315,7 +315,7 @@ func (ps *Sets) ValidateSheets(valids []string) error { return err } -// // ElemLabel satisfies the gi.SliceLabeler interface to provide labels for slice elements +// // ElemLabel satisfies the core.SliceLabeler interface to provide labels for slice elements // func (ps *Sets) ElemLabel(idx int) string { // return (*ps)[idx].Name // } diff --git a/params/tweak.go b/params/tweak.go index 4290854..e050e53 100644 --- a/params/tweak.go +++ b/params/tweak.go @@ -10,8 +10,8 @@ import ( "strconv" "strings" - "cogentcore.org/core/laser" "cogentcore.org/core/math32" + "cogentcore.org/core/reflectx" "golang.org/x/exp/maps" ) @@ -156,7 +156,7 @@ func TweaksFromHypers(hypers Flex) []*Tweaks { for _, slnm := range slsort { sel := slnms[slnm] flx := sels[sel] - // fmt.Println(laser.StringJSON(sel), "\n", laser.StringJSON(flx)) + // fmt.Println(reflectx.StringJSON(sel), "\n", reflectx.StringJSON(flx)) var f0 *FlexVal for _, fv := range flx { if f0 == nil { @@ -198,7 +198,7 @@ func TweaksFromHypers(hypers Flex) []*Tweaks { var pars []float32 // param vals to search if tweak[0] == '[' { - err := laser.SetRobust(&pars, tweak) + err := reflectx.SetRobust(&pars, tweak) if err != nil { fmt.Println("Error processing tweak value list:", tweak, "error:", err) continue diff --git a/params/tweak_test.go b/params/tweak_test.go index 405847a..22e4fb0 100644 --- a/params/tweak_test.go +++ b/params/tweak_test.go @@ -7,7 +7,7 @@ package params import ( "testing" - "cogentcore.org/core/laser" + "cogentcore.org/core/reflectx" "github.com/andreyvit/diff" ) @@ -250,10 +250,10 @@ func TestTweakHypers(t *testing.T) { basenet := tweakSets.SetByName("Base").Sheets["Network"] hypers.ApplySheet(basenet, false) - // fmt.Println("hypers:", laser.StringJSON(hypers)) + // fmt.Println("hypers:", reflectx.StringJSON(hypers)) srch := TweaksFromHypers(hypers) - ss := laser.StringJSON(srch) + ss := reflectx.StringJSON(srch) // fmt.Println("\n\n##########\n", ss) if ss != trgSearch { t.Errorf("Test Tweak Search output incorrect at: %v!\n", diff.LineDiff(ss, trgSearch)) diff --git a/patgen/reshape.go b/patgen/reshape.go index 4c47350..3358186 100644 --- a/patgen/reshape.go +++ b/patgen/reshape.go @@ -7,7 +7,7 @@ package patgen import ( "log" - "cogentcore.org/core/gi" + "cogentcore.org/core/core" "github.com/emer/etable/v2/etable" "github.com/emer/etable/v2/etensor" ) @@ -35,11 +35,11 @@ func ReshapeCpp(dt *etable.Table) { // ReshapeCppFile fixes C++ emergent table shape which is reversed from Go. // It loads file from fname and saves to fixnm func ReshapeCppFile(dt *etable.Table, fname, fixnm string) { - err := dt.OpenCSV(gi.Filename(fname), etable.Tab) + err := dt.OpenCSV(core.Filename(fname), etable.Tab) if err != nil { log.Println(err) return } ReshapeCpp(dt) - dt.SaveCSV(gi.Filename(fixnm), etable.Tab, true) + dt.SaveCSV(core.Filename(fixnm), etable.Tab, true) } diff --git a/stepper/README.md b/stepper/README.md index b2ccfc2..b5aa59f 100644 --- a/stepper/README.md +++ b/stepper/README.md @@ -115,29 +115,29 @@ and (optionally) `stepper.StopCheckFn` functions: 8. Add code to the user interface to start, pause, and stop the simulation: ```go - func (ss *Sim) ConfigGUI() *gi.Window { + func (ss *Sim) ConfigGUI() *core.Window { ... - tbar.AddAction(gi.ActOpts{Label: "Stop", Icon: "stop", + tbar.AddAction(core.ActOpts{Label: "Stop", Icon: "stop", Tooltip: "Stop the current program at its next natural stopping point (i.e., cleanly stopping when appropriate chunks of computation have completed).", - UpdateFunc: func(act *gi.Action) { + UpdateFunc: func(act *core.Action) { act.SetActiveStateUpdate(ss.IsRunning) - }}, win.This(), func(recv, send ki.Ki, sig int64, data interface{}) { + }}, win.This(), func(recv, send tree.Ki, sig int64, data interface{}) { fmt.Println("STOP!") ss.Stepper.Pause() // NOTE: call Pause here. Stop should only be called when starting over for a new run ss.IsRunning = false ss.ToolBar.UpdateActions() ss.Win.Viewport.SetNeedsFullRender() }) - tbar.AddAction(gi.ActOpts{Label: "Cycle", Icon: "run", Tooltip: "Step to the end of a Cycle.", - UpdateFunc: func(act *gi.Action) { + tbar.AddAction(core.ActOpts{Label: "Cycle", Icon: "run", Tooltip: "Step to the end of a Cycle.", + UpdateFunc: func(act *core.Action) { act.SetActiveStateUpdate(!ss.IsRunning) - }}, win.This(), func(recv, send ki.Ki, sig int64, data interface{}) { + }}, win.This(), func(recv, send tree.Ki, sig int64, data interface{}) { ss.RunSteps(Cycle, tbar) }) ... } - func (ss *Sim) RunSteps(grain StepGrain, tbar *gi.ToolBar) { + func (ss *Sim) RunSteps(grain StepGrain, tbar *core.ToolBar) { if !ss.IsRunning { ss.IsRunning = true tbar.UpdateActions()