From 3478e753e9cca56b7f80885ad4a45b2ceed654b5 Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Mon, 7 Oct 2024 14:13:36 -0700 Subject: [PATCH 1/6] update go.mod and fix author, terminal --- author/book/book.go | 60 ++-- author/book/{book.cosh => book.goal} | 16 +- go.mod | 6 +- go.sum | 8 +- numbers/cmd/numbers/numbers.go | 127 ++------ numbers/cmd/numbers/typegen.go | 15 - numbers/databrowser/README.md | 7 - numbers/databrowser/browser.go | 270 ------------------ numbers/databrowser/clean.go | 59 ---- ...gentcore_org-cogent-numbers-databrowser.go | 32 --- numbers/databrowser/datatab.go | 164 ----------- numbers/databrowser/filetree.go | 214 -------------- numbers/databrowser/prompt.go | 61 ---- numbers/databrowser/typegen.go | 38 --- .../cogentcore_org-core-tensor-bitslice.go | 19 -- .../cogentcore_org-core-tensor-stats-clust.go | 36 --- ...gentcore_org-core-tensor-stats-convolve.go | 19 -- ...entcore_org-core-tensor-stats-histogram.go | 18 -- ...cogentcore_org-core-tensor-stats-metric.go | 69 ----- .../cogentcore_org-core-tensor-stats-norm.go | 43 --- .../cogentcore_org-core-tensor-stats-pca.go | 24 -- .../cogentcore_org-core-tensor-stats-simat.go | 23 -- .../cogentcore_org-core-tensor-stats-split.go | 24 -- .../cogentcore_org-core-tensor-stats-stats.go | 167 ----------- .../cogentcore_org-core-tensor-table.go | 53 ---- .../cogentcore_org-core-tensor-tensorcore.go | 33 --- numbers/imports/cogentcore_org-core-tensor.go | 166 ----------- numbers/imports/core.go | 11 - numbers/imports/make | 5 - numbers/numshell/interp.go | 73 ----- numbers/random/random.go | 16 +- terminal/app.go | 2 +- 32 files changed, 77 insertions(+), 1801 deletions(-) rename author/book/{book.cosh => book.goal} (96%) delete mode 100644 numbers/cmd/numbers/typegen.go delete mode 100644 numbers/databrowser/README.md delete mode 100644 numbers/databrowser/browser.go delete mode 100644 numbers/databrowser/clean.go delete mode 100644 numbers/databrowser/cogentcore_org-cogent-numbers-databrowser.go delete mode 100644 numbers/databrowser/datatab.go delete mode 100644 numbers/databrowser/filetree.go delete mode 100644 numbers/databrowser/prompt.go delete mode 100644 numbers/databrowser/typegen.go delete mode 100644 numbers/imports/cogentcore_org-core-tensor-bitslice.go delete mode 100644 numbers/imports/cogentcore_org-core-tensor-stats-clust.go delete mode 100644 numbers/imports/cogentcore_org-core-tensor-stats-convolve.go delete mode 100644 numbers/imports/cogentcore_org-core-tensor-stats-histogram.go delete mode 100644 numbers/imports/cogentcore_org-core-tensor-stats-metric.go delete mode 100644 numbers/imports/cogentcore_org-core-tensor-stats-norm.go delete mode 100644 numbers/imports/cogentcore_org-core-tensor-stats-pca.go delete mode 100644 numbers/imports/cogentcore_org-core-tensor-stats-simat.go delete mode 100644 numbers/imports/cogentcore_org-core-tensor-stats-split.go delete mode 100644 numbers/imports/cogentcore_org-core-tensor-stats-stats.go delete mode 100644 numbers/imports/cogentcore_org-core-tensor-table.go delete mode 100644 numbers/imports/cogentcore_org-core-tensor-tensorcore.go delete mode 100644 numbers/imports/cogentcore_org-core-tensor.go delete mode 100644 numbers/imports/core.go delete mode 100755 numbers/imports/make delete mode 100644 numbers/numshell/interp.go diff --git a/author/book/book.go b/author/book/book.go index 61d77f77..e97ba76d 100644 --- a/author/book/book.go +++ b/author/book/book.go @@ -1,3 +1,5 @@ +// Code generated by "goal build"; DO NOT EDIT. + // Copyright (c) 2024, Cogent Core. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -27,17 +29,15 @@ import ( "cogentcore.org/core/base/iox/imagex" "cogentcore.org/core/base/iox/yamlx" "cogentcore.org/core/base/logx" - coshell "cogentcore.org/core/shell" - "cogentcore.org/core/shell/cosh" + goalp "cogentcore.org/core/goal" + "cogentcore.org/core/goal/goalib" ) var ( - shell = coshell.NewShell() + goal = goalp.NewGoal() pdInputs = filepath.Join("author", "pandoc-inputs") ) -// Code generated by "cosh build"; DO NOT EDIT. - // Book generates a book based on a set of markdown files, with the // following required file names (with [] indicating optional files): // @@ -63,7 +63,7 @@ func Book(c *author.Config) error { //types:add book.Refs() // note: we allow this to fail, in case using compiled refs mdfn := book.Markdown() if logx.UserLevel <= slog.LevelInfo { - shell.Config.Echo = os.Stdout + goal.Config.Echo = os.Stdout } var errs []error for _, fmt := range c.Formats { @@ -141,7 +141,7 @@ func (bk *BookData) HTML(mdfn string) error { f.Write(imgb64) f.Write([]byte("\"/>\n\n")) f.Close() - shell.Run("pandoc", "-f", mdopts, "--lua-filter", bk.pdi("glossary-filter.lua"), "-F", "pandoc-crossref", "--citeproc", "--bibliography", "references.bib", "-t", "html", "-B", cover, "--standalone", "--embed-resources", "--number-sections", "--css", bk.pdi("html.css"), "-H", bk.pdi("head_include.html"), "-o", trg, mdfn) + goal.Run("pandoc", "-f", mdopts, "--lua-filter", bk.pdi("glossary-filter.lua"), "-F", "pandoc-crossref", "--citeproc", "--bibliography", "references.bib", "-t", "html", "-B", cover, "--standalone", "--embed-resources", "--number-sections", "--css", bk.pdi("html.css"), "-H", bk.pdi("head_include.html"), "-o", trg, mdfn) return nil } @@ -150,7 +150,7 @@ func (bk *BookData) PDF(mdfn string) error { logx.PrintlnWarn("\n####################################\nGenerating PDF...\n") mdopts := bk.pandocMarkdownOpts() trg := bk.Name + ".pdf" - shell.Run("pandoc", "-f", mdopts, "--lua-filter", bk.pdi("glossary-filter.lua"), "-F", "pandoc-crossref", "--citeproc", "--bibliography", "references.bib", "-t", "latex", "--template", bk.pdi("latex.template"), "-H", bk.pdi("header.latex"), "-B", bk.pdi("cover-page.latex"), "--number-sections", "--toc", "-o", trg, mdfn) + goal.Run("pandoc", "-f", mdopts, "--lua-filter", bk.pdi("glossary-filter.lua"), "-F", "pandoc-crossref", "--citeproc", "--bibliography", "references.bib", "-t", "latex", "--template", bk.pdi("latex.template"), "-H", bk.pdi("header.latex"), "-B", bk.pdi("cover-page.latex"), "--number-sections", "--toc", "-o", trg, mdfn) return nil } @@ -159,7 +159,7 @@ func (bk *BookData) LaTeX(mdfn string) error { logx.PrintlnWarn("\n####################################\nGenerating LaTeX...\n") mdopts := bk.pandocMarkdownOpts() trg := bk.Name + ".tex" - shell.Run("pandoc", "-f", mdopts, "--lua-filter", bk.pdi("glossary-filter.lua"), "-F", "pandoc-crossref", "--citeproc", "--bibliography", "references.bib", "-t", "latex", "--template", bk.pdi("latex.template"), "-H", bk.pdi("header.latex"), "-B", bk.pdi("cover-page.latex"), "--number-sections", "--toc", "-o", trg, mdfn) + goal.Run("pandoc", "-f", mdopts, "--lua-filter", bk.pdi("glossary-filter.lua"), "-F", "pandoc-crossref", "--citeproc", "--bibliography", "references.bib", "-t", "latex", "--template", bk.pdi("latex.template"), "-H", bk.pdi("header.latex"), "-B", bk.pdi("cover-page.latex"), "--number-sections", "--toc", "-o", trg, mdfn) return nil } @@ -183,7 +183,7 @@ func (bk *BookData) EPUB(mdfn string) error { fmt.Fprintf(f, "%s\n", md["identifier_scheme"], md["identifier"]) f.Close() - shell.Run("pandoc", "-f", mdopts, "--lua-filter", bk.pdi("glossary-filter.lua"), "-F", "pandoc-crossref", "--citeproc", "--bibliography", "references.bib", "-t", "epub", "--standalone", "--embed-resources", "--number-sections", "--css", bk.pdi("epub.css"), "--epub-metadata", emd, "--epub-cover-image", "cover.png", "-o", trg, mdfn) + goal.Run("pandoc", "-f", mdopts, "--lua-filter", bk.pdi("glossary-filter.lua"), "-F", "pandoc-crossref", "--citeproc", "--bibliography", "references.bib", "-t", "epub", "--standalone", "--embed-resources", "--number-sections", "--css", bk.pdi("epub.css"), "--epub-metadata", emd, "--epub-cover-image", "cover.png", "-o", trg, mdfn) return nil } @@ -192,7 +192,7 @@ func (bk *BookData) DOCX(mdfn string) error { logx.PrintlnWarn("\n####################################\nGenerating DOCX...\n") mdopts := bk.pandocMarkdownOpts() trg := bk.Name + ".docx" - shell.Run("pandoc", "-f", mdopts, "--lua-filter", bk.pdi("glossary-filter.lua"), "-F", "pandoc-crossref", "--citeproc", "--bibliography", "references.bib", "-t", "docx", "--number-sections", "--reference-doc", bk.pdi("custom-reference.docx"), "-o", trg, mdfn) + goal.Run("pandoc", "-f", mdopts, "--lua-filter", bk.pdi("glossary-filter.lua"), "-F", "pandoc-crossref", "--citeproc", "--bibliography", "references.bib", "-t", "docx", "--number-sections", "--reference-doc", bk.pdi("custom-reference.docx"), "-o", trg, mdfn) return nil } @@ -207,40 +207,40 @@ func (bk *BookData) Markdown() string { fn := "author/book.md" bk.GetFiles() bk.metadataToMD(fn) - shell.Run("cat", "frontmatter.md", ">>", fn) + goal.Run("cat", "frontmatter.md", ">>", fn) for ci, ch := range bk.Chapters { chdiv := fmt.Sprintf("\n
\n", ci) - shell.Run("echo", chdiv, ">>", fn) - shell.Run("cat", ch, ">>", fn) - shell.Run("echo", "\n
", ">>", fn) + goal.Run("echo", chdiv, ">>", fn) + goal.Run("cat", ch, ">>", fn) + goal.Run("echo", "\n", ">>", fn) } - shell.Run("cat", "endmatter.md", ">>", fn) + goal.Run("cat", "endmatter.md", ">>", fn) // todo: appendix - if cosh.FileExists("glossary.md") { - shell.Run("echo", "\n
\n", ">>", fn) - shell.Run("cat", "glossary.md", ">>", fn) - shell.Run("echo", "\n
", ">>", fn) + if goalib.FileExists("glossary.md") { + goal.Run("echo", "\n
\n", ">>", fn) + goal.Run("cat", "glossary.md", ">>", fn) + goal.Run("echo", "\n
", ">>", fn) } - shell.Run("echo", "# References {-}", ">>", fn) - shell.Run("echo", "\n::: {#refs}", ">>", fn) - shell.Run("echo", ":::", ">>", fn) + goal.Run("echo", "# References {-}", ">>", fn) + goal.Run("echo", "\n::: {#refs}", ">>", fn) + goal.Run("echo", ":::", ">>", fn) return fn } func (bk *BookData) GetFiles() { - bk.Chapters = cosh.SplitLines(shell.Output("ls", "chapter-*.md")) + bk.Chapters = goalib.SplitLines(`ls chapter-*.md`) sort.Strings(bk.Chapters) - if cosh.FileExists("appendix-a.md") { - bk.Appendicies = cosh.SplitLines(shell.Output("ls", "appendix-*.md")) + if goalib.FileExists("appendix-a.md") { + bk.Appendicies = goalib.SplitLines(`ls appendix-*.md`) sort.Strings(bk.Appendicies) } } // metadataToMD outputs the medadata to book.md file func (bk *BookData) metadataToMD(fn string) { - shell.Run("echo", "---", ">", fn) - shell.Run("cat", "metadata.yaml", ">>", fn) - shell.Run("echo", "---", ">>", fn) + goal.Run("echo", "---", ">", fn) + goal.Run("cat", "metadata.yaml", ">>", fn) + goal.Run("echo", "---", ">>", fn) } func (bk *BookData) pdi(fn string) string { @@ -255,7 +255,7 @@ func (bk *BookData) savePandocInputs() { fc, _ := fs.ReadFile(PandocInputs, fn) _, fb := path.Split(fn) tf := bk.pdi(fb) - cosh.WriteFile(tf, string(fc)) + goalib.WriteFile(tf, string(fc)) } } diff --git a/author/book/book.cosh b/author/book/book.goal similarity index 96% rename from author/book/book.cosh rename to author/book/book.goal index 9035ffd7..bdb24b15 100644 --- a/author/book/book.cosh +++ b/author/book/book.goal @@ -18,11 +18,11 @@ import ( "cogentcore.org/core/base/logx" "cogentcore.org/core/base/iox/imagex" "cogentcore.org/core/base/iox/yamlx" - coshell "cogentcore.org/core/shell" + goalp "cogentcore.org/core/goal" ) var ( - shell = coshell.NewShell() + goal = goalp.NewGoal() pdInputs = filepath.Join("author", "pandoc-inputs") ) @@ -51,7 +51,7 @@ func Book(c *author.Config) error { //types:add book.Refs() // note: we allow this to fail, in case using compiled refs mdfn := book.Markdown() if logx.UserLevel <= slog.LevelInfo { - shell.Config.Echo = os.Stdout + goal.Config.Echo = os.Stdout } var errs []error for _, fmt := range c.Formats { @@ -204,7 +204,7 @@ func (bk *BookData) Markdown() string { } cat "endmatter.md" >> {fn} // todo: appendix - if cosh.FileExists("glossary.md") { + if goalib.FileExists("glossary.md") { echo "\n
\n" >> {fn} cat "glossary.md" >> {fn} echo "\n
" >> {fn} @@ -216,10 +216,10 @@ func (bk *BookData) Markdown() string { } func (bk *BookData) GetFiles() { - bk.Chapters = cosh.SplitLines(`ls chapter-*.md`) + bk.Chapters = goalib.SplitLines(`ls chapter-*.md`) sort.Strings(bk.Chapters) - if cosh.FileExists("appendix-a.md") { - bk.Appendicies = cosh.SplitLines(`ls appendix-*.md`) + if goalib.FileExists("appendix-a.md") { + bk.Appendicies = goalib.SplitLines(`ls appendix-*.md`) sort.Strings(bk.Appendicies) } } @@ -243,7 +243,7 @@ func (bk *BookData) savePandocInputs() { fc, _ := fs.ReadFile(PandocInputs, fn) _, fb := path.Split(fn) tf := bk.pdi(fb) - cosh.WriteFile(tf, string(fc)) + goalib.WriteFile(tf, string(fc)) } } diff --git a/go.mod b/go.mod index d521ab95..5bc6fdd1 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module cogentcore.org/cogent go 1.22 require ( - cogentcore.org/core v0.3.3-0.20240902213628-48df10901467 + cogentcore.org/core v0.3.5-0.20241007210315-636a2d6b7fc8 github.com/Knetic/govaluate v3.0.0+incompatible github.com/aandrew-me/tgpt/v2 v2.7.2 github.com/alecthomas/chroma/v2 v2.13.0 @@ -15,7 +15,6 @@ require ( github.com/emersion/go-message v0.18.1 github.com/emersion/go-sasl v0.0.0-20231106173351-e73c9f7bad43 github.com/emersion/go-smtp v0.21.1 - github.com/ergochat/readline v0.1.2 github.com/go-delve/delve v1.22.1 github.com/mattn/go-shellwords v1.0.12 github.com/robert-nix/ansihtml v1.0.1 @@ -39,9 +38,10 @@ require ( github.com/chewxy/math32 v1.10.1 // indirect github.com/cilium/ebpf v0.13.2 // indirect github.com/cloudflare/circl v1.3.7 // indirect - github.com/cogentcore/webgpu v0.0.0-20240812054109-ca2e8adebe15 // indirect + github.com/cogentcore/webgpu v0.0.0-20240906154609-e35089e9a725 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dlclark/regexp2 v1.11.0 // indirect + github.com/ergochat/readline v0.1.2 // indirect github.com/ericchiang/css v1.3.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a // indirect diff --git a/go.sum b/go.sum index 73174d86..142412d5 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -cogentcore.org/core v0.3.3-0.20240902213628-48df10901467 h1:AL9pi5H1ttL76EpnqBCCaflNnfwRxuezZOApoSOL564= -cogentcore.org/core v0.3.3-0.20240902213628-48df10901467/go.mod h1:dg3uRsPcd8S1ZYvRD2TztCtjopRkrB5V/lbl54xsQd4= +cogentcore.org/core v0.3.5-0.20241007210315-636a2d6b7fc8 h1:cf6+MvGjy6pSsjSK6u+coLLHEJ6sG5aBB3zzWun6T14= +cogentcore.org/core v0.3.5-0.20241007210315-636a2d6b7fc8/go.mod h1:HiWp9KXOQmYNaW5wdGpMBEHQTVprdsfBzVmTJ8OPk1A= github.com/Bios-Marcel/wastebasket v0.0.4-0.20240213135800-f26f1ae0a7c4 h1:6lx9xzJAhdjq0LvVfbITeC3IH9Fzvo1aBahyPu2FuG8= github.com/Bios-Marcel/wastebasket v0.0.4-0.20240213135800-f26f1ae0a7c4/go.mod h1:FChzXi1izqzdPb6BiNZmcZLGyTYiT61iGx9Rxx9GNeI= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -38,8 +38,8 @@ github.com/cilium/ebpf v0.13.2 h1:uhLimLX+jF9BTPPvoCUYh/mBeoONkjgaJ9w9fn0mRj4= github.com/cilium/ebpf v0.13.2/go.mod h1:DHp1WyrLeiBh19Cf/tfiSMhqheEiK8fXFZ4No0P1Hso= github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= -github.com/cogentcore/webgpu v0.0.0-20240812054109-ca2e8adebe15 h1:Yg1VobUl2PWHzNsNVm5ong4u/zWDkucgwLvv7/qf1PU= -github.com/cogentcore/webgpu v0.0.0-20240812054109-ca2e8adebe15/go.mod h1:ciqaxChrmRRMU1SnI5OE12Cn3QWvOKO+e5nSy+N9S1o= +github.com/cogentcore/webgpu v0.0.0-20240906154609-e35089e9a725 h1:Zf2ixJY1PsN3huZa0Uof7VKYuoBbdxJCEbKdhKhHqwE= +github.com/cogentcore/webgpu v0.0.0-20240906154609-e35089e9a725/go.mod h1:ciqaxChrmRRMU1SnI5OE12Cn3QWvOKO+e5nSy+N9S1o= github.com/cogentcore/yaegi v0.0.0-20240724064145-e32a03faad56 h1:Fz1uHiFCHnijFcMXzn36KLamcx5q4pxoR5rKCrcXIcQ= github.com/cogentcore/yaegi v0.0.0-20240724064145-e32a03faad56/go.mod h1:+MGpZ0srBmeJ7aaOLTdVss8WLolt0/y/plVHLpxgd3A= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= diff --git a/numbers/cmd/numbers/numbers.go b/numbers/cmd/numbers/numbers.go index 4701bfd9..172ed7cd 100644 --- a/numbers/cmd/numbers/numbers.go +++ b/numbers/cmd/numbers/numbers.go @@ -7,109 +7,40 @@ package main import ( - "fmt" - "os" - "path/filepath" - "strings" - - "cogentcore.org/cogent/numbers/databrowser" - "cogentcore.org/cogent/numbers/random" - "cogentcore.org/core/base/errors" - "cogentcore.org/core/base/fsx" "cogentcore.org/core/cli" "cogentcore.org/core/core" "cogentcore.org/core/events" - "cogentcore.org/core/shell" - "cogentcore.org/core/shell/interpreter" - "github.com/cogentcore/yaegi/interp" + "cogentcore.org/core/goal/interpreter" + "cogentcore.org/core/icons" + "cogentcore.org/core/tensor/databrowser" + "cogentcore.org/core/tensor/datafs" + "cogentcore.org/core/tree" ) -//go:generate core generate -add-types -add-funcs - -// Config is the configuration information for the numbers cli. -type Config struct { - - // The input file to run/compile. - // If this is provided as the first argument, - // then the program will exit after running, - // unless the Interactive mode is flagged. - Input string `posarg:"0" required:"-"` - - // the Go file to output the transpiled Input file to, - // as an optional second argument in build mode. - // It defaults to the input file with .numbers changed to .go. - Output string `cmd:"build" posarg:"1" required:"-"` - - // an optional expression to evaluate, which can be used - // in addition to the Input file to run, to execute commands - // defined within that file for example, or as a command to run - // prior to starting interactive mode if no Input is specified. - Expr string `flag:"e,expr"` - - // runs the interactive command line after processing an Input file. - // Interactive mode is the default for all cases except when - // an Input file is specified, and is not available - // if an Output file is specified for transpiling. - Interactive bool `flag:"i,interactive"` -} - func main() { //types:skip opts := cli.DefaultOptions("numbers", "Cogent Numbers, an interactive tool for data management, analysis and math.") - cli.Run(opts, &Config{}, Run, Build) -} - -// Run runs the specified numbers file. If no file is specified, -// it runs an interactive shell that allows the user to input numbers. -func Run(c *Config) error { //cli:cmd -root - if c.Input == "" { - return Interactive(c) - } - code := "" - if errors.Log1(fsx.FileExists(c.Input)) { - b, err := os.ReadFile(c.Input) - if err != nil && c.Expr == "" { - return err - } - code = string(b) - } - if c.Expr != "" { - if code != "" { - code += "\n" - } - code += c.Expr + "\n" - } - in := interpreter.NewInterpreter(interp.Options{}) - in.Config() - _, _, err := in.Eval(code) - if err == nil { - err = in.Shell.DepthError() - } - if c.Interactive { - return Interactive(c) - } - return err + cfg := &interpreter.Config{} + cfg.InteractiveFunc = Interactive + cli.Run(opts, cfg, interpreter.Run, interpreter.Build) } // Interactive runs an interactive shell that allows the user to input numbers. -func Interactive(c *Config) error { - b := core.NewBody("Cogent Numbers") - core.NewText(b).SetText("Cogent Numbers").SetType(core.TextHeadlineSmall) - - ts := core.NewTabs(b) - - db, _ := ts.NewTab("Data browser") - core.NewText(db).SetType(core.TextTitleLarge).SetText("Use your terminal to enter data browser commands.") - - rt, _ := ts.NewTab("Random") - tb := core.NewToolbar(rt) - rd := random.NewRandom(rt) - tb.Maker(rd.MakeToolbar) - - in := interpreter.NewInterpreter(interp.Options{}) +func Interactive(c *interpreter.Config, in *interpreter.Interpreter) error { in.HistFile = "~/.numbers-history" - in.Interp.Use(databrowser.Symbols) - in.Config() - + br := databrowser.NewBrowserWindow(datafs.CurRoot, "Cogent Numbers") + b := br.Parent.(*core.Body) + b.AddTopBar(func(bar *core.Frame) { + tb := core.NewToolbar(bar) + // tb.Maker(tbv.MakeToolbar) + tb.Maker(func(p *tree.Plan) { + tree.Add(p, func(w *core.Button) { + w.SetText("README").SetIcon(icons.FileMarkdown). + SetTooltip("open README help file").OnClick(func(e events.Event) { + core.TheApp.OpenURL("https://github.com/cogentcore/core/blob/main/tensor/examples/planets/README.md") + }) + }) + }) + }) b.OnShow(func(e events.Event) { go func() { if c.Expr != "" { @@ -118,17 +49,7 @@ func Interactive(c *Config) error { in.Interactive() }() }) - b.RunMainWindow() + core.Wait() return nil } -// Build builds the specified input numbers file to the specified output Go file. -func Build(c *Config) error { - if c.Input == "" { - return fmt.Errorf("need input file") - } - if c.Output == "" { - c.Output = strings.TrimSuffix(c.Input, filepath.Ext(c.Input)) + ".go" - } - return shell.NewShell().TranspileFile(c.Input, c.Output) -} diff --git a/numbers/cmd/numbers/typegen.go b/numbers/cmd/numbers/typegen.go deleted file mode 100644 index 1f65a3bb..00000000 --- a/numbers/cmd/numbers/typegen.go +++ /dev/null @@ -1,15 +0,0 @@ -// Code generated by "core generate -add-types -add-funcs"; DO NOT EDIT. - -package main - -import ( - "cogentcore.org/core/types" -) - -var _ = types.AddType(&types.Type{Name: "main.Config", IDName: "config", Doc: "Config is the configuration information for the numbers cli.", Directives: []types.Directive{{Tool: "go", Directive: "generate", Args: []string{"core", "generate", "-add-types", "-add-funcs"}}}, Fields: []types.Field{{Name: "Input", Doc: "The input file to run/compile.\nIf this is provided as the first argument,\nthen the program will exit after running,\nunless the Interactive mode is flagged."}, {Name: "Output", Doc: "the Go file to output the transpiled Input file to,\nas an optional second argument in build mode.\nIt defaults to the input file with .numbers changed to .go."}, {Name: "Expr", Doc: "an optional expression to evaluate, which can be used\nin addition to the Input file to run, to execute commands\ndefined within that file for example, or as a command to run\nprior to starting interactive mode if no Input is specified."}, {Name: "Interactive", Doc: "runs the interactive command line after processing an Input file.\nInteractive mode is the default for all cases except when\nan Input file is specified, and is not available\nif an Output file is specified for transpiling."}}}) - -var _ = types.AddFunc(&types.Func{Name: "main.Run", Doc: "Run runs the specified numbers file. If no file is specified,\nit runs an interactive shell that allows the user to input numbers.", Directives: []types.Directive{{Tool: "cli", Directive: "cmd", Args: []string{"-root"}}}, Args: []string{"c"}, Returns: []string{"error"}}) - -var _ = types.AddFunc(&types.Func{Name: "main.Interactive", Doc: "Interactive runs an interactive shell that allows the user to input numbers.", Args: []string{"c"}, Returns: []string{"error"}}) - -var _ = types.AddFunc(&types.Func{Name: "main.Build", Doc: "Build builds the specified input numbers file to the specified output Go file.", Args: []string{"c"}, Returns: []string{"error"}}) diff --git a/numbers/databrowser/README.md b/numbers/databrowser/README.md deleted file mode 100644 index bb4d2962..00000000 --- a/numbers/databrowser/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# databrowser - -* metadata must be assembled by the user into a .toml file per data directory with the values, which can be assembled from other files in the directory etc. - -* maybe a master top-level .toml with the config for the tables with the column names - - diff --git a/numbers/databrowser/browser.go b/numbers/databrowser/browser.go deleted file mode 100644 index f3d96af1..00000000 --- a/numbers/databrowser/browser.go +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright (c) 2024, Cogent Core. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package databrowser - -//go:generate core generate -//go:generate yaegi extract cogentcore.org/cogent/numbers/databrowser - -import ( - "fmt" - "log/slog" - "os" - "path/filepath" - "reflect" - "slices" - "strconv" - "strings" - "unicode" - - "cogentcore.org/cogent/numbers/numshell" - "cogentcore.org/core/base/errors" - "cogentcore.org/core/base/fsx" - "cogentcore.org/core/base/logx" - "cogentcore.org/core/core" - "cogentcore.org/core/events" - "cogentcore.org/core/filetree" - "cogentcore.org/core/icons" - "cogentcore.org/core/styles" - "cogentcore.org/core/tree" - "cogentcore.org/core/types" - "github.com/cogentcore/yaegi/interp" - "golang.org/x/exp/maps" -) - -// TheBrowser is the current browser, -// which is valid immediately after NewBrowserWindow -// where it is used to get a local variable for subsequent use. -var TheBrowser *Browser - -// Symbols variable stores the map of stdlib symbols per package. -var Symbols = map[string]map[string]reflect.Value{} - -// MapTypes variable contains a map of functions which have an interface{} as parameter but -// do something special if the parameter implements a given interface. -var MapTypes = map[reflect.Value][]reflect.Type{} - -// Browser is a data browser, for browsing data typically organized into -// separate directories, with .cosh Scripts as toolbar actions to perform -// regular tasks on the data. -// Scripts are ordered alphabetically and any leading #- prefix is automatically -// removed from the label, so you can use numbers to specify a custom order. -type Browser struct { - core.Frame - - // DataRoot is the path to the root of the data to browse - DataRoot string - - // StartDir is the starting directory, where the numbers app - // was originally started. - StartDir string - - // ScriptsDir is the directory containing scripts for toolbar actions. - // It defaults to DataDir/dbscripts - ScriptsDir string - - // Scripts - Scripts map[string]string `set:"-"` - - // ScriptInterp is the interpreter to use for running Browser scripts - ScriptInterp *numshell.Interpreter `set:"-"` - - toolbar *core.Toolbar -} - -// Init initializes with the data and script directories -func (br *Browser) Init() { - br.Frame.Init() - br.Styler(func(s *styles.Style) { - s.Grow.Set(1, 1) - }) - br.InitInterp() - - br.OnShow(func(e events.Event) { - br.UpdateFiles() - }) - - tree.AddChildAt(br, "splits", func(w *core.Splits) { - w.SetSplits(.15, .85) - tree.AddChildAt(w, "fileframe", func(w *core.Frame) { - w.Styler(func(s *styles.Style) { - s.Direction = styles.Column - s.Overflow.Set(styles.OverflowAuto) - s.Grow.Set(1, 1) - }) - tree.AddChildAt(w, "filetree", func(w *filetree.Tree) { - w.FileNodeType = types.For[FileNode]() - // w.OnSelect(func(e events.Event) { - // e.SetHandled() - // sels := w.SelectedViews() - // if sels != nil { - // br.FileNodeSelected(sn) - // } - // }) - }) - }) - tree.AddChildAt(w, "tabs", func(w *core.Tabs) { - w.Type = core.FunctionalTabs - }) - }) -} - -// NewBrowserWindow opens a new data Browser for given data directory. -// By default the scripts for this data directory are located in -// dbscripts relative to the data directory. -func NewBrowserWindow(dataDir string) *Browser { - startDir, _ := os.Getwd() - startDir = errors.Log1(filepath.Abs(startDir)) - b := core.NewBody("Cogent Data Browser: " + fsx.DirAndFile(startDir)) - br := NewBrowser(b) - br.StartDir = startDir - ddr := errors.Log1(filepath.Abs(dataDir)) - fmt.Println(ddr) - b.AddTopBar(func(bar *core.Frame) { - tb := core.NewToolbar(bar) - br.toolbar = tb - tb.Maker(br.MakeToolbar) - }) - - br.SetDataRoot(ddr) - br.SetScriptsDir(filepath.Join(ddr, "dbscripts")) - TheBrowser = br - br.ScriptInterp.Eval("br := databrowser.TheBrowser") // grab it - br.UpdateScripts() - b.RunWindow() - return br -} - -// ParentBrowser returns the Browser parent of given node -func ParentBrowser(tn tree.Node) (*Browser, bool) { - var res *Browser - tn.AsTree().WalkUp(func(n tree.Node) bool { - if c, ok := n.(*Browser); ok { - res = c - return false - } - return true - }) - return res, res != nil -} - -func (br *Browser) InitInterp() { - br.ScriptInterp = numshell.NewInterpreter(interp.Options{}) - br.ScriptInterp.Interp.Use(Symbols) - // br.ScriptInterp.Interp.Use(interp.Exports{ - // "cogentcore.org/cogent/numbers/databrowser/databrowser": map[string]reflect.Value{ - // "br": reflect.ValueOf(br).Elem(), // note this does not work - // }, - // }) - br.ScriptInterp.Config() - // logx.UserLevel = slog.LevelDebug // for debugging of init loading -} - -func (br *Browser) GetDataRoot() string { - return br.DataRoot -} - -func (br *Browser) RunScript(snm string) { - sc, ok := br.Scripts[snm] - if !ok { - slog.Error("script not found:", "Script:", snm) - return - } - logx.PrintlnDebug("\n################\nrunning script:\n", sc, "\n") - _, _, err := br.ScriptInterp.Eval(sc) - if err == nil { - err = br.ScriptInterp.Shell.DepthError() - } - br.ScriptInterp.Shell.ResetDepth() -} - -func (br *Browser) Splits() *core.Splits { - return br.FindPath("splits").(*core.Splits) -} - -func (br *Browser) FileTree() *filetree.Tree { - sp := br.Splits() - return sp.Child(0).AsTree().Child(0).(*filetree.Tree) -} - -func (br *Browser) Tabs() *core.Tabs { - return br.FindPath("splits/tabs").(*core.Tabs) -} - -// UpdateFiles Updates the file picker with current files in DataRoot, -func (br *Browser) UpdateFiles() { //types:add - files := br.FileTree() - fmt.Println(br.DataRoot) - files.OpenPath(br.DataRoot) - // files.UpdateAll() TODO(filetree) - os.Chdir(br.DataRoot) - br.Update() -} - -// UpdateScripts updates the Scripts and updates the toolbar. -func (br *Browser) UpdateScripts() { //types:add - redo := (br.Scripts != nil) - scr := fsx.Filenames(br.ScriptsDir, ".cosh") - br.Scripts = make(map[string]string) - for _, s := range scr { - snm := strings.TrimSuffix(s, ".cosh") - sc, err := os.ReadFile(filepath.Join(br.ScriptsDir, s)) - if err == nil { - if unicode.IsLower(rune(snm[0])) { - if !redo { - fmt.Println("run init script:", snm) - br.ScriptInterp.Eval(string(sc)) - } - } else { - ssc := string(sc) - br.Scripts[snm] = ssc - } - } else { - slog.Error(err.Error()) - } - } - if br.toolbar != nil { - br.toolbar.Update() - } -} - -func (br *Browser) MakeToolbar(p *tree.Plan) { - tree.Add(p, func(w *core.FuncButton) { - w.SetFunc(br.UpdateFiles).SetText("").SetIcon(icons.Refresh).SetShortcut("Command+U") - }) - tree.Add(p, func(w *core.FuncButton) { - w.SetFunc(br.UpdateScripts).SetText("").SetIcon(icons.Code) - }) - scr := maps.Keys(br.Scripts) - slices.Sort(scr) - for _, s := range scr { - lbl := TrimOrderPrefix(s) - tree.AddAt(p, lbl, func(w *core.Button) { - w.SetText(lbl).SetIcon(icons.RunCircle). - OnClick(func(e events.Event) { - br.RunScript(s) - }) - sc := br.Scripts[s] - tt := FirstComment(sc) - if tt == "" { - tt = "Run Script (add a comment to top of script to provide more useful info here)" - } - w.SetTooltip(tt) - }) - } -} - -// TrimOrderPrefix trims any optional #- prefix from given string, -// used for ordering items by name. -func TrimOrderPrefix(s string) string { - i := strings.Index(s, "-") - if i < 0 { - return s - } - ds := s[:i] - if _, err := strconv.Atoi(ds); err != nil { - return s - } - return s[i+1:] -} diff --git a/numbers/databrowser/clean.go b/numbers/databrowser/clean.go deleted file mode 100644 index 7e031f65..00000000 --- a/numbers/databrowser/clean.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2024, Cogent Core. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package databrowser - -import ( - "io" - "log/slog" - "os" - "strings" - - "cogentcore.org/core/core" - "cogentcore.org/core/tensor/table" -) - -// CleanCatTSV cleans a TSV file formed by -// concatenating multiple files together. -// Removes redundant headers and then sorts -// by given set of columns -func CleanCatTSV(filename string, sorts []string) error { - str, err := os.ReadFile(filename) - if err != nil { - slog.Error(err.Error()) - return err - } - lns := strings.Split(string(str), "\n") - if len(lns) == 0 { - return nil - } - hdr := lns[0] - f, err := os.Create(filename) - if err != nil { - slog.Error(err.Error()) - return err - } - for i, ln := range lns { - if i > 0 && ln == hdr { - continue - } - io.WriteString(f, ln) - io.WriteString(f, "\n") - } - f.Close() - dt := table.NewTable() - err = dt.OpenCSV(core.Filename(filename), table.Detect) - if err != nil { - slog.Error(err.Error()) - return err - } - ix := table.NewIndexView(dt) - ix.SortColumnNames(sorts, table.Ascending) - st := ix.NewTable() - err = st.SaveCSV(core.Filename(filename), table.Tab, true) - if err != nil { - slog.Error(err.Error()) - } - return err -} diff --git a/numbers/databrowser/cogentcore_org-cogent-numbers-databrowser.go b/numbers/databrowser/cogentcore_org-cogent-numbers-databrowser.go deleted file mode 100644 index 1f4e3ac5..00000000 --- a/numbers/databrowser/cogentcore_org-cogent-numbers-databrowser.go +++ /dev/null @@ -1,32 +0,0 @@ -// Code generated by 'yaegi extract cogentcore.org/cogent/numbers/databrowser'. DO NOT EDIT. - -package databrowser - -import ( - "reflect" -) - -func init() { - Symbols["cogentcore.org/cogent/numbers/databrowser/databrowser"] = map[string]reflect.Value{ - // function, constant and variable definitions - "CleanCatTSV": reflect.ValueOf(CleanCatTSV), - "FirstComment": reflect.ValueOf(FirstComment), - "IsTableFile": reflect.ValueOf(IsTableFile), - "MapTypes": reflect.ValueOf(&MapTypes).Elem(), - "NewBrowser": reflect.ValueOf(NewBrowser), - "NewBrowserWindow": reflect.ValueOf(NewBrowserWindow), - "NewDiffBrowserDirs": reflect.ValueOf(NewDiffBrowserDirs), - "NewFileNode": reflect.ValueOf(NewFileNode), - "ParentBrowser": reflect.ValueOf(ParentBrowser), - "PromptOKCancel": reflect.ValueOf(PromptOKCancel), - "PromptString": reflect.ValueOf(PromptString), - "PromptStruct": reflect.ValueOf(PromptStruct), - "Symbols": reflect.ValueOf(&Symbols).Elem(), - "TheBrowser": reflect.ValueOf(&TheBrowser).Elem(), - "TrimOrderPrefix": reflect.ValueOf(TrimOrderPrefix), - - // type definitions - "Browser": reflect.ValueOf((*Browser)(nil)), - "FileNode": reflect.ValueOf((*FileNode)(nil)), - } -} diff --git a/numbers/databrowser/datatab.go b/numbers/databrowser/datatab.go deleted file mode 100644 index 330ea6ea..00000000 --- a/numbers/databrowser/datatab.go +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (c) 2024, Cogent Core. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package databrowser - -import ( - "fmt" - "strings" - - "cogentcore.org/core/base/errors" - "cogentcore.org/core/base/iox/tomlx" - "cogentcore.org/core/core" - "cogentcore.org/core/plot/plotcore" - "cogentcore.org/core/shell/cosh" - "cogentcore.org/core/styles" - "cogentcore.org/core/tensor" - "cogentcore.org/core/tensor/table" - "cogentcore.org/core/tensor/tensorcore" - "cogentcore.org/core/texteditor" -) - -// NewTabTensorTable creates a tab with a tensor table and a tensorcore table. -// Use tv.Table.Table to get the underlying *table.Table -// and tv.Table is the table.IndexView onto the table. -// Use tv.Table.Sequential to update the IndexView to view -// all of the rows when done updating the Table, and then call br.Update() -func (br *Browser) NewTabTensorTable(label string) *tensorcore.Table { - tabs := br.Tabs() - tab := tabs.RecycleTab(label) - if tab.HasChildren() { - tv := tab.Child(1).(*tensorcore.Table) - return tv - } - dt := table.NewTable() - tb := core.NewToolbar(tab) - tv := tensorcore.NewTable(tab) - tv.SetReadOnlyMultiSelect(true) - tv.Styler(func(s *styles.Style) { - s.SetReadOnly(true) // todo: not taking effect - }) - tb.Maker(tv.MakeToolbar) - tv.SetTable(dt) - br.Update() - return tv -} - -// NewTabTable creates a tab with a slice Table. -// Sets the slice if tab already exists -func (br *Browser) NewTabTable(label string, slc any) *core.Table { - tabs := br.Tabs() - tab := tabs.RecycleTab(label) - if tab.HasChildren() { - tv := tab.Child(0).(*core.Table) - tv.SetSlice(slc) - return tv - } - tv := core.NewTable(tab) - tv.SetReadOnlyMultiSelect(true) - tv.Styler(func(s *styles.Style) { - s.SetReadOnly(true) // todo: not taking effect - }) - tv.SetSlice(slc) - br.Update() - return tv -} - -// NewTabPlot creates a tab with a SubPlot PlotEditor. -// Set the table and call br.Update after this. -func (br *Browser) NewTabPlot(label string) *plotcore.PlotEditor { - tabs := br.Tabs() - tab := tabs.RecycleTab(label) - if tab.HasChildren() { - pl := tab.Child(0).AsTree().Child(1).(*plotcore.PlotEditor) - return pl - } - pl := plotcore.NewSubPlot(tab) - return pl -} - -// NewTabEditorString opens an editor tab to display given string -func (br *Browser) NewTabEditorString(label, content string) *texteditor.Editor { - tabs := br.Tabs() - tab := tabs.RecycleTab(label) - if tab.HasChildren() { - ed := tab.Child(0).(*texteditor.Editor) - ed.Buffer.SetText([]byte(content)) - return ed - } - ed := texteditor.NewEditor(tab) - ed.Styler(func(s *styles.Style) { - s.Grow.Set(1, 1) - }) - ed.Buffer.SetText([]byte(content)) - br.Update() - return ed -} - -// FormatTableFromCSV formats the columns of the given table according to the -// Name, Type values in given format CSV file. -func (br *Browser) FormatTableFromCSV(dt *table.Table, format string) error { - ft := table.NewTable() - if err := errors.Log(ft.OpenCSV(core.Filename(format), table.Comma)); err != nil { - return err - } - // todo: need a config mode for this! - for i := range ft.Rows { - name := ft.StringValue("Name", i) - typ := ft.StringValue("Type", i) - switch typ { - case "string": - dt.AddStringColumn(name) - case "time": - dt.AddIntColumn(name) - } - } - return nil -} - -// OpenTOML opens given .toml formatted file with name = value -// entries, as a map. -func (br *Browser) OpenTOML(filename string) (map[string]string, error) { - md := make(map[string]string) - err := tomlx.Open(&md, filename) - errors.Log(err) - return md, err -} - -// TableWithNewKeyColumns returns a copy of the Table with new columns -// having given values, inserted at the start, used as legend keys etc. -// args are column name, value pairs. -func (br *Browser) TableWithNewKeyColumns(dt *table.Table, args ...string) *table.Table { - n := len(args) - if n%2 != 0 { - fmt.Println("TableWithNewColumns requires even number of args as colnm, value pairs") - return dt - } - c := dt.Clone() - nc := n / 2 - for j := 0; j < nc; j++ { - colNm := args[2*j] - val := args[2*j+1] - col := tensor.NewString([]int{c.Rows}) - c.InsertColumn(col, colNm, 0) - for i := range col.Values { - col.Values[i] = val - } - } - return c -} - -// FirstComment returns the first comment lines from given .cosh file, -// which is used to set the tooltip for scripts. -func FirstComment(sc string) string { - sl := cosh.SplitLines(sc) - cmt := "" - for _, l := range sl { - if !strings.HasPrefix(l, "// ") { - return cmt - } - cmt += strings.TrimSpace(l[3:]) + " " - } - return cmt -} diff --git a/numbers/databrowser/filetree.go b/numbers/databrowser/filetree.go deleted file mode 100644 index b54e68ae..00000000 --- a/numbers/databrowser/filetree.go +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright (c) 2024, Cogent Core. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package databrowser - -import ( - "log" - "strings" - - "cogentcore.org/core/base/fileinfo" - "cogentcore.org/core/base/fsx" - "cogentcore.org/core/core" - "cogentcore.org/core/events" - "cogentcore.org/core/filetree" - "cogentcore.org/core/icons" - "cogentcore.org/core/styles" - "cogentcore.org/core/styles/states" - "cogentcore.org/core/tensor/table" - "cogentcore.org/core/texteditor" - "cogentcore.org/core/texteditor/diffbrowser" -) - -// FileNode is Code version of FileNode for FileTree -type FileNode struct { - filetree.Node -} - -func (fn *FileNode) Init() { - fn.Node.Init() - fn.AddContextMenu(fn.ContextMenu) -} - -func (fn *FileNode) OnDoubleClick(e events.Event) { - e.SetHandled() - br, ok := ParentBrowser(fn.This) - if !ok { - return - } - sels := fn.GetSelectedNodes() - if len(sels) > 0 { - sn := filetree.AsNode(sels[len(sels)-1]) - if sn != nil { - if sn.IsDir() { - if !sn.HasChildren() { - // sn.OpenEmptyDir() TODO(filetree) - } else { - sn.ToggleClose() - } - } else { - br.FileNodeOpened(sn) - } - } - } -} - -func (br *Browser) FileNodeOpened(fn *filetree.Node) { - // fmt.Println("opened:", fn.FPath) - df := fsx.DirAndFile(string(fn.Filepath)) - switch { - case fn.Info.Cat == fileinfo.Data: - df := fsx.DirAndFile(string(fn.Filepath)) - tv := br.NewTabTensorTable(df) - dt := tv.Table.Table - err := dt.OpenCSV(fn.Filepath, table.Tab) // todo: need more flexible data handling mode - tv.Table.Sequential() - br.Update() - if err != nil { - core.ErrorSnackbar(br, err) - } - case fn.IsExec(): // todo: use exec? - fn.OpenFilesDefault() - case fn.Info.Cat == fileinfo.Video: // todo: use our video viewer - fn.OpenFilesDefault() - case fn.Info.Cat == fileinfo.Audio: // todo: use our audio viewer - fn.OpenFilesDefault() - case fn.Info.Cat == fileinfo.Image: // todo: use our image viewer - fn.OpenFilesDefault() - case fn.Info.Cat == fileinfo.Model: // todo: use xyz - fn.OpenFilesDefault() - case fn.Info.Cat == fileinfo.Sheet: // todo: use our spreadsheet :) - fn.OpenFilesDefault() - case fn.Info.Cat == fileinfo.Bin: // don't edit - fn.OpenFilesDefault() - case fn.Info.Cat == fileinfo.Archive || fn.Info.Cat == fileinfo.Backup: // don't edit - fn.OpenFilesDefault() - default: - br.NewTabEditor(df, string(fn.Filepath)) - } -} - -func (br *Browser) FileNodeSelected(fn *filetree.Node) { - // todo: anything? -} - -// NewTabEditor opens an editor tab for given file -func (br *Browser) NewTabEditor(label, filename string) *texteditor.Editor { - tabs := br.Tabs() - tab := tabs.RecycleTab(label) - if tab.HasChildren() { - ed := tab.Child(0).(*texteditor.Editor) - ed.Buffer.Open(core.Filename(filename)) - return ed - } - ed := texteditor.NewEditor(tab) - ed.Styler(func(s *styles.Style) { - s.Grow.Set(1, 1) - }) - ed.Buffer.Open(core.Filename(filename)) - br.Update() - return ed -} - -// EditFiles calls EditFile on selected files -func (fn *FileNode) EditFiles() { //types:add - fn.SelectedFunc(func(sn *filetree.Node) { - sn.This.(*FileNode).EditFile() - }) -} - -// EditFile pulls up this file in Code -func (fn *FileNode) EditFile() { - if fn.IsDir() { - log.Printf("FileNode Edit -- cannot view (edit) directories!\n") - return - } - br, ok := ParentBrowser(fn.This) - if ok { - df := fsx.DirAndFile(string(fn.Filepath)) - br.NewTabEditor(df, string(fn.Filepath)) - } -} - -// PlotFiles calls PlotFile on selected files -func (fn *FileNode) PlotFiles() { //types:add - fn.SelectedFunc(func(sn *filetree.Node) { - sn.This.(*FileNode).PlotFile() - }) -} - -// PlotFile pulls up this file in Code -func (fn *FileNode) PlotFile() { - if fn.IsDir() { - return - } - br, ok := ParentBrowser(fn.This) - if ok { - df := fsx.DirAndFile(string(fn.Filepath)) - pl := br.NewTabPlot(df) - - dt := table.NewTable() - err := dt.OpenCSV(fn.Filepath, table.Tab) - if err != nil { - core.ErrorSnackbar(br, err) - } - pl.SetTable(dt) - pl.Options.Title = df - br.Update() - } -} - -// DiffDirs displays a browser with differences between two selected directories -func (fn *FileNode) DiffDirs() { //types:add - var da, db *filetree.Node - fn.SelectedFunc(func(sn *filetree.Node) { - if sn.IsDir() { - if da == nil { - da = sn - } else if db == nil { - db = sn - } - } - }) - if da == nil || db == nil { - core.MessageSnackbar(fn, "DiffDirs requires two selected directories") - return - } - NewDiffBrowserDirs(string(da.Filepath), string(db.Filepath)) -} - -// NewDiffBrowserDirs returns a new diff browser for files that differ -// within the two given directories. Excludes Job and .tsv data files. -func NewDiffBrowserDirs(pathA, pathB string) { - brow, b := diffbrowser.NewBrowserWindow() - brow.DiffDirs(pathA, pathB, func(fname string) bool { - if IsTableFile(fname) { - return true - } - if strings.HasPrefix(fname, "job.") || fname == "dbmeta.toml" { - return true - } - return false - }) - b.RunWindow() -} - -func IsTableFile(fname string) bool { - return strings.HasSuffix(fname, ".tsv") || strings.HasSuffix(fname, ".csv") -} - -func (fn *FileNode) ContextMenu(m *core.Scene) { - core.NewFuncButton(m).SetFunc(fn.EditFiles).SetText("Edit").SetIcon(icons.Edit). - Styler(func(s *styles.Style) { - s.SetState(!fn.HasSelection(), states.Disabled) - }) - core.NewFuncButton(m).SetFunc(fn.PlotFiles).SetText("Plot").SetIcon(icons.Edit). - Styler(func(s *styles.Style) { - s.SetState(!fn.HasSelection() || fn.Info.Cat != fileinfo.Data, states.Disabled) - }) - core.NewFuncButton(m).SetFunc(fn.DiffDirs).SetText("Diff Dirs").SetIcon(icons.Edit). - Styler(func(s *styles.Style) { - s.SetState(!fn.HasSelection() || !fn.IsDir(), states.Disabled) - }) -} diff --git a/numbers/databrowser/prompt.go b/numbers/databrowser/prompt.go deleted file mode 100644 index d00d2a82..00000000 --- a/numbers/databrowser/prompt.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2024, Cogent Core. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package databrowser - -import ( - "cogentcore.org/core/core" - "cogentcore.org/core/events" - "cogentcore.org/core/styles" -) - -// PromptOKCancel prompts the user for whether to do something, -// calling the given function if the user clicks OK. -func PromptOKCancel(ctx core.Widget, prompt string, fun func()) { - d := core.NewBody(prompt) - d.AddBottomBar(func(bar *core.Frame) { - d.AddCancel(bar) - d.AddOK(bar).OnClick(func(e events.Event) { - if fun != nil { - fun() - } - }) - }) - d.RunDialog(ctx) -} - -// PromptString prompts the user for a string value (initial value given), -// calling the given function if the user clicks OK. -func PromptString(ctx core.Widget, str string, prompt string, fun func(s string)) { - d := core.NewBody(prompt) - tf := core.NewTextField(d).SetText(str) - tf.Styler(func(s *styles.Style) { - s.Min.X.Ch(60) - }) - d.AddBottomBar(func(bar *core.Frame) { - d.AddCancel(bar) - d.AddOK(bar).OnClick(func(e events.Event) { - if fun != nil { - fun(tf.Text()) - } - }) - }) - d.RunDialog(ctx) -} - -// PromptStruct prompts the user for the values in given struct (pass a pointer), -// calling the given function if the user clicks OK. -func PromptStruct(ctx core.Widget, str any, prompt string, fun func()) { - d := core.NewBody(prompt) - core.NewForm(d).SetStruct(str) - d.AddBottomBar(func(bar *core.Frame) { - d.AddCancel(bar) - d.AddOK(bar).OnClick(func(e events.Event) { - if fun != nil { - fun() - } - }) - }) - d.RunDialog(ctx) -} diff --git a/numbers/databrowser/typegen.go b/numbers/databrowser/typegen.go deleted file mode 100644 index e8da5b1c..00000000 --- a/numbers/databrowser/typegen.go +++ /dev/null @@ -1,38 +0,0 @@ -// Code generated by "core generate"; DO NOT EDIT. - -package databrowser - -import ( - "cogentcore.org/core/tree" - "cogentcore.org/core/types" -) - -var _ = types.AddType(&types.Type{Name: "cogentcore.org/cogent/numbers/databrowser.Browser", IDName: "browser", Doc: "Browser is a data browser, for browsing data typically organized into\nseparate directories, with .cosh Scripts as toolbar actions to perform\nregular tasks on the data.\nScripts are ordered alphabetically and any leading #- prefix is automatically\nremoved from the label, so you can use numbers to specify a custom order.", Methods: []types.Method{{Name: "UpdateFiles", Doc: "UpdateFiles Updates the file picker with current files in DataRoot,", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "UpdateScripts", Doc: "UpdateScripts updates the Scripts and updates the toolbar.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}}, Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "DataRoot", Doc: "DataRoot is the path to the root of the data to browse"}, {Name: "StartDir", Doc: "StartDir is the starting directory, where the numbers app\nwas originally started."}, {Name: "ScriptsDir", Doc: "ScriptsDir is the directory containing scripts for toolbar actions.\nIt defaults to DataDir/dbscripts"}, {Name: "Scripts", Doc: "Scripts"}, {Name: "ScriptInterp", Doc: "ScriptInterp is the interpreter to use for running Browser scripts"}}}) - -// NewBrowser returns a new [Browser] with the given optional parent: -// Browser is a data browser, for browsing data typically organized into -// separate directories, with .cosh Scripts as toolbar actions to perform -// regular tasks on the data. -// Scripts are ordered alphabetically and any leading #- prefix is automatically -// removed from the label, so you can use numbers to specify a custom order. -func NewBrowser(parent ...tree.Node) *Browser { return tree.New[Browser](parent...) } - -// SetDataRoot sets the [Browser.DataRoot]: -// DataRoot is the path to the root of the data to browse -func (t *Browser) SetDataRoot(v string) *Browser { t.DataRoot = v; return t } - -// SetStartDir sets the [Browser.StartDir]: -// StartDir is the starting directory, where the numbers app -// was originally started. -func (t *Browser) SetStartDir(v string) *Browser { t.StartDir = v; return t } - -// SetScriptsDir sets the [Browser.ScriptsDir]: -// ScriptsDir is the directory containing scripts for toolbar actions. -// It defaults to DataDir/dbscripts -func (t *Browser) SetScriptsDir(v string) *Browser { t.ScriptsDir = v; return t } - -var _ = types.AddType(&types.Type{Name: "cogentcore.org/cogent/numbers/databrowser.FileNode", IDName: "file-node", Doc: "FileNode is Code version of FileNode for FileTree", Methods: []types.Method{{Name: "EditFiles", Doc: "EditFiles calls EditFile on selected files", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "PlotFiles", Doc: "PlotFiles calls PlotFile on selected files", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "DiffDirs", Doc: "DiffDirs displays a browser with differences between two selected directories", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}}, Embeds: []types.Field{{Name: "Node"}}}) - -// NewFileNode returns a new [FileNode] with the given optional parent: -// FileNode is Code version of FileNode for FileTree -func NewFileNode(parent ...tree.Node) *FileNode { return tree.New[FileNode](parent...) } diff --git a/numbers/imports/cogentcore_org-core-tensor-bitslice.go b/numbers/imports/cogentcore_org-core-tensor-bitslice.go deleted file mode 100644 index 5103ae05..00000000 --- a/numbers/imports/cogentcore_org-core-tensor-bitslice.go +++ /dev/null @@ -1,19 +0,0 @@ -// Code generated by 'yaegi extract cogentcore.org/core/tensor/bitslice'. DO NOT EDIT. - -package imports - -import ( - "cogentcore.org/core/tensor/bitslice" - "reflect" -) - -func init() { - Symbols["cogentcore.org/core/tensor/bitslice/bitslice"] = map[string]reflect.Value{ - // function, constant and variable definitions - "BitIndex": reflect.ValueOf(bitslice.BitIndex), - "Make": reflect.ValueOf(bitslice.Make), - - // type definitions - "Slice": reflect.ValueOf((*bitslice.Slice)(nil)), - } -} diff --git a/numbers/imports/cogentcore_org-core-tensor-stats-clust.go b/numbers/imports/cogentcore_org-core-tensor-stats-clust.go deleted file mode 100644 index 27f97709..00000000 --- a/numbers/imports/cogentcore_org-core-tensor-stats-clust.go +++ /dev/null @@ -1,36 +0,0 @@ -// Code generated by 'yaegi extract cogentcore.org/core/tensor/stats/clust'. DO NOT EDIT. - -package imports - -import ( - "cogentcore.org/core/tensor/stats/clust" - "reflect" -) - -func init() { - Symbols["cogentcore.org/core/tensor/stats/clust/clust"] = map[string]reflect.Value{ - // function, constant and variable definitions - "Avg": reflect.ValueOf(clust.Avg), - "AvgDist": reflect.ValueOf(clust.AvgDist), - "Contrast": reflect.ValueOf(clust.Contrast), - "ContrastDist": reflect.ValueOf(clust.ContrastDist), - "Glom": reflect.ValueOf(clust.Glom), - "GlomClust": reflect.ValueOf(clust.GlomClust), - "GlomInit": reflect.ValueOf(clust.GlomInit), - "GlomStd": reflect.ValueOf(clust.GlomStd), - "Max": reflect.ValueOf(clust.Max), - "MaxDist": reflect.ValueOf(clust.MaxDist), - "Min": reflect.ValueOf(clust.Min), - "MinDist": reflect.ValueOf(clust.MinDist), - "NewNode": reflect.ValueOf(clust.NewNode), - "Plot": reflect.ValueOf(clust.Plot), - "StdDistsN": reflect.ValueOf(clust.StdDistsN), - "StdDistsValues": reflect.ValueOf(clust.StdDistsValues), - "StdFunc": reflect.ValueOf(clust.StdFunc), - - // type definitions - "DistFunc": reflect.ValueOf((*clust.DistFunc)(nil)), - "Node": reflect.ValueOf((*clust.Node)(nil)), - "StdDists": reflect.ValueOf((*clust.StdDists)(nil)), - } -} diff --git a/numbers/imports/cogentcore_org-core-tensor-stats-convolve.go b/numbers/imports/cogentcore_org-core-tensor-stats-convolve.go deleted file mode 100644 index eeb11d8a..00000000 --- a/numbers/imports/cogentcore_org-core-tensor-stats-convolve.go +++ /dev/null @@ -1,19 +0,0 @@ -// Code generated by 'yaegi extract cogentcore.org/core/tensor/stats/convolve'. DO NOT EDIT. - -package imports - -import ( - "cogentcore.org/core/tensor/stats/convolve" - "reflect" -) - -func init() { - Symbols["cogentcore.org/core/tensor/stats/convolve/convolve"] = map[string]reflect.Value{ - // function, constant and variable definitions - "GaussianKernel32": reflect.ValueOf(convolve.GaussianKernel32), - "GaussianKernel64": reflect.ValueOf(convolve.GaussianKernel64), - "Slice32": reflect.ValueOf(convolve.Slice32), - "Slice64": reflect.ValueOf(convolve.Slice64), - "SmoothTable": reflect.ValueOf(convolve.SmoothTable), - } -} diff --git a/numbers/imports/cogentcore_org-core-tensor-stats-histogram.go b/numbers/imports/cogentcore_org-core-tensor-stats-histogram.go deleted file mode 100644 index a273277b..00000000 --- a/numbers/imports/cogentcore_org-core-tensor-stats-histogram.go +++ /dev/null @@ -1,18 +0,0 @@ -// Code generated by 'yaegi extract cogentcore.org/core/tensor/stats/histogram'. DO NOT EDIT. - -package imports - -import ( - "cogentcore.org/core/tensor/stats/histogram" - "reflect" -) - -func init() { - Symbols["cogentcore.org/core/tensor/stats/histogram/histogram"] = map[string]reflect.Value{ - // function, constant and variable definitions - "F32": reflect.ValueOf(histogram.F32), - "F32Table": reflect.ValueOf(histogram.F32Table), - "F64": reflect.ValueOf(histogram.F64), - "F64Table": reflect.ValueOf(histogram.F64Table), - } -} diff --git a/numbers/imports/cogentcore_org-core-tensor-stats-metric.go b/numbers/imports/cogentcore_org-core-tensor-stats-metric.go deleted file mode 100644 index 826f4248..00000000 --- a/numbers/imports/cogentcore_org-core-tensor-stats-metric.go +++ /dev/null @@ -1,69 +0,0 @@ -// Code generated by 'yaegi extract cogentcore.org/core/tensor/stats/metric'. DO NOT EDIT. - -package imports - -import ( - "cogentcore.org/core/tensor/stats/metric" - "reflect" -) - -func init() { - Symbols["cogentcore.org/core/tensor/stats/metric/metric"] = map[string]reflect.Value{ - // function, constant and variable definitions - "Abs": reflect.ValueOf(metric.Abs), - "Abs32": reflect.ValueOf(metric.Abs32), - "Abs64": reflect.ValueOf(metric.Abs64), - "ClosestRow32": reflect.ValueOf(metric.ClosestRow32), - "ClosestRow32Py": reflect.ValueOf(metric.ClosestRow32Py), - "ClosestRow64": reflect.ValueOf(metric.ClosestRow64), - "ClosestRow64Py": reflect.ValueOf(metric.ClosestRow64Py), - "Correlation": reflect.ValueOf(metric.Correlation), - "Correlation32": reflect.ValueOf(metric.Correlation32), - "Correlation64": reflect.ValueOf(metric.Correlation64), - "Cosine": reflect.ValueOf(metric.Cosine), - "Cosine32": reflect.ValueOf(metric.Cosine32), - "Cosine64": reflect.ValueOf(metric.Cosine64), - "Covariance": reflect.ValueOf(metric.Covariance), - "Covariance32": reflect.ValueOf(metric.Covariance32), - "Covariance64": reflect.ValueOf(metric.Covariance64), - "CrossEntropy": reflect.ValueOf(metric.CrossEntropy), - "CrossEntropy32": reflect.ValueOf(metric.CrossEntropy32), - "CrossEntropy64": reflect.ValueOf(metric.CrossEntropy64), - "Euclidean": reflect.ValueOf(metric.Euclidean), - "Euclidean32": reflect.ValueOf(metric.Euclidean32), - "Euclidean64": reflect.ValueOf(metric.Euclidean64), - "EuclideanBinTol": reflect.ValueOf(metric.EuclideanBinTol), - "EuclideanBinTol32": reflect.ValueOf(metric.EuclideanBinTol32), - "EuclideanBinTol64": reflect.ValueOf(metric.EuclideanBinTol64), - "Hamming": reflect.ValueOf(metric.Hamming), - "Hamming32": reflect.ValueOf(metric.Hamming32), - "Hamming64": reflect.ValueOf(metric.Hamming64), - "Increasing": reflect.ValueOf(metric.Increasing), - "InnerProduct": reflect.ValueOf(metric.InnerProduct), - "InnerProduct32": reflect.ValueOf(metric.InnerProduct32), - "InnerProduct64": reflect.ValueOf(metric.InnerProduct64), - "InvCorrelation": reflect.ValueOf(metric.InvCorrelation), - "InvCorrelation32": reflect.ValueOf(metric.InvCorrelation32), - "InvCorrelation64": reflect.ValueOf(metric.InvCorrelation64), - "InvCosine": reflect.ValueOf(metric.InvCosine), - "InvCosine32": reflect.ValueOf(metric.InvCosine32), - "InvCosine64": reflect.ValueOf(metric.InvCosine64), - "StdFunc32": reflect.ValueOf(metric.StdFunc32), - "StdFunc64": reflect.ValueOf(metric.StdFunc64), - "StdMetricsN": reflect.ValueOf(metric.StdMetricsN), - "StdMetricsValues": reflect.ValueOf(metric.StdMetricsValues), - "SumSquares": reflect.ValueOf(metric.SumSquares), - "SumSquares32": reflect.ValueOf(metric.SumSquares32), - "SumSquares64": reflect.ValueOf(metric.SumSquares64), - "SumSquaresBinTol": reflect.ValueOf(metric.SumSquaresBinTol), - "SumSquaresBinTol32": reflect.ValueOf(metric.SumSquaresBinTol32), - "SumSquaresBinTol64": reflect.ValueOf(metric.SumSquaresBinTol64), - "Tolerance32": reflect.ValueOf(metric.Tolerance32), - "Tolerance64": reflect.ValueOf(metric.Tolerance64), - - // type definitions - "Func32": reflect.ValueOf((*metric.Func32)(nil)), - "Func64": reflect.ValueOf((*metric.Func64)(nil)), - "StdMetrics": reflect.ValueOf((*metric.StdMetrics)(nil)), - } -} diff --git a/numbers/imports/cogentcore_org-core-tensor-stats-norm.go b/numbers/imports/cogentcore_org-core-tensor-stats-norm.go deleted file mode 100644 index 948ca0f6..00000000 --- a/numbers/imports/cogentcore_org-core-tensor-stats-norm.go +++ /dev/null @@ -1,43 +0,0 @@ -// Code generated by 'yaegi extract cogentcore.org/core/tensor/stats/norm'. DO NOT EDIT. - -package imports - -import ( - "cogentcore.org/core/tensor/stats/norm" - "reflect" -) - -func init() { - Symbols["cogentcore.org/core/tensor/stats/norm/norm"] = map[string]reflect.Value{ - // function, constant and variable definitions - "Abs32": reflect.ValueOf(norm.Abs32), - "Abs64": reflect.ValueOf(norm.Abs64), - "AbsTensor": reflect.ValueOf(norm.AbsTensor), - "AddVec64": reflect.ValueOf(norm.AddVec64), - "AddVector32": reflect.ValueOf(norm.AddVector32), - "Binarize32": reflect.ValueOf(norm.Binarize32), - "Binarize64": reflect.ValueOf(norm.Binarize64), - "DivNorm32": reflect.ValueOf(norm.DivNorm32), - "DivNorm64": reflect.ValueOf(norm.DivNorm64), - "FloatFunc": reflect.ValueOf(norm.FloatFunc), - "FloatOnlyError": reflect.ValueOf(norm.FloatOnlyError), - "MultVec64": reflect.ValueOf(norm.MultVec64), - "MultVector32": reflect.ValueOf(norm.MultVector32), - "SubNorm32": reflect.ValueOf(norm.SubNorm32), - "SubNorm64": reflect.ValueOf(norm.SubNorm64), - "TensorDivNorm": reflect.ValueOf(norm.TensorDivNorm), - "TensorSubNorm": reflect.ValueOf(norm.TensorSubNorm), - "TensorUnit": reflect.ValueOf(norm.TensorUnit), - "TensorZScore": reflect.ValueOf(norm.TensorZScore), - "Thresh32": reflect.ValueOf(norm.Thresh32), - "Thresh64": reflect.ValueOf(norm.Thresh64), - "Unit32": reflect.ValueOf(norm.Unit32), - "Unit64": reflect.ValueOf(norm.Unit64), - "ZScore32": reflect.ValueOf(norm.ZScore32), - "ZScore64": reflect.ValueOf(norm.ZScore64), - - // type definitions - "Func32": reflect.ValueOf((*norm.Func32)(nil)), - "Func64": reflect.ValueOf((*norm.Func64)(nil)), - } -} diff --git a/numbers/imports/cogentcore_org-core-tensor-stats-pca.go b/numbers/imports/cogentcore_org-core-tensor-stats-pca.go deleted file mode 100644 index 1068c84e..00000000 --- a/numbers/imports/cogentcore_org-core-tensor-stats-pca.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by 'yaegi extract cogentcore.org/core/tensor/stats/pca'. DO NOT EDIT. - -package imports - -import ( - "cogentcore.org/core/tensor/stats/pca" - "reflect" -) - -func init() { - Symbols["cogentcore.org/core/tensor/stats/pca/pca"] = map[string]reflect.Value{ - // function, constant and variable definitions - "CovarTableColumn": reflect.ValueOf(pca.CovarTableColumn), - "CovarTableColumnStd": reflect.ValueOf(pca.CovarTableColumnStd), - "CovarTensor": reflect.ValueOf(pca.CovarTensor), - "CovarTensorStd": reflect.ValueOf(pca.CovarTensorStd), - "TableColumnRowsVec": reflect.ValueOf(pca.TableColumnRowsVec), - "TensorRowsVec": reflect.ValueOf(pca.TensorRowsVec), - - // type definitions - "PCA": reflect.ValueOf((*pca.PCA)(nil)), - "SVD": reflect.ValueOf((*pca.SVD)(nil)), - } -} diff --git a/numbers/imports/cogentcore_org-core-tensor-stats-simat.go b/numbers/imports/cogentcore_org-core-tensor-stats-simat.go deleted file mode 100644 index 209ca695..00000000 --- a/numbers/imports/cogentcore_org-core-tensor-stats-simat.go +++ /dev/null @@ -1,23 +0,0 @@ -// Code generated by 'yaegi extract cogentcore.org/core/tensor/stats/simat'. DO NOT EDIT. - -package imports - -import ( - "cogentcore.org/core/tensor/stats/simat" - "reflect" -) - -func init() { - Symbols["cogentcore.org/core/tensor/stats/simat/simat"] = map[string]reflect.Value{ - // function, constant and variable definitions - "BlankRepeat": reflect.ValueOf(simat.BlankRepeat), - "NewSimMat": reflect.ValueOf(simat.NewSimMat), - "Tensor": reflect.ValueOf(simat.Tensor), - "TensorStd": reflect.ValueOf(simat.TensorStd), - "Tensors": reflect.ValueOf(simat.Tensors), - "TensorsStd": reflect.ValueOf(simat.TensorsStd), - - // type definitions - "SimMat": reflect.ValueOf((*simat.SimMat)(nil)), - } -} diff --git a/numbers/imports/cogentcore_org-core-tensor-stats-split.go b/numbers/imports/cogentcore_org-core-tensor-stats-split.go deleted file mode 100644 index 66c660a6..00000000 --- a/numbers/imports/cogentcore_org-core-tensor-stats-split.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by 'yaegi extract cogentcore.org/core/tensor/stats/split'. DO NOT EDIT. - -package imports - -import ( - "cogentcore.org/core/tensor/stats/split" - "reflect" -) - -func init() { - Symbols["cogentcore.org/core/tensor/stats/split/split"] = map[string]reflect.Value{ - // function, constant and variable definitions - "AggAllNumericColumns": reflect.ValueOf(split.AggAllNumericColumns), - "AggColumn": reflect.ValueOf(split.AggColumn), - "AggIndex": reflect.ValueOf(split.AggIndex), - "All": reflect.ValueOf(split.All), - "DescColumn": reflect.ValueOf(split.DescColumn), - "DescIndex": reflect.ValueOf(split.DescIndex), - "GroupBy": reflect.ValueOf(split.GroupBy), - "GroupByFunc": reflect.ValueOf(split.GroupByFunc), - "GroupByIndex": reflect.ValueOf(split.GroupByIndex), - "Permuted": reflect.ValueOf(split.Permuted), - } -} diff --git a/numbers/imports/cogentcore_org-core-tensor-stats-stats.go b/numbers/imports/cogentcore_org-core-tensor-stats-stats.go deleted file mode 100644 index b1613632..00000000 --- a/numbers/imports/cogentcore_org-core-tensor-stats-stats.go +++ /dev/null @@ -1,167 +0,0 @@ -// Code generated by 'yaegi extract cogentcore.org/core/tensor/stats/stats'. DO NOT EDIT. - -package imports - -import ( - "cogentcore.org/core/tensor/stats/stats" - "reflect" -) - -func init() { - Symbols["cogentcore.org/core/tensor/stats/stats/stats"] = map[string]reflect.Value{ - // function, constant and variable definitions - "Count": reflect.ValueOf(stats.Count), - "Count32": reflect.ValueOf(stats.Count32), - "Count64": reflect.ValueOf(stats.Count64), - "CountColumn": reflect.ValueOf(stats.CountColumn), - "CountFunc": reflect.ValueOf(stats.CountFunc), - "CountIfColumn": reflect.ValueOf(stats.CountIfColumn), - "CountIfIndex": reflect.ValueOf(stats.CountIfIndex), - "CountIndex": reflect.ValueOf(stats.CountIndex), - "CountTensor": reflect.ValueOf(stats.CountTensor), - "DescAll": reflect.ValueOf(stats.DescAll), - "DescColumn": reflect.ValueOf(stats.DescColumn), - "DescIndex": reflect.ValueOf(stats.DescIndex), - "DescStats": reflect.ValueOf(&stats.DescStats).Elem(), - "DescStatsND": reflect.ValueOf(&stats.DescStatsND).Elem(), - "L1Norm": reflect.ValueOf(stats.L1Norm), - "L1Norm32": reflect.ValueOf(stats.L1Norm32), - "L1Norm64": reflect.ValueOf(stats.L1Norm64), - "L1NormColumn": reflect.ValueOf(stats.L1NormColumn), - "L1NormFunc": reflect.ValueOf(stats.L1NormFunc), - "L1NormIndex": reflect.ValueOf(stats.L1NormIndex), - "L1NormTensor": reflect.ValueOf(stats.L1NormTensor), - "L2Norm": reflect.ValueOf(stats.L2Norm), - "L2Norm32": reflect.ValueOf(stats.L2Norm32), - "L2Norm64": reflect.ValueOf(stats.L2Norm64), - "L2NormColumn": reflect.ValueOf(stats.L2NormColumn), - "L2NormIndex": reflect.ValueOf(stats.L2NormIndex), - "L2NormTensor": reflect.ValueOf(stats.L2NormTensor), - "Max": reflect.ValueOf(stats.Max), - "Max32": reflect.ValueOf(stats.Max32), - "Max64": reflect.ValueOf(stats.Max64), - "MaxAbs": reflect.ValueOf(stats.MaxAbs), - "MaxAbs32": reflect.ValueOf(stats.MaxAbs32), - "MaxAbs64": reflect.ValueOf(stats.MaxAbs64), - "MaxAbsColumn": reflect.ValueOf(stats.MaxAbsColumn), - "MaxAbsFunc": reflect.ValueOf(stats.MaxAbsFunc), - "MaxAbsIndex": reflect.ValueOf(stats.MaxAbsIndex), - "MaxAbsTensor": reflect.ValueOf(stats.MaxAbsTensor), - "MaxColumn": reflect.ValueOf(stats.MaxColumn), - "MaxFunc": reflect.ValueOf(stats.MaxFunc), - "MaxIndex": reflect.ValueOf(stats.MaxIndex), - "MaxIndex32": reflect.ValueOf(stats.MaxIndex32), - "MaxIndex64": reflect.ValueOf(stats.MaxIndex64), - "MaxTensor": reflect.ValueOf(stats.MaxTensor), - "Mean": reflect.ValueOf(stats.Mean), - "Mean32": reflect.ValueOf(stats.Mean32), - "Mean64": reflect.ValueOf(stats.Mean64), - "MeanColumn": reflect.ValueOf(stats.MeanColumn), - "MeanIndex": reflect.ValueOf(stats.MeanIndex), - "MeanTables": reflect.ValueOf(stats.MeanTables), - "MeanTensor": reflect.ValueOf(stats.MeanTensor), - "Median": reflect.ValueOf(stats.Median), - "MedianColumn": reflect.ValueOf(stats.MedianColumn), - "MedianIndex": reflect.ValueOf(stats.MedianIndex), - "Min": reflect.ValueOf(stats.Min), - "Min32": reflect.ValueOf(stats.Min32), - "Min64": reflect.ValueOf(stats.Min64), - "MinAbs": reflect.ValueOf(stats.MinAbs), - "MinAbs32": reflect.ValueOf(stats.MinAbs32), - "MinAbs64": reflect.ValueOf(stats.MinAbs64), - "MinAbsColumn": reflect.ValueOf(stats.MinAbsColumn), - "MinAbsFunc": reflect.ValueOf(stats.MinAbsFunc), - "MinAbsIndex": reflect.ValueOf(stats.MinAbsIndex), - "MinAbsTensor": reflect.ValueOf(stats.MinAbsTensor), - "MinColumn": reflect.ValueOf(stats.MinColumn), - "MinFunc": reflect.ValueOf(stats.MinFunc), - "MinIndex": reflect.ValueOf(stats.MinIndex), - "MinIndex32": reflect.ValueOf(stats.MinIndex32), - "MinIndex64": reflect.ValueOf(stats.MinIndex64), - "MinTensor": reflect.ValueOf(stats.MinTensor), - "PctIfColumn": reflect.ValueOf(stats.PctIfColumn), - "PctIfIndex": reflect.ValueOf(stats.PctIfIndex), - "Prod": reflect.ValueOf(stats.Prod), - "Prod32": reflect.ValueOf(stats.Prod32), - "Prod64": reflect.ValueOf(stats.Prod64), - "ProdColumn": reflect.ValueOf(stats.ProdColumn), - "ProdFunc": reflect.ValueOf(stats.ProdFunc), - "ProdIndex": reflect.ValueOf(stats.ProdIndex), - "ProdTensor": reflect.ValueOf(stats.ProdTensor), - "PropIfColumn": reflect.ValueOf(stats.PropIfColumn), - "PropIfIndex": reflect.ValueOf(stats.PropIfIndex), - "Q1": reflect.ValueOf(stats.Q1), - "Q1Column": reflect.ValueOf(stats.Q1Column), - "Q1Index": reflect.ValueOf(stats.Q1Index), - "Q3": reflect.ValueOf(stats.Q3), - "Q3Column": reflect.ValueOf(stats.Q3Column), - "Q3Index": reflect.ValueOf(stats.Q3Index), - "Quantiles": reflect.ValueOf(stats.Quantiles), - "QuantilesIndex": reflect.ValueOf(stats.QuantilesIndex), - "Sem": reflect.ValueOf(stats.Sem), - "Sem32": reflect.ValueOf(stats.Sem32), - "Sem64": reflect.ValueOf(stats.Sem64), - "SemColumn": reflect.ValueOf(stats.SemColumn), - "SemIndex": reflect.ValueOf(stats.SemIndex), - "SemPop": reflect.ValueOf(stats.SemPop), - "SemPop32": reflect.ValueOf(stats.SemPop32), - "SemPop64": reflect.ValueOf(stats.SemPop64), - "SemPopColumn": reflect.ValueOf(stats.SemPopColumn), - "SemPopIndex": reflect.ValueOf(stats.SemPopIndex), - "SemPopTensor": reflect.ValueOf(stats.SemPopTensor), - "SemTensor": reflect.ValueOf(stats.SemTensor), - "Stat32": reflect.ValueOf(stats.Stat32), - "Stat64": reflect.ValueOf(stats.Stat64), - "StatColumn": reflect.ValueOf(stats.StatColumn), - "StatIndex": reflect.ValueOf(stats.StatIndex), - "StatIndexFunc": reflect.ValueOf(stats.StatIndexFunc), - "StatTensor": reflect.ValueOf(stats.StatTensor), - "StatsN": reflect.ValueOf(stats.StatsN), - "StatsValues": reflect.ValueOf(stats.StatsValues), - "Std": reflect.ValueOf(stats.Std), - "Std32": reflect.ValueOf(stats.Std32), - "Std64": reflect.ValueOf(stats.Std64), - "StdColumn": reflect.ValueOf(stats.StdColumn), - "StdIndex": reflect.ValueOf(stats.StdIndex), - "StdPop": reflect.ValueOf(stats.StdPop), - "StdPop32": reflect.ValueOf(stats.StdPop32), - "StdPop64": reflect.ValueOf(stats.StdPop64), - "StdPopColumn": reflect.ValueOf(stats.StdPopColumn), - "StdPopIndex": reflect.ValueOf(stats.StdPopIndex), - "StdPopTensor": reflect.ValueOf(stats.StdPopTensor), - "StdTensor": reflect.ValueOf(stats.StdTensor), - "Sum": reflect.ValueOf(stats.Sum), - "Sum32": reflect.ValueOf(stats.Sum32), - "Sum64": reflect.ValueOf(stats.Sum64), - "SumColumn": reflect.ValueOf(stats.SumColumn), - "SumFunc": reflect.ValueOf(stats.SumFunc), - "SumIndex": reflect.ValueOf(stats.SumIndex), - "SumSq": reflect.ValueOf(stats.SumSq), - "SumSq32": reflect.ValueOf(stats.SumSq32), - "SumSq64": reflect.ValueOf(stats.SumSq64), - "SumSqColumn": reflect.ValueOf(stats.SumSqColumn), - "SumSqIndex": reflect.ValueOf(stats.SumSqIndex), - "SumSqTensor": reflect.ValueOf(stats.SumSqTensor), - "SumTensor": reflect.ValueOf(stats.SumTensor), - "TensorStat": reflect.ValueOf(stats.TensorStat), - "Var": reflect.ValueOf(stats.Var), - "Var32": reflect.ValueOf(stats.Var32), - "Var64": reflect.ValueOf(stats.Var64), - "VarColumn": reflect.ValueOf(stats.VarColumn), - "VarIndex": reflect.ValueOf(stats.VarIndex), - "VarPop": reflect.ValueOf(stats.VarPop), - "VarPop32": reflect.ValueOf(stats.VarPop32), - "VarPop64": reflect.ValueOf(stats.VarPop64), - "VarPopColumn": reflect.ValueOf(stats.VarPopColumn), - "VarPopIndex": reflect.ValueOf(stats.VarPopIndex), - "VarPopTensor": reflect.ValueOf(stats.VarPopTensor), - "VarTensor": reflect.ValueOf(stats.VarTensor), - - // type definitions - "IfFunc": reflect.ValueOf((*stats.IfFunc)(nil)), - "IndexViewFuncColumn": reflect.ValueOf((*stats.IndexViewFuncColumn)(nil)), - "IndexViewFuncIndex": reflect.ValueOf((*stats.IndexViewFuncIndex)(nil)), - "StatFunc": reflect.ValueOf((*stats.StatFunc)(nil)), - "Stats": reflect.ValueOf((*stats.Stats)(nil)), - } -} diff --git a/numbers/imports/cogentcore_org-core-tensor-table.go b/numbers/imports/cogentcore_org-core-tensor-table.go deleted file mode 100644 index ee1e2969..00000000 --- a/numbers/imports/cogentcore_org-core-tensor-table.go +++ /dev/null @@ -1,53 +0,0 @@ -// Code generated by 'yaegi extract cogentcore.org/core/tensor/table'. DO NOT EDIT. - -package imports - -import ( - "cogentcore.org/core/tensor/table" - "reflect" -) - -func init() { - Symbols["cogentcore.org/core/tensor/table/table"] = map[string]reflect.Value{ - // function, constant and variable definitions - "AddAggName": reflect.ValueOf(table.AddAggName), - "Ascending": reflect.ValueOf(table.Ascending), - "ColumnNameOnly": reflect.ValueOf(table.ColumnNameOnly), - "Comma": reflect.ValueOf(table.Comma), - "ConfigFromDataValues": reflect.ValueOf(table.ConfigFromDataValues), - "ConfigFromHeaders": reflect.ValueOf(table.ConfigFromHeaders), - "ConfigFromTableHeaders": reflect.ValueOf(table.ConfigFromTableHeaders), - "Contains": reflect.ValueOf(table.Contains), - "DelimsN": reflect.ValueOf(table.DelimsN), - "DelimsValues": reflect.ValueOf(table.DelimsValues), - "Descending": reflect.ValueOf(table.Descending), - "Detect": reflect.ValueOf(table.Detect), - "DetectTableHeaders": reflect.ValueOf(table.DetectTableHeaders), - "Equals": reflect.ValueOf(table.Equals), - "Headers": reflect.ValueOf(table.Headers), - "IgnoreCase": reflect.ValueOf(table.IgnoreCase), - "InferDataType": reflect.ValueOf(table.InferDataType), - "NewIndexView": reflect.ValueOf(table.NewIndexView), - "NewSliceTable": reflect.ValueOf(table.NewSliceTable), - "NewTable": reflect.ValueOf(table.NewTable), - "NoHeaders": reflect.ValueOf(table.NoHeaders), - "ShapeFromString": reflect.ValueOf(table.ShapeFromString), - "Space": reflect.ValueOf(table.Space), - "Tab": reflect.ValueOf(table.Tab), - "TableColumnType": reflect.ValueOf(table.TableColumnType), - "TableHeaderChar": reflect.ValueOf(table.TableHeaderChar), - "TableHeaderToType": reflect.ValueOf(&table.TableHeaderToType).Elem(), - "UpdateSliceTable": reflect.ValueOf(table.UpdateSliceTable), - "UseCase": reflect.ValueOf(table.UseCase), - - // type definitions - "Delims": reflect.ValueOf((*table.Delims)(nil)), - "Filterer": reflect.ValueOf((*table.Filterer)(nil)), - "IndexView": reflect.ValueOf((*table.IndexView)(nil)), - "LessFunc": reflect.ValueOf((*table.LessFunc)(nil)), - "SplitAgg": reflect.ValueOf((*table.SplitAgg)(nil)), - "Splits": reflect.ValueOf((*table.Splits)(nil)), - "SplitsLessFunc": reflect.ValueOf((*table.SplitsLessFunc)(nil)), - "Table": reflect.ValueOf((*table.Table)(nil)), - } -} diff --git a/numbers/imports/cogentcore_org-core-tensor-tensorcore.go b/numbers/imports/cogentcore_org-core-tensor-tensorcore.go deleted file mode 100644 index 5c0a57f4..00000000 --- a/numbers/imports/cogentcore_org-core-tensor-tensorcore.go +++ /dev/null @@ -1,33 +0,0 @@ -// Code generated by 'yaegi extract cogentcore.org/core/tensor/tensorcore'. DO NOT EDIT. - -package imports - -import ( - "cogentcore.org/core/tensor/tensorcore" - "reflect" -) - -func init() { - Symbols["cogentcore.org/core/tensor/tensorcore/tensorcore"] = map[string]reflect.Value{ - // function, constant and variable definitions - "LabelSpace": reflect.ValueOf(tensorcore.LabelSpace), - "NewSimMatButton": reflect.ValueOf(tensorcore.NewSimMatButton), - "NewSimMatGrid": reflect.ValueOf(tensorcore.NewSimMatGrid), - "NewTable": reflect.ValueOf(tensorcore.NewTable), - "NewTableButton": reflect.ValueOf(tensorcore.NewTableButton), - "NewTensorButton": reflect.ValueOf(tensorcore.NewTensorButton), - "NewTensorEditor": reflect.ValueOf(tensorcore.NewTensorEditor), - "NewTensorGrid": reflect.ValueOf(tensorcore.NewTensorGrid), - - // type definitions - "SimMatButton": reflect.ValueOf((*tensorcore.SimMatButton)(nil)), - "SimMatGrid": reflect.ValueOf((*tensorcore.SimMatGrid)(nil)), - "Table": reflect.ValueOf((*tensorcore.Table)(nil)), - "TableButton": reflect.ValueOf((*tensorcore.TableButton)(nil)), - "TensorButton": reflect.ValueOf((*tensorcore.TensorButton)(nil)), - "TensorDisplay": reflect.ValueOf((*tensorcore.TensorDisplay)(nil)), - "TensorEditor": reflect.ValueOf((*tensorcore.TensorEditor)(nil)), - "TensorGrid": reflect.ValueOf((*tensorcore.TensorGrid)(nil)), - "TensorLayout": reflect.ValueOf((*tensorcore.TensorLayout)(nil)), - } -} diff --git a/numbers/imports/cogentcore_org-core-tensor.go b/numbers/imports/cogentcore_org-core-tensor.go deleted file mode 100644 index 3a0df85f..00000000 --- a/numbers/imports/cogentcore_org-core-tensor.go +++ /dev/null @@ -1,166 +0,0 @@ -// Code generated by 'yaegi extract cogentcore.org/core/tensor'. DO NOT EDIT. - -package imports - -import ( - "cogentcore.org/core/tensor" - "gonum.org/v1/gonum/mat" - "reflect" -) - -func init() { - Symbols["cogentcore.org/core/tensor/tensor"] = map[string]reflect.Value{ - // function, constant and variable definitions - "AddShapes": reflect.ValueOf(tensor.AddShapes), - "BoolToFloat64": reflect.ValueOf(tensor.BoolToFloat64), - "ColMajorStrides": reflect.ValueOf(tensor.ColMajorStrides), - "CopyDense": reflect.ValueOf(tensor.CopyDense), - "EqualInts": reflect.ValueOf(tensor.EqualInts), - "Float64ToBool": reflect.ValueOf(tensor.Float64ToBool), - "Float64ToString": reflect.ValueOf(tensor.Float64ToString), - "NewBits": reflect.ValueOf(tensor.NewBits), - "NewBitsShape": reflect.ValueOf(tensor.NewBitsShape), - "NewByte": reflect.ValueOf(tensor.NewByte), - "NewFloat32": reflect.ValueOf(tensor.NewFloat32), - "NewFloat64": reflect.ValueOf(tensor.NewFloat64), - "NewInt": reflect.ValueOf(tensor.NewInt), - "NewInt32": reflect.ValueOf(tensor.NewInt32), - "NewOfType": reflect.ValueOf(tensor.NewOfType), - "NewShape": reflect.ValueOf(tensor.NewShape), - "NewString": reflect.ValueOf(tensor.NewString), - "NewStringShape": reflect.ValueOf(tensor.NewStringShape), - "OddColumn": reflect.ValueOf(tensor.OddColumn), - "OddRow": reflect.ValueOf(tensor.OddRow), - "OpenCSV": reflect.ValueOf(tensor.OpenCSV), - "Projection2DCoords": reflect.ValueOf(tensor.Projection2DCoords), - "Projection2DIndex": reflect.ValueOf(tensor.Projection2DIndex), - "Projection2DSet": reflect.ValueOf(tensor.Projection2DSet), - "Projection2DSetString": reflect.ValueOf(tensor.Projection2DSetString), - "Projection2DShape": reflect.ValueOf(tensor.Projection2DShape), - "Projection2DString": reflect.ValueOf(tensor.Projection2DString), - "Projection2DValue": reflect.ValueOf(tensor.Projection2DValue), - "ReadCSV": reflect.ValueOf(tensor.ReadCSV), - "RowMajorStrides": reflect.ValueOf(tensor.RowMajorStrides), - "SaveCSV": reflect.ValueOf(tensor.SaveCSV), - "StringToFloat64": reflect.ValueOf(tensor.StringToFloat64), - "WriteCSV": reflect.ValueOf(tensor.WriteCSV), - - // type definitions - "Bits": reflect.ValueOf((*tensor.Bits)(nil)), - "Shape": reflect.ValueOf((*tensor.Shape)(nil)), - "String": reflect.ValueOf((*tensor.String)(nil)), - "Tensor": reflect.ValueOf((*tensor.Tensor)(nil)), - - // interface wrapper definitions - "_Tensor": reflect.ValueOf((*_cogentcore_org_core_tensor_Tensor)(nil)), - } -} - -// _cogentcore_org_core_tensor_Tensor is an interface wrapper for Tensor type -type _cogentcore_org_core_tensor_Tensor struct { - IValue interface{} - WAt func(i int, j int) float64 - WClone func() tensor.Tensor - WCopyCellsFrom func(from tensor.Tensor, to int, start int, n int) - WCopyFrom func(from tensor.Tensor) - WCopyMetaData func(from tensor.Tensor) - WCopyShapeFrom func(from tensor.Tensor) - WDataType func() reflect.Kind - WDimSize func(dim int) int - WDims func() (r int, c int) - WFloat func(i []int) float64 - WFloat1D func(i int) float64 - WFloatRowCell func(row int, cell int) float64 - WFloats func(flt *[]float64) - WIsString func() bool - WLen func() int - WMetaData func(key string) (string, bool) - WMetaDataMap func() map[string]string - WNumDims func() int - WRange func() (min float64, max float64, minIndex int, maxIndex int) - WRowCellSize func() (rows int, cells int) - WSetFloat func(i []int, val float64) - WSetFloat1D func(i int, val float64) - WSetFloatRowCell func(row int, cell int, val float64) - WSetFloats func(vals []float64) - WSetMetaData func(key string, val string) - WSetNumRows func(rows int) - WSetShape func(sizes []int, names ...string) - WSetString func(i []int, val string) - WSetString1D func(i int, val string) - WSetStringRowCell func(row int, cell int, val string) - WSetZeros func() - WShape func() *tensor.Shape - WString func() string - WString1D func(i int) string - WStringRowCell func(row int, cell int) string - WStringValue func(i []int) string - WSubSpace func(offs []int) tensor.Tensor - WT func() mat.Matrix -} - -func (W _cogentcore_org_core_tensor_Tensor) At(i int, j int) float64 { return W.WAt(i, j) } -func (W _cogentcore_org_core_tensor_Tensor) Clone() tensor.Tensor { return W.WClone() } -func (W _cogentcore_org_core_tensor_Tensor) CopyCellsFrom(from tensor.Tensor, to int, start int, n int) { - W.WCopyCellsFrom(from, to, start, n) -} -func (W _cogentcore_org_core_tensor_Tensor) CopyFrom(from tensor.Tensor) { W.WCopyFrom(from) } -func (W _cogentcore_org_core_tensor_Tensor) CopyMetaData(from tensor.Tensor) { W.WCopyMetaData(from) } -func (W _cogentcore_org_core_tensor_Tensor) CopyShapeFrom(from tensor.Tensor) { W.WCopyShapeFrom(from) } -func (W _cogentcore_org_core_tensor_Tensor) DataType() reflect.Kind { return W.WDataType() } -func (W _cogentcore_org_core_tensor_Tensor) DimSize(dim int) int { return W.WDimSize(dim) } -func (W _cogentcore_org_core_tensor_Tensor) Dims() (r int, c int) { return W.WDims() } -func (W _cogentcore_org_core_tensor_Tensor) Float(i []int) float64 { return W.WFloat(i) } -func (W _cogentcore_org_core_tensor_Tensor) Float1D(i int) float64 { return W.WFloat1D(i) } -func (W _cogentcore_org_core_tensor_Tensor) FloatRowCell(row int, cell int) float64 { - return W.WFloatRowCell(row, cell) -} -func (W _cogentcore_org_core_tensor_Tensor) Floats(flt *[]float64) { W.WFloats(flt) } -func (W _cogentcore_org_core_tensor_Tensor) IsString() bool { return W.WIsString() } -func (W _cogentcore_org_core_tensor_Tensor) Len() int { return W.WLen() } -func (W _cogentcore_org_core_tensor_Tensor) MetaData(key string) (string, bool) { - return W.WMetaData(key) -} -func (W _cogentcore_org_core_tensor_Tensor) MetaDataMap() map[string]string { return W.WMetaDataMap() } -func (W _cogentcore_org_core_tensor_Tensor) NumDims() int { return W.WNumDims() } -func (W _cogentcore_org_core_tensor_Tensor) Range() (min float64, max float64, minIndex int, maxIndex int) { - return W.WRange() -} -func (W _cogentcore_org_core_tensor_Tensor) RowCellSize() (rows int, cells int) { - return W.WRowCellSize() -} -func (W _cogentcore_org_core_tensor_Tensor) SetFloat(i []int, val float64) { W.WSetFloat(i, val) } -func (W _cogentcore_org_core_tensor_Tensor) SetFloat1D(i int, val float64) { W.WSetFloat1D(i, val) } -func (W _cogentcore_org_core_tensor_Tensor) SetFloatRowCell(row int, cell int, val float64) { - W.WSetFloatRowCell(row, cell, val) -} -func (W _cogentcore_org_core_tensor_Tensor) SetFloats(vals []float64) { W.WSetFloats(vals) } -func (W _cogentcore_org_core_tensor_Tensor) SetMetaData(key string, val string) { - W.WSetMetaData(key, val) -} -func (W _cogentcore_org_core_tensor_Tensor) SetNumRows(rows int) { W.WSetNumRows(rows) } -func (W _cogentcore_org_core_tensor_Tensor) SetShape(sizes []int, names ...string) { - W.WSetShape(sizes, names...) -} -func (W _cogentcore_org_core_tensor_Tensor) SetString(i []int, val string) { W.WSetString(i, val) } -func (W _cogentcore_org_core_tensor_Tensor) SetString1D(i int, val string) { W.WSetString1D(i, val) } -func (W _cogentcore_org_core_tensor_Tensor) SetStringRowCell(row int, cell int, val string) { - W.WSetStringRowCell(row, cell, val) -} -func (W _cogentcore_org_core_tensor_Tensor) SetZeros() { W.WSetZeros() } -func (W _cogentcore_org_core_tensor_Tensor) Shape() *tensor.Shape { return W.WShape() } -func (W _cogentcore_org_core_tensor_Tensor) String() string { - if W.WString == nil { - return "" - } - return W.WString() -} -func (W _cogentcore_org_core_tensor_Tensor) String1D(i int) string { return W.WString1D(i) } -func (W _cogentcore_org_core_tensor_Tensor) StringRowCell(row int, cell int) string { - return W.WStringRowCell(row, cell) -} -func (W _cogentcore_org_core_tensor_Tensor) StringValue(i []int) string { return W.WStringValue(i) } -func (W _cogentcore_org_core_tensor_Tensor) SubSpace(offs []int) tensor.Tensor { - return W.WSubSpace(offs) -} -func (W _cogentcore_org_core_tensor_Tensor) T() mat.Matrix { return W.WT() } diff --git a/numbers/imports/core.go b/numbers/imports/core.go deleted file mode 100644 index 8e9884d6..00000000 --- a/numbers/imports/core.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2024, Cogent Core. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package imports - -//go:generate ./make - -import "reflect" - -var Symbols = map[string]map[string]reflect.Value{} diff --git a/numbers/imports/make b/numbers/imports/make deleted file mode 100755 index 2fd0ab61..00000000 --- a/numbers/imports/make +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env cosh - -yaegi extract cogentcore.org/core/tensor/bitslice cogentcore.org/core/tensor -yaegi extract cogentcore.org/core/tensor/table cogentcore.org/core/tensor/tensorcore -yaegi extract cogentcore.org/core/tensor/stats/clust cogentcore.org/core/tensor/stats/convolve cogentcore.org/core/tensor/stats/histogram cogentcore.org/core/tensor/stats/metric cogentcore.org/core/tensor/stats/norm cogentcore.org/core/tensor/stats/pca cogentcore.org/core/tensor/stats/simat cogentcore.org/core/tensor/stats/split cogentcore.org/core/tensor/stats/stats diff --git a/numbers/numshell/interp.go b/numbers/numshell/interp.go deleted file mode 100644 index 6acbf3ad..00000000 --- a/numbers/numshell/interp.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2024, Cogent Core. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package numshell - -import ( - "errors" - "io" - "log" - "os" - - "cogentcore.org/cogent/numbers/imports" - "cogentcore.org/core/shell" - "cogentcore.org/core/shell/interpreter" - "cogentcore.org/core/yaegicore/symbols" - "github.com/cogentcore/yaegi/interp" - "github.com/ergochat/readline" -) - -// NumbersInterpreter is the interpreter for Numbers app -type Interpreter struct { - interpreter.Interpreter -} - -func NewInterpreter(options interp.Options) *Interpreter { - in := &Interpreter{} - in.Interpreter = *interpreter.NewInterpreter(options) - in.InitInterp() - return in -} - -// InitInterp initializes the interpreter with symbols -func (in *Interpreter) InitInterp() { - in.Interp.Use(symbols.Symbols) - in.Interp.Use(imports.Symbols) -} - -// RunScript runs given script code on the interpreter -func (in *Interpreter) RunScript(script string) { - in.Interp.Eval(script) -} - -// Interactive runs an interactive shell that allows the user to input. -// Does not return until the interactive session ends. -func (in *Interpreter) Interactive() error { - in.Interp.ImportUsed() - in.RunConfig() - rl, err := readline.NewFromConfig(&readline.Config{ - AutoComplete: &shell.ReadlineCompleter{Shell: in.Shell}, - Undo: true, - }) - if err != nil { - return err - } - defer rl.Close() - log.SetOutput(rl.Stderr()) // redraw the prompt correctly after log output - - for { - rl.SetPrompt(in.Prompt()) - line, err := rl.ReadLine() - if errors.Is(err, readline.ErrInterrupt) { - continue - } - if errors.Is(err, io.EOF) { - os.Exit(0) - } - if err != nil { - return err - } - in.Eval(line) - } -} diff --git a/numbers/random/random.go b/numbers/random/random.go index 09ebf2ee..4a6d0e60 100644 --- a/numbers/random/random.go +++ b/numbers/random/random.go @@ -8,8 +8,6 @@ package random //go:generate core generate import ( - "strconv" - "cogentcore.org/core/base/randx" "cogentcore.org/core/core" "cogentcore.org/core/events" @@ -66,8 +64,8 @@ func (rd *Random) Init() { rd.NumSamples = 1000000 rd.NumBins = 100 rd.Range.Set(0, 1) - rd.Table = &table.Table{} - rd.Histogram = &table.Table{} + rd.Table = table.New() + rd.Histogram = table.New() rd.ConfigTable(rd.Table) rd.Plot() @@ -95,19 +93,19 @@ func (rd *Random) Plot() { //types:add dt.SetNumRows(rd.NumSamples) for vi := 0; vi < rd.NumSamples; vi++ { vl := rd.Dist.Gen() - dt.SetFloat("Value", vi, float64(vl)) + dt.Column("Value").SetFloat(float64(vl), vi) } - histogram.F64Table(rd.Histogram, dt.Columns[0].(*tensor.Float64).Values, rd.NumBins, rd.Range.Min, rd.Range.Max) + histogram.F64Table(rd.Histogram, dt.Columns.Values[0].(*tensor.Float64).Values, rd.NumBins, rd.Range.Min, rd.Range.Max) if rd.plot != nil { rd.plot.UpdatePlot() } } func (rd *Random) ConfigTable(dt *table.Table) { - dt.SetMetaData("name", "Data") - dt.SetMetaData("read-only", "true") - dt.SetMetaData("precision", strconv.Itoa(logPrec)) + dt.Meta.SetName("Data") + dt.Meta.Set("read-only", true) + tensor.SetPrecision(dt.Meta, logPrec) dt.AddFloat64Column("Value") } diff --git a/terminal/app.go b/terminal/app.go index 9627fd96..9e0ea119 100644 --- a/terminal/app.go +++ b/terminal/app.go @@ -22,9 +22,9 @@ import ( "cogentcore.org/core/colors" "cogentcore.org/core/core" "cogentcore.org/core/events" + "cogentcore.org/core/goal/interpreter" "cogentcore.org/core/icons" "cogentcore.org/core/keymap" - "cogentcore.org/core/shell/interpreter" "cogentcore.org/core/styles" "cogentcore.org/core/styles/units" "cogentcore.org/core/texteditor" From 65cef3aa4daa16af30cfb10b19c3f138f9497aa3 Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Mon, 7 Oct 2024 17:38:43 -0700 Subject: [PATCH 2/6] code sets read only for generated files; uses 'goal build' instead of 'go build' if it finds a 'goal' exe on path. --- author/book/book.goal | 14 ++++++++++++-- code/code.go | 7 ++++++- code/commands.go | 10 ++++++++++ code/texteditor.go | 9 --------- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/author/book/book.goal b/author/book/book.goal index bdb24b15..0be7fcb0 100644 --- a/author/book/book.goal +++ b/author/book/book.goal @@ -14,11 +14,21 @@ package book import ( "fmt" - - "cogentcore.org/core/base/logx" + "io/fs" + "log/slog" + "os" + "path" + "path/filepath" + "sort" + + "cogentcore.org/cogent/author" + "cogentcore.org/cogent/author/refs" + "cogentcore.org/core/base/errors" "cogentcore.org/core/base/iox/imagex" "cogentcore.org/core/base/iox/yamlx" + "cogentcore.org/core/base/logx" goalp "cogentcore.org/core/goal" + "cogentcore.org/core/goal/goalib" ) var ( diff --git a/code/code.go b/code/code.go index 6ba12f34..3fc175ac 100644 --- a/code/code.go +++ b/code/code.go @@ -217,7 +217,12 @@ func (cv *Code) makeTextEditor(p *tree.Plan, i int) { }) tree.AddChildAt(w, "texteditor-"+txnm, func(w *TextEditor) { w.Code = cv - ConfigEditorTextEditor(&w.Editor) + w.Styler(func(s *styles.Style) { + s.Grow.Set(1, 1) + s.Min.X.Ch(20) + s.Min.Y.Em(5) + w.SetReadOnly(w.Buffer.Info.Generated) + }) w.OnFocus(func(e events.Event) { cv.ActiveTextEditorIndex = i }) diff --git a/code/commands.go b/code/commands.go index 1c63a0d1..b09db674 100644 --- a/code/commands.go +++ b/code/commands.go @@ -781,6 +781,16 @@ func (cm *Commands) CopyFrom(cp Commands) { // MergeAvailableCmds updates the AvailCmds list from CustomCmds and StdCmds func MergeAvailableCmds() { AvailableCommands.CopyFrom(StandardCommands) + hasGoal := false + if _, err := exec.LookPath("goal"); err == nil { + hasGoal = true + } + if hasGoal { // replace go build commands with goal build + gob, _, _ := AvailableCommands.CmdByName(CmdName(CommandName("Go", "Build Dir")), false) + gob.Cmds[0].Cmd = "goal" + gob, _, _ = AvailableCommands.CmdByName(CmdName(CommandName("Go", "Build Proj")), false) + gob.Cmds[0].Cmd = "goal" + } for _, cmd := range CustomCommands { _, idx, has := AvailableCommands.CmdByName(CmdName(cmd.Label()), false) if has { diff --git a/code/texteditor.go b/code/texteditor.go index 38a853a8..cece39b6 100644 --- a/code/texteditor.go +++ b/code/texteditor.go @@ -183,15 +183,6 @@ func ConfigOutputTextEditor(ed *texteditor.Editor) { }) } -// ConfigEditorTextEditor configures an editor texteditor -func ConfigEditorTextEditor(ed *texteditor.Editor) { - ed.Styler(func(s *styles.Style) { - s.Grow.Set(1, 1) - s.Min.X.Ch(20) - s.Min.Y.Em(5) - }) -} - // ContextMenu builds the text editor context menu func (ed *TextEditor) ContextMenu(m *core.Scene) { core.NewButton(m).SetText("Copy").SetIcon(icons.ContentCopy). From f99204d0e13f41ce3065c1cdc2278db6db7a776a Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Mon, 7 Oct 2024 21:33:35 -0700 Subject: [PATCH 3/6] open source of generated files, not the generated file, for errors and other links. --- code/editor.go | 1 + code/files.go | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/code/editor.go b/code/editor.go index ae972ad6..0fa66dba 100644 --- a/code/editor.go +++ b/code/editor.go @@ -414,6 +414,7 @@ func (cv *Code) OpenFileURL(ur string, ftv *texteditor.Editor) bool { } } pos := up.Fragment + tv, _, ok := cv.LinkViewFile(core.Filename(fpath)) if !ok { _, fnm := filepath.Split(fpath) diff --git a/code/files.go b/code/files.go index e58229c8..4432d4d5 100644 --- a/code/files.go +++ b/code/files.go @@ -12,6 +12,7 @@ import ( "time" "cogentcore.org/core/base/fileinfo" + "cogentcore.org/core/base/fsx" "cogentcore.org/core/core" "cogentcore.org/core/events" "cogentcore.org/core/filetree" @@ -319,13 +320,34 @@ func (cv *Code) LinkViewFileNode(fn *filetree.Node) (*TextEditor, int) { return tv, idx } +// GeneratedFileExts are file extensions for the source file that generates +// another file. If a file is opened that is marked as generated, this list is +// used to look for another file with the same name and the source extention, +// and it is opened instead. +var GeneratedFileExts = map[string]string{ + ".goal": ".go", +} + // LinkViewFile opens the file in the 2nd texteditor, which is next to // the tabs where links are clicked, if it is not collapsed -- else 1st func (cv *Code) LinkViewFile(fnm core.Filename) (*TextEditor, int, bool) { - fn := cv.FileNodeForFile(string(fnm), true) + fn := cv.FileNodeForFile(string(fnm), true) // add if not found if fn == nil { return nil, -1, false } + if fn.Info.Generated { + bfnm, ext := fsx.ExtSplit(string(fnm)) + for ex, fex := range GeneratedFileExts { + if fex == ext { + nfnm := bfnm + ex + nfn := cv.FileNodeForFile(nfnm, false) + if nfn != nil { + fn = nfn + break + } + } + } + } tv, idx, ok := cv.TextEditorForFileNode(fn) if ok { if idx == 1 { From 8db6597487899b325a6a88501297fe95c065a70d Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Mon, 7 Oct 2024 21:46:17 -0700 Subject: [PATCH 4/6] update to current goal core --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5bc6fdd1..14060d51 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module cogentcore.org/cogent go 1.22 require ( - cogentcore.org/core v0.3.5-0.20241007210315-636a2d6b7fc8 + cogentcore.org/core v0.3.5-0.20241008044156-a7ed4e8f9c75 github.com/Knetic/govaluate v3.0.0+incompatible github.com/aandrew-me/tgpt/v2 v2.7.2 github.com/alecthomas/chroma/v2 v2.13.0 diff --git a/go.sum b/go.sum index 142412d5..032e2bb9 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -cogentcore.org/core v0.3.5-0.20241007210315-636a2d6b7fc8 h1:cf6+MvGjy6pSsjSK6u+coLLHEJ6sG5aBB3zzWun6T14= -cogentcore.org/core v0.3.5-0.20241007210315-636a2d6b7fc8/go.mod h1:HiWp9KXOQmYNaW5wdGpMBEHQTVprdsfBzVmTJ8OPk1A= +cogentcore.org/core v0.3.5-0.20241008044156-a7ed4e8f9c75 h1:b3rS/1Hm4dekw4R0lsvEE4oC/40sPnAhmB8VJdakbas= +cogentcore.org/core v0.3.5-0.20241008044156-a7ed4e8f9c75/go.mod h1:HiWp9KXOQmYNaW5wdGpMBEHQTVprdsfBzVmTJ8OPk1A= github.com/Bios-Marcel/wastebasket v0.0.4-0.20240213135800-f26f1ae0a7c4 h1:6lx9xzJAhdjq0LvVfbITeC3IH9Fzvo1aBahyPu2FuG8= github.com/Bios-Marcel/wastebasket v0.0.4-0.20240213135800-f26f1ae0a7c4/go.mod h1:FChzXi1izqzdPb6BiNZmcZLGyTYiT61iGx9Rxx9GNeI= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= From 40452901e044fc49a2088297a463e2b7741c7cb4 Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Mon, 7 Oct 2024 23:43:26 -0700 Subject: [PATCH 5/6] crash guard in code, and update to latest core --- code/code.go | 4 +++- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/code/code.go b/code/code.go index 3fc175ac..f04c4bf2 100644 --- a/code/code.go +++ b/code/code.go @@ -221,7 +221,9 @@ func (cv *Code) makeTextEditor(p *tree.Plan, i int) { s.Grow.Set(1, 1) s.Min.X.Ch(20) s.Min.Y.Em(5) - w.SetReadOnly(w.Buffer.Info.Generated) + if w.Buffer != nil { + w.SetReadOnly(w.Buffer.Info.Generated) + } }) w.OnFocus(func(e events.Event) { cv.ActiveTextEditorIndex = i diff --git a/go.mod b/go.mod index 14060d51..9e0ea59c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module cogentcore.org/cogent go 1.22 require ( - cogentcore.org/core v0.3.5-0.20241008044156-a7ed4e8f9c75 + cogentcore.org/core v0.3.5-0.20241008063015-a9780190b4d3 github.com/Knetic/govaluate v3.0.0+incompatible github.com/aandrew-me/tgpt/v2 v2.7.2 github.com/alecthomas/chroma/v2 v2.13.0 diff --git a/go.sum b/go.sum index 032e2bb9..9387c773 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -cogentcore.org/core v0.3.5-0.20241008044156-a7ed4e8f9c75 h1:b3rS/1Hm4dekw4R0lsvEE4oC/40sPnAhmB8VJdakbas= -cogentcore.org/core v0.3.5-0.20241008044156-a7ed4e8f9c75/go.mod h1:HiWp9KXOQmYNaW5wdGpMBEHQTVprdsfBzVmTJ8OPk1A= +cogentcore.org/core v0.3.5-0.20241008063015-a9780190b4d3 h1:fIazr2orn9A3LSCfedi16RXUrG52y0vwSS5YYDp9B4k= +cogentcore.org/core v0.3.5-0.20241008063015-a9780190b4d3/go.mod h1:HiWp9KXOQmYNaW5wdGpMBEHQTVprdsfBzVmTJ8OPk1A= github.com/Bios-Marcel/wastebasket v0.0.4-0.20240213135800-f26f1ae0a7c4 h1:6lx9xzJAhdjq0LvVfbITeC3IH9Fzvo1aBahyPu2FuG8= github.com/Bios-Marcel/wastebasket v0.0.4-0.20240213135800-f26f1ae0a7c4/go.mod h1:FChzXi1izqzdPb6BiNZmcZLGyTYiT61iGx9Rxx9GNeI= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= From 18debd2be94821820a8aba103edd6a9249f7dc4f Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Fri, 25 Oct 2024 03:23:13 -0700 Subject: [PATCH 6/6] removed env vars now that I've figured out how to set them on mac through launchctl as documented in README.md and implemented in goal --- code/README.md | 14 ++++++++++++++ code/settings.go | 11 ----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/code/README.md b/code/README.md index 6618b38a..cccf41d2 100644 --- a/code/README.md +++ b/code/README.md @@ -20,6 +20,20 @@ go install cogentcore.org/cogent/code/cmd/cogentcode@latest * See Releases on this github page for pre-built OS-specific app packages that install the compiled binaries. +## MacOS environment variables + +When `Code` is run from an installed mac app bundle, it does not inherit the normal shell environment. To set environment variables in a way that extends to GUI apps, you must use: +```sh +launchctl setenv VAR VALUE +``` +The `goal` shell automatically does this for you when setting any environment variables. + +This does not extend to the `PATH` variable, which requires this command: +```sh +sudo launchctl config user path $PATH +``` +This only takes effect after a reboot. Also, once done, then the default shell path will have that path, already, so commands to set the path in the shell will end up with duplicates. + # Future Plans We plan to incorporate [gopls](https://github.com/golang/tools/tree/master/gopls) to provide more comprehensive Go language IDE-level support, similar to what is found in VS Code. At present, the completion can be a bit spotty for some kinds of expressions, and the lookup "go to definition" functionality is also not perfect. However, the basic code editing dynamics are pretty solid, so adding gopls would bring it much closer to feature-parity with VS Code. diff --git a/code/settings.go b/code/settings.go index aba9e8b0..c525878c 100644 --- a/code/settings.go +++ b/code/settings.go @@ -43,9 +43,6 @@ type SettingsData struct { //types:add // file picker settings Files FileSettings - // environment variables to set for this app -- if run from the command line, standard shell environment variables are inherited, but on some OS's (Mac), they are not set when run as a gui app - EnvVars map[string]string - // if set, the current customized set of language options (see Edit Lang Opts) is saved / loaded along with other settings -- if not set, then you always are using the default compiled-in standard set (which will be updated) SaveLangOpts bool @@ -117,7 +114,6 @@ func (se *SettingsData) Open() error { func (se *SettingsData) Apply() { //types:add MergeAvailableCmds() AvailableLanguages.Validate() - se.ApplyEnvVars() } // SetGoMod applies the given gomod setting, setting the GO111MODULE env var @@ -129,13 +125,6 @@ func SetGoMod(gomod bool) { } } -// ApplyEnvVars applies environment variables set in EnvVars -func (se *SettingsData) ApplyEnvVars() { - for k, v := range se.EnvVars { - os.Setenv(k, v) - } -} - func (se *SettingsData) MakeToolbar(p *tree.Plan) { tree.Add(p, func(w *core.FuncButton) { w.SetFunc(se.EditLangOpts).SetIcon(icons.Subtitles)