Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc fixes for core from the cogent lab development branch and removal of all lab stuff. #1391

Merged
merged 448 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
448 commits
Select commit Hold shift + click to select a range
1f916d5
break up Run and Done commands to allow sequencing.
rcoreilly Oct 4, 2024
a7b0e5a
actually parse read-only flag and use in generated code
rcoreilly Oct 4, 2024
cbd7d4d
start on auto-processing of global var exprs with tmp vars. one very …
rcoreilly Oct 5, 2024
0b3deae
calling functions with global vars now automatically creates tmp vars…
rcoreilly Oct 5, 2024
157954b
complete working mockup of how to do tensors in gosl. added Header of…
rcoreilly Oct 5, 2024
18a80d2
generating correct gosl.go code and parsing various tensor properties.
rcoreilly Oct 6, 2024
a28cb78
gosl tensor translation full working
rcoreilly Oct 6, 2024
e7f0783
rand updated to new gosl code
rcoreilly Oct 6, 2024
9109105
add wgsl
rcoreilly Oct 6, 2024
03ca327
move gosl back up to main gosl dir -- don't need other things in gosl…
rcoreilly Oct 6, 2024
f8e6083
matrix.Inverse function, and return errors instead of panic in matrix…
rcoreilly Oct 6, 2024
6891c5e
gotosl test now working with new paradigm
rcoreilly Oct 6, 2024
90c1ff5
updated docs for gosl and GPU
rcoreilly Oct 6, 2024
b1eb7d2
tensor n-dim indexing in goal mode; translates to Value, Set* functions
rcoreilly Oct 7, 2024
e176319
split out yaegicore into nogui and gui components, goal only includes…
rcoreilly Oct 7, 2024
d520baa
goal build runs gosl and go build
rcoreilly Oct 7, 2024
293bb2c
verbose fixes etc
rcoreilly Oct 7, 2024
087225c
goal: fix parsing of Go assignment expressions, including now getting…
rcoreilly Oct 7, 2024
562463c
core.Filename is alias for fs.Filename
rcoreilly Oct 7, 2024
fb30eee
fix goal build final code composition -- generate code first then wra…
rcoreilly Oct 7, 2024
636a2d6
get the scripts functionality and helper functions from numbers/datab…
rcoreilly Oct 7, 2024
6e81601
fileinfo detects generated files using standard Go regex, and filetre…
rcoreilly Oct 7, 2024
73e8663
use go format.Source on generated full goal build files (but not impo…
rcoreilly Oct 8, 2024
35825cc
textedtitor readonly uses SurfaceContainer (not Low) background for r…
rcoreilly Oct 8, 2024
a7ed4e8
exclude generated files from search results in filetree
rcoreilly Oct 8, 2024
a978019
moved PCA (EigSym) over to matrix, along with SVD, where they belong..
rcoreilly Oct 8, 2024
972bb9f
use parallel threading for N>2 dim matrix ops which are very expensiv…
rcoreilly Oct 8, 2024
2dd807b
wrap ndim index exprs in int() so they always work
rcoreilly Oct 8, 2024
83fbb1b
gosl: remove int() wrapper for tensor indexing calls
rcoreilly Oct 8, 2024
732b831
use %.10g for default tensor sprintf format -- removes tiny residual …
rcoreilly Oct 8, 2024
980319f
add bool Value, Set functions
rcoreilly Oct 8, 2024
052427e
goal: key fix to decl parsing -- only if brack and paren depth 0
rcoreilly Oct 8, 2024
48b5e43
N-dimensional indexing uses recursive go parsing.
rcoreilly Oct 9, 2024
49a9941
fix comment handling
rcoreilly Oct 9, 2024
e223197
fix comment handling for real, good tests
rcoreilly Oct 9, 2024
9d3db3e
gosl: support tensor pointers for global vars
rcoreilly Oct 9, 2024
2cdc6b8
base/generate and enumgen were filtering out generated files, which e…
rcoreilly Oct 9, 2024
35497ec
goal: dec is same as inc
rcoreilly Oct 9, 2024
9a7d941
gosl & goal have better error reporting and gosl inserts //line comme…
rcoreilly Oct 10, 2024
684904f
gosl: auto Get* functions for global vars, that GPU re-interprets, to…
rcoreilly Oct 11, 2024
69f246b
use gosl imports -- works great!
rcoreilly Oct 11, 2024
3fa7bc0
key bugfix: was not removing imported package prefixes
rcoreilly Oct 11, 2024
5f84974
must do vars file first to get vars; still not quite working for pl.I…
rcoreilly Oct 11, 2024
f7e1ea1
gosl tensor handles SetAdd etc properly.
rcoreilly Oct 12, 2024
2e82b9f
get type of Get* temp vars, looking up in type package scope.
rcoreilly Oct 12, 2024
9b2bbb5
start on atomic -- needs atomic type -- will require some infra for t…
rcoreilly Oct 12, 2024
2ebb515
major reorganization to generate only those functions that are used i…
rcoreilly Oct 13, 2024
b96d530
fix tmpvar name for Get -> Set
rcoreilly Oct 13, 2024
6a9a4d6
add package.function calls for callgraph -- fixes FastExp
rcoreilly Oct 14, 2024
00be93f
get path type for Get temp vars
rcoreilly Oct 14, 2024
c9c5807
set global var from temp _before_ final return statement
rcoreilly Oct 14, 2024
95082fd
prevent redundant include, fix tests and exampels.
rcoreilly Oct 14, 2024
9711018
important fix for enumgen, typegen: exclude enumgen.go, typegen.go fi…
rcoreilly Oct 17, 2024
ecf906c
in process logic for commands / builtins to be able to do pipe output…
rcoreilly Oct 25, 2024
215e3df
pipe working for builtin but not commands -- args fixed -- unclear wh…
rcoreilly Oct 25, 2024
7ceb537
Set builtin automatically does home path expansion and dedupe, as doe…
rcoreilly Oct 25, 2024
433561d
goal: a bit more robustness for crashing but still not dealing with s…
rcoreilly Oct 25, 2024
d10c186
goal: & of tensor -> ValuePtr -- needed for atomic exprs
rcoreilly Oct 31, 2024
e02a82b
full atomic support in place
rcoreilly Oct 31, 2024
2b46ead
goal: add atomic test case and const slice test case, and rename atom…
rcoreilly Nov 1, 2024
cd0f474
add Editable to texteditor context menu when in read only mode
rcoreilly Nov 1, 2024
1fbfb70
gosl properly handles global array vars as consts.
rcoreilly Nov 1, 2024
afc747f
gosl: enumgen exports the N const with //gosl:start, end wrapper -- n…
rcoreilly Nov 1, 2024
8a57518
gosl: for range expr translation
rcoreilly Nov 2, 2024
ded4517
GPUInit is safe to multiple calls; README docs updates
rcoreilly Nov 4, 2024
1de1aee
Merge branch 'main' into goal
rcoreilly Nov 4, 2024
ab2169d
Merge branch 'main' into goal
rcoreilly Nov 5, 2024
febe06c
plot styler implementation -- seems reasonable
rcoreilly Nov 6, 2024
fd42b32
plots: new functions don't return err so direct Add works
rcoreilly Nov 6, 2024
844be5a
plots: gearing up to test goal api for plotting using planets data
rcoreilly Nov 6, 2024
a2f6978
ploteditor styling functions
rcoreilly Nov 6, 2024
5167ef5
updated datafs-sim example with stat funcs that do everything in one …
rcoreilly Nov 6, 2024
462bfdf
first pass on new unified style, only for plots for now; got rid of s…
rcoreilly Nov 7, 2024
9974fe1
XY is the common Plotter type for Line and Scatter, just sets Line vs…
rcoreilly Nov 7, 2024
1ecc504
plot styles mostly in place and working -- need styler logic etc.
rcoreilly Nov 7, 2024
967e939
new styling plan in place for how to combine plot and element level s…
rcoreilly Nov 7, 2024
75e27b8
plot: all styling in place, elements updated, plots replicating. next…
rcoreilly Nov 8, 2024
003f149
plot styling fully working including range; imagex/testing now saves …
rcoreilly Nov 8, 2024
b95d503
new plot data framework all in place and building, but tests are failing
rcoreilly Nov 9, 2024
c00873f
use Data type for map, much simpler call signature
rcoreilly Nov 9, 2024
8c171b0
plot.Data is the map, Valuer is the value interface -- use plot.Data{…
rcoreilly Nov 9, 2024
1bdcd3d
fix Xaxis style scaling
rcoreilly Nov 9, 2024
d028ce7
checklengths
rcoreilly Nov 9, 2024
71150b9
rest of register functions
rcoreilly Nov 9, 2024
90536d6
fix xerr
rcoreilly Nov 9, 2024
43c3157
update README
rcoreilly Nov 11, 2024
780dd78
styler metadata; metadata has Metadataer interface for grabing from a…
rcoreilly Nov 11, 2024
58000e0
tensor-attached plot stylers example, tests etc.
rcoreilly Nov 11, 2024
3c88bf9
plot: start on table based plotting -- not working
rcoreilly Nov 11, 2024
c293888
table plot working for each plot type; fix label plotting; fix minmax…
rcoreilly Nov 12, 2024
f75d485
error bars use Y range properly, and range more generally; Low is opt…
rcoreilly Nov 12, 2024
a725107
fix inverted scale -> needs underlying scale
rcoreilly Nov 12, 2024
45890e0
ploteditor taking shape -- just need a reflectx copy named fields fun…
rcoreilly Nov 12, 2024
22c985b
ploteditor: CopyFields is working to set changed values, but color co…
rcoreilly Nov 12, 2024
ee023f4
reflectx image pointer copying now working properly -- CopyFields nee…
rcoreilly Nov 13, 2024
915f134
ploteditor default styling reasonable
rcoreilly Nov 13, 2024
b4b8278
overall plot styling working
rcoreilly Nov 13, 2024
f3bd93c
set columns buttons working; style switches with line color
rcoreilly Nov 13, 2024
05fc348
global x axis and auto legend
rcoreilly Nov 13, 2024
bc7464d
plot table: tricky logic for automatic X axis label working
rcoreilly Nov 13, 2024
a2d67fd
readme
rcoreilly Nov 13, 2024
4bded0c
bar plot striding logic; increase default nticks; cleanup old code
rcoreilly Nov 13, 2024
4531b30
panzoom post-processing -- better than before. also has shift = x, al…
rcoreilly Nov 13, 2024
de3e5e1
plot highlighting for kai
rcoreilly Nov 13, 2024
3e62411
tensor: only support one set of Row access methods, always taking cel…
rcoreilly Nov 14, 2024
d25dbd2
sim stats working much better: need loop phase input
rcoreilly Nov 14, 2024
90d672f
add AppendRowFloat, Int, String -- much cleaner for those cases
rcoreilly Nov 14, 2024
79dc4c5
better names and cleanup of datafs-sim
rcoreilly Nov 14, 2024
9c32594
add readme
rcoreilly Nov 14, 2024
fa11baa
core.tree and filetree: major update: Root is exported and is type Tr…
rcoreilly Nov 14, 2024
702d792
rest of fix for #1232 -- call update on tree when first ext is added.
rcoreilly Nov 14, 2024
fc1706a
yaegicore update and further browser plans
rcoreilly Nov 14, 2024
c18519b
databrowser separated, Basic pulled out
rcoreilly Nov 15, 2024
06d5c43
fix goal parsing of static initializer Field: expressions. databrowse…
rcoreilly Nov 15, 2024
5f34201
goal: some crash protections
rcoreilly Nov 15, 2024
28961a6
goal: plotting is robust to nil and plot update function in databrows…
rcoreilly Nov 16, 2024
7487521
key fix to databrowser tabs logic: target item is last widget in tab …
rcoreilly Nov 16, 2024
a82e893
gosl runs CPU functions using threaded calls
rcoreilly Nov 16, 2024
8d540d5
plot: fix hover to actually report data instead of pixels!
rcoreilly Nov 16, 2024
4a7f491
core.Tabs also needs a Tabber interface to get parent Tabs when it co…
rcoreilly Nov 16, 2024
648ad6f
goal: select tab by name in db Tabber
rcoreilly Nov 16, 2024
5456f8b
goal: negative indexing in basic 1D tensor case -- todo: need to add …
rcoreilly Nov 16, 2024
8c113ab
more tab api
rcoreilly Nov 17, 2024
ad313ea
only support global metadata.Name / SetName interface
rcoreilly Nov 17, 2024
538b1d7
merge with main
rcoreilly Nov 17, 2024
ab7b603
goal: fix tests, add File and Filename to metadata
rcoreilly Nov 18, 2024
03addeb
goal: key fixes to tensor.Rows Set*1D methods: return after indexes =…
rcoreilly Nov 18, 2024
6a5bd8a
goal: exec/TestStdIO out is pipe is true
rcoreilly Nov 18, 2024
859ab42
remove core prefix from Tabber
rcoreilly Nov 18, 2024
c2fe534
fix precision to use new metadata funcs
rcoreilly Nov 18, 2024
9750b0f
rename datafs -> tensorfs
rcoreilly Nov 19, 2024
f3bf82a
enumgen has -gosl option for generating gosl comments
rcoreilly Nov 19, 2024
c182389
more datafs renames in databrowser
rcoreilly Nov 19, 2024
2faafaa
major cleanup of tensorfs: rename Data -> Node, reduce API, add READM…
rcoreilly Nov 19, 2024
2163667
fix randx dists_test
rcoreilly Nov 19, 2024
1c21d3f
gpu Release encoders before Finish -- needed for newer wgpu; ToGPU is…
rcoreilly Nov 21, 2024
fca60e4
gosl: use consistent order of generated kernels, systems
rcoreilly Nov 21, 2024
7c7e55c
gosl: GPURelease is robust to no gpu, multiple calls.
rcoreilly Nov 22, 2024
691afa8
goal: tensor printing format and projection2d logic vastly improved -…
rcoreilly Nov 23, 2024
d081797
goal: test updates to new print format
rcoreilly Nov 23, 2024
7cb6c3d
goal: yaegicore update
rcoreilly Nov 23, 2024
6b98fa3
goal: tensorfs DirFromTable sets dir tensors from a table
rcoreilly Nov 23, 2024
34e47b2
cli: if only one command is passed to cli.Run, it is set as root
rcoreilly Nov 23, 2024
b598836
Merge commit 'a31766c9f42558d7cc1df19022a7be53861dfc0a' into goal
rcoreilly Nov 25, 2024
35cd77e
merge with main
rcoreilly Nov 25, 2024
29e40fa
update to reflectx.AnyIsNil -> IsNil
rcoreilly Nov 25, 2024
fa7d3b1
Merge commit 'dd5006304' into goal
rcoreilly Nov 26, 2024
fdb597e
Merge branch 'screens' into goal
rcoreilly Nov 26, 2024
2054450
Merge branch 'screens' into goal
rcoreilly Nov 26, 2024
63789c6
Merge branch 'menufocus' into goal
rcoreilly Nov 26, 2024
98ca16f
Merge branch 'screens' into goal
rcoreilly Nov 27, 2024
d1dc169
goal: add type-specific shortcuts to tensorfs
rcoreilly Nov 28, 2024
ce7b842
Merge branch 'screens' into goal
rcoreilly Nov 28, 2024
cbf6dff
update fullscreen flag in UpdateFullscreen
rcoreilly Nov 28, 2024
1a4013c
initial fullscreen sets size properly in scene etc
rcoreilly Nov 28, 2024
edb1359
tensorfs.CurRoot and databrowser.CurTabber for ad-hoc data plotting etc.
rcoreilly Dec 1, 2024
066d53d
reflectx SetFieldsFromMap and FieldAtPath -- from emer.params -- usef…
rcoreilly Dec 1, 2024
247cc8b
move SetFields to structs -- just one func.
rcoreilly Dec 1, 2024
9a7dbbe
tensor: major improvement in stats, metric speed -- 5x to 7x -- inter…
rcoreilly Dec 2, 2024
804fab4
don't do Scene shortcut updating in offscreen platform
rcoreilly Dec 2, 2024
73abe3c
goal: changes to enable core run web to build and run (also need patc…
rcoreilly Dec 3, 2024
b462156
goal: tensorfs handles multi-dir paths in RecycleDir
rcoreilly Dec 3, 2024
d603d83
gosl: major update to use separate TensorStrides variable that is aut…
rcoreilly Dec 3, 2024
7876e13
gosl: finished major update to use separate TensorStrides variable.
rcoreilly Dec 3, 2024
748b871
return GPUDevice in TheApp -- might need for compute to get GUI GPU.
rcoreilly Dec 4, 2024
a91b998
gosl: many fixes: docs include size, slrand and type include only if …
rcoreilly Dec 4, 2024
6a67f7e
gosl: couldn't get rand import conditionality to work in axon.
rcoreilly Dec 4, 2024
75608cf
gosl: fixed rand import on demand
rcoreilly Dec 4, 2024
2c84228
gosl: readme fixes
rcoreilly Dec 4, 2024
6ae279f
gpu/compute example updated with gui and timing cases for diagnosing …
rcoreilly Dec 5, 2024
ca1deae
gosl: add notes about installing naga and tint for gosl.
rcoreilly Dec 5, 2024
31b4441
gpu adapter name fixes
rcoreilly Dec 5, 2024
6d0170d
merge screens into goal
rcoreilly Dec 5, 2024
69b6a19
AppearanceSettings Screens is now read-only and improved comment docs…
rcoreilly Dec 5, 2024
0a49e9e
Merge commit 'd0111a0c522027cbcac4e54b527f857b288db251' into goal
rcoreilly Dec 6, 2024
0de2ad5
Merge branch 'screens' into goal
rcoreilly Dec 7, 2024
2b8fa3e
Merge branch 'screens' into goal
rcoreilly Dec 7, 2024
ba6c108
reminder about issue 1362 in device code
rcoreilly Dec 7, 2024
224cb66
critical fix for gpu compute device Max limits -- must be properly me…
rcoreilly Dec 7, 2024
3bbd50b
compute workgroup indexing logic in place, all good
rcoreilly Dec 8, 2024
bde99e3
gosl: update gosl to use new indexing logic
rcoreilly Dec 8, 2024
fd57490
merge main (screens) into goal
rcoreilly Dec 9, 2024
de6b16e
add table.Table Init() method for fields.
rcoreilly Dec 9, 2024
36e2633
fix for #1365 in goal branch -- added test, confirmed working
rcoreilly Dec 9, 2024
a38e70a
fix pointer-to-pointer logic to pass test
rcoreilly Dec 9, 2024
85b39f0
modernize tensor grid style with stylers and meta data etc, just like…
rcoreilly Dec 10, 2024
7d08e35
generate
rcoreilly Dec 10, 2024
5df1032
minmax.clipvalue -> clampvalue
rcoreilly Dec 10, 2024
c1d2fa3
goal: various plot / table / tensor api updates
rcoreilly Dec 11, 2024
e79b5d6
fixed major issues with plot stylers -- was accumulating more and mor…
rcoreilly Dec 11, 2024
5748481
plot: actually saving the mods and style with metadata is exactly the…
rcoreilly Dec 11, 2024
c9a1396
key fix for ploteditor: have to put the closure inside AddAt -- thoug…
rcoreilly Dec 12, 2024
ae821fb
partial fix for form layout
rcoreilly Dec 15, 2024
a07f8ef
merge main into goal
rcoreilly Dec 15, 2024
08bdda7
events does a focusClear just before sending Click event if current f…
rcoreilly Dec 15, 2024
9c835ab
Merge branch 'main' into goal
rcoreilly Dec 16, 2024
80c6bef
key fix to tensorfs for RecycleDir with paths
rcoreilly Dec 16, 2024
b09ad07
core tool buildDesktop detects presence of a cmd directory and builds…
rcoreilly Dec 18, 2024
c0c3867
glm: indexes may be nil.
rcoreilly Dec 19, 2024
9fd59c9
tensorfs: RecycleDir -> Dir -- simplify to one api call and make it s…
rcoreilly Dec 19, 2024
740dc0f
ploteditor shows tooltip including docs from tensor, and tensorfs Dir…
rcoreilly Dec 19, 2024
3665412
stats: add First / Final stats
rcoreilly Dec 21, 2024
4641252
partial fix for crashing on shouldDisplay, and test case showing sizi…
rcoreilly Dec 21, 2024
e92ae92
fix for #1387: bounding boxes must be based on alloc, not actual, for…
rcoreilly Dec 21, 2024
1a151e2
remove goal, plot, tensor, which have moved to cogent lab
rcoreilly Dec 22, 2024
fc30cb1
remove base/* packages moved to cogent lab; update yaegicore to exclu…
rcoreilly Dec 22, 2024
bb4d3ba
remove plot example
rcoreilly Dec 22, 2024
f719a15
form: fix tests with new bboxes
rcoreilly Dec 22, 2024
730c847
Merge branch 'main' into miscfix
rcoreilly Dec 23, 2024
dbeb6f3
remove plot from docs
rcoreilly Dec 23, 2024
b21194c
remove line from dem
rcoreilly Dec 23, 2024
397d78b
undo core cmd build thing.
rcoreilly Dec 23, 2024
147733b
fix it
rcoreilly Dec 23, 2024
4359bf6
remove extra line
rcoreilly Dec 23, 2024
632f017
rename yaegicore symbols
rcoreilly Dec 23, 2024
9ef8960
clarify basesymbols docs
kkoreilly Dec 23, 2024
524f8bb
reflectx.FieldValue as for loop
rcoreilly Dec 23, 2024
a2adcaa
reflectx.CopyFields underlying
rcoreilly Dec 23, 2024
f59be2f
remove redundant reflectx.FieldAtPath
rcoreilly Dec 23, 2024
b9859d5
use errors.log
rcoreilly Dec 23, 2024
5db3927
use errors.log
rcoreilly Dec 23, 2024
0e71727
assert no err
rcoreilly Dec 23, 2024
ec31845
rename to UniqueList
rcoreilly Dec 23, 2024
2bd2bd6
remove redundant focusClear
rcoreilly Dec 23, 2024
48eb4bb
not modified
rcoreilly Dec 23, 2024
18bd14b
remove spacing in test
rcoreilly Dec 23, 2024
77289e0
layouter
rcoreilly Dec 23, 2024
bf5af6b
tensorcore.Table
rcoreilly Dec 23, 2024
591d2b1
len(action)
rcoreilly Dec 23, 2024
cebb987
printlninfo
rcoreilly Dec 23, 2024
7245124
treer
rcoreilly Dec 23, 2024
2cac877
inf
rcoreilly Dec 23, 2024
b365d09
firefox
rcoreilly Dec 23, 2024
2c6b7bc
no print
rcoreilly Dec 23, 2024
ba65b30
FieldByPath and yaegi base
rcoreilly Dec 23, 2024
25cc7a5
ToBase for colors in filepath nodes
rcoreilly Dec 23, 2024
c610c70
faslkdfjasd
rcoreilly Dec 23, 2024
0f9f9be
screen size
rcoreilly Dec 23, 2024
c66da7c
editable
rcoreilly Dec 23, 2024
f39f659
printlninfo
rcoreilly Dec 23, 2024
904b2f7
slider test was spacing
rcoreilly Dec 23, 2024
3d89bcc
Tabber only returns the impl.
rcoreilly Dec 23, 2024
1873f5b
use goal not cosh in make scripts
rcoreilly Dec 23, 2024
b93f0b6
revert BBox back to Actual
rcoreilly Dec 23, 2024
7251cd4
rename enumgen.go to generate.go; confusing and problem-causing for i…
kkoreilly Dec 23, 2024
4649ff2
typegen now works on enumgen.Generate again with enumgen.go renamed
kkoreilly Dec 23, 2024
2b4a0ef
add todo about #1394
rcoreilly Dec 23, 2024
fb68e21
rename typegen.go to generate.go to avoid confusion and name conflicts
kkoreilly Dec 23, 2024
5b1b90d
typegen now includes typegen.Generate again with typegen.go renamed
kkoreilly Dec 23, 2024
9f1a5d9
fix #1365 in a more robust way
kkoreilly Dec 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
48 changes: 0 additions & 48 deletions base/atomiccounter/atomiccounter.go

This file was deleted.

28 changes: 0 additions & 28 deletions base/atomiccounter/atomiccounter_test.go

This file was deleted.

14 changes: 9 additions & 5 deletions base/exec/stdio.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ func (st *StdIO) Set(o *StdIO) *StdIO {
func (st *StdIO) SetToOS() *StdIO {
cur := &StdIO{}
cur.SetFromOS()
if sif, ok := st.In.(*os.File); ok {
os.Stdin = sif
} else {
fmt.Printf("In is not an *os.File: %#v\n", st.In)
}
os.Stdout = st.Out.(*os.File)
os.Stderr = st.Err.(*os.File)
os.Stdin = st.In.(*os.File)
return cur
}

Expand Down Expand Up @@ -98,13 +102,10 @@ func IsPipe(rw any) bool {
if rw == nil {
return false
}
w, ok := rw.(io.Writer)
_, ok := rw.(io.Writer)
if !ok {
return false
}
if w == os.Stdout {
return false
}
of, ok := rw.(*os.File)
if !ok {
return false
Expand Down Expand Up @@ -247,6 +248,9 @@ func (st *StdIOState) PopToStart() {
for len(st.InStack) > st.InStart {
st.PopIn()
}
for len(st.PipeIn) > 0 {
CloseReader(st.PipeIn.Pop())
}
}

// ErrIsInOut returns true if the given Err writer is also present
Expand Down
4 changes: 2 additions & 2 deletions base/exec/stdio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ func TestStdIO(t *testing.T) {
assert.Equal(t, os.Stdout, st.Out)
assert.Equal(t, os.Stderr, st.Err)
assert.Equal(t, os.Stdin, st.In)
assert.Equal(t, false, st.OutIsPipe())
// assert.Equal(t, false, st.OutIsPipe())

obuf := &bytes.Buffer{}
ibuf := &bytes.Buffer{}
var ss StdIOState
ss.SetFromOS()
ss.StackStart()
assert.Equal(t, false, ss.OutIsPipe())
// assert.Equal(t, false, ss.OutIsPipe())

ss.PushOut(obuf)
assert.NotEqual(t, os.Stdout, ss.Out)
Expand Down
5 changes: 5 additions & 0 deletions base/fileinfo/fileinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ type FileInfo struct { //types:add
// version control system status, when enabled
VCS vcs.FileStatus `table:"-"`

// Generated indicates that the file is generated and should not be edited.
// For Go files, this regex: `^// Code generated .* DO NOT EDIT\.$` is used.
Generated bool `table:"-"`

// full path to file, including name; for file functions
Path string `table:"-"`
}
Expand Down Expand Up @@ -143,6 +147,7 @@ func (fi *FileInfo) SetMimeInfo() error {
}
fi.Cat = UnknownCategory
fi.Known = Unknown
fi.Generated = IsGeneratedFile(fi.Path)
fi.Kind = ""
mtyp, _, err := MimeFromFile(fi.Path)
if err != nil {
Expand Down
16 changes: 15 additions & 1 deletion base/fileinfo/mimetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ package fileinfo
import (
"fmt"
"mime"
"os"
"path/filepath"
"regexp"
"strings"

"github.com/h2non/filetype"
Expand Down Expand Up @@ -99,6 +101,18 @@ func MimeFromFile(fname string) (mtype, ext string, err error) {
return "", ext, fmt.Errorf("fileinfo.MimeFromFile could not find mime type for ext: %v file: %v", ext, fn)
}

var generatedRe = regexp.MustCompile(`^// Code generated .* DO NOT EDIT`)

func IsGeneratedFile(fname string) bool {
file, err := os.Open(fname)
if err != nil {
return false
}
head := make([]byte, 2048)
file.Read(head)
return generatedRe.Match(head)
}

// todo: use this to check against mime types!

// MimeToKindMapInit makes sure the MimeToKindMap is initialized from
Expand Down Expand Up @@ -316,7 +330,7 @@ var StandardMimes = []MimeType{
{"text/x-forth", []string{".frt"}, Code, Forth}, // note: ".fs" conflicts with fsharp
{"text/x-fortran", []string{".f", ".F"}, Code, Fortran},
{"text/x-fsharp", []string{".fs", ".fsi"}, Code, FSharp},
{"text/x-gosrc", []string{".go", ".mod", ".work", ".cosh"}, Code, Go},
{"text/x-gosrc", []string{".go", ".mod", ".work", ".goal"}, Code, Go},
{"text/x-haskell", []string{".hs", ".lhs"}, Code, Haskell},
{"text/x-literate-haskell", nil, Code, Haskell}, // todo: not sure if same or not

Expand Down
2 changes: 1 addition & 1 deletion base/fileinfo/typegen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions base/fsx/fsx.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import (
"time"
)

// Filename is used to open a file picker dialog when used as an argument
// type in a function, or as a field value.
type Filename string

// GoSrcDir tries to locate dir in GOPATH/src/ or GOROOT/src/pkg/ and returns its
// full path. GOPATH may contain a list of paths. From Robin Elkind github.com/mewkiz/pkg.
func GoSrcDir(dir string) (absDir string, err error) {
Expand Down
22 changes: 17 additions & 5 deletions base/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,28 @@ func PrintHeader(w io.Writer, pkg string, imports ...string) {
}
}

// Inspect goes through all of the files in the given package
// and calls the given function on each node in files that
// are not generated. The bool return value from the given function
// ExcludeFile returns true if the given file is on the exclude list.
func ExcludeFile(pkg *packages.Package, file *ast.File, exclude ...string) bool {
fpos := pkg.Fset.Position(file.FileStart)
_, fname := filepath.Split(fpos.Filename)
for _, ex := range exclude {
if fname == ex {
return true
}
}
return false
}

// Inspect goes through all of the files in the given package,
// except those listed in the exclude list, and calls the given
// function on each node. The bool return value from the given function
// indicates whether to continue traversing down the AST tree
// of that node and look at its children. If a non-nil error value
// is returned by the given function, the traversal of the tree is
// stopped and the error value is returned.
func Inspect(pkg *packages.Package, f func(n ast.Node) (bool, error)) error {
func Inspect(pkg *packages.Package, f func(n ast.Node) (bool, error), exclude ...string) error {
for _, file := range pkg.Syntax {
if ast.IsGenerated(file) {
if ExcludeFile(pkg, file, exclude...) {
continue
}
var terr error
Expand Down
28 changes: 28 additions & 0 deletions base/iox/imagex/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"os"
"path/filepath"
"strings"

"cogentcore.org/core/base/num"
)

// TestingT is an interface wrapper around *testing.T
Expand Down Expand Up @@ -56,6 +58,25 @@ func CompareColors(cc, ic color.RGBA, tol int) bool {
return true
}

// DiffImage returns the difference between two images,
// with pixels having the abs of the difference between pixels.
func DiffImage(a, b image.Image) image.Image {
ab := a.Bounds()
di := image.NewRGBA(ab)
for y := ab.Min.Y; y < ab.Max.Y; y++ {
for x := ab.Min.X; x < ab.Max.X; x++ {
cc := color.RGBAModel.Convert(a.At(x, y)).(color.RGBA)
ic := color.RGBAModel.Convert(b.At(x, y)).(color.RGBA)
r := uint8(num.Abs(int(cc.R) - int(ic.R)))
g := uint8(num.Abs(int(cc.G) - int(ic.G)))
b := uint8(num.Abs(int(cc.B) - int(ic.B)))
c := color.RGBA{r, g, b, 255}
di.Set(x, y, c)
}
}
return di
}

// Assert asserts that the given image is equivalent
// to the image stored at the given filename in the testdata directory,
// with ".png" added to the filename if there is no extension
Expand All @@ -77,6 +98,7 @@ func Assert(t TestingT, img image.Image, filename string) {

ext := filepath.Ext(filename)
failFilename := strings.TrimSuffix(filename, ext) + ".fail" + ext
diffFilename := strings.TrimSuffix(filename, ext) + ".diff" + ext

if UpdateTestImages {
err := Save(img, filename)
Expand All @@ -87,6 +109,7 @@ func Assert(t TestingT, img image.Image, filename string) {
if err != nil {
t.Errorf("AssertImage: error removing old fail image: %v", err)
}
os.RemoveAll(diffFilename)
return
}

Expand Down Expand Up @@ -133,10 +156,15 @@ func Assert(t TestingT, img image.Image, filename string) {
if err != nil {
t.Errorf("AssertImage: error saving fail image: %v", err)
}
err = Save(DiffImage(img, fimg), diffFilename)
if err != nil {
t.Errorf("AssertImage: error saving diff image: %v", err)
}
} else {
err := os.RemoveAll(failFilename)
if err != nil {
t.Errorf("AssertImage: error removing old fail image: %v", err)
}
os.RemoveAll(diffFilename)
}
}
6 changes: 6 additions & 0 deletions base/keylist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# keylist

keylist implements an ordered list (slice) of items (Values), with a map from a Key (e.g., names) to indexes, to support fast lookup by name. There is also a Keys slice.

This is a different implementation of the [ordmap](../ordmap) package, and has the advantage of direct slice access to the values, instead of having to go through the KeyValue tuple struct in ordmap.

Loading
Loading